CEPH 簡介
不管你是想為云平臺提供Ceph 物件存盤和/或 Ceph 塊設備,還是想部署一個 Ceph 檔案系統或者把 Ceph 作為他用,所有 Ceph 存盤集群的部署都始于部署一個個 Ceph 節點、網路和 Ceph 存盤集群, Ceph 存盤集群至少需要一個 Ceph Monitor 和兩個 OSD 守護行程,而運行 Ceph 檔案系統客戶端時,則必須要有元資料服務器( Metadata Server ),

- Ceph OSDs: Ceph OSD 守護行程( Ceph OSD )的功能是存盤資料,處理資料的復制、恢復、回填、再均衡,并通過檢查其他OSD 守護行程的心跳來向 Ceph Monitors 提供一些監控資訊,當 Ceph 存盤集群設定為有2個副本時,至少需要2個 OSD 守護行程,集群才能達到 active+clean 狀態( Ceph 默認有3個副本,但你可以調整副本數),
- Monitors: Ceph Monitor維護著展示集群狀態的各種圖表,包括監視器圖、 OSD 圖、歸置組( PG )圖、和 CRUSH 圖, Ceph 保存著發生在Monitors 、 OSD 和 PG上的每一次狀態變更的歷史資訊(稱為 epoch ),
- MDSs: Ceph 元資料服務器( MDS )為 Ceph 檔案系統存盤元資料(也就是說,Ceph 塊設備和 Ceph 物件存盤不使用MDS ),元資料服務器使得 POSIX 檔案系統的用戶們,可以在不對 Ceph 存盤集群造成負擔的前提下,執行諸如 ls、find 等基本命令,
Ceph 把客戶端資料保存為存盤池內的物件,通過使用 CRUSH 演算法, Ceph 可以計算出哪個歸置組(PG)應該持有指定的物件(Object),然后進一步計算出哪個 OSD 守護行程持有該歸置組, CRUSH 演算法使得 Ceph 存盤集群能夠動態地伸縮、再均衡和修復,
環境說明:
服務器
| 節點 | 型別 | ip | CPU | 記憶體 | 硬碟 |
| ceph-deploy | 管理平臺 | 192.168.68.50 | 2 | 4G | /dev/sdb /dev/sdc |
| ceph1 | Monitor osd | 192.168.68.51 | 2 | 4G | /dev/sdb /dev/sdc |
| ceph2 | osd | 192.168.68.52 | 2 | 4G | /dev/sdb /dev/sdc |
| ceph3 | osd | 192.168.68.53 | 2 | 4G | /dev/sdb /dev/sdc |
系統環境
ceph version: 14.2.22 nautilus OS: CentO7.9 內核:5.4.161
升級內核可參考: https://www.cnblogs.com/Sunzz/p/15624582.html
轉載請在文章開頭附上原文鏈接地址:https://www.cnblogs.com/Sunzz/p/15624370.html
環境準備
修改/etc/hosts
每個服務器都要修改192.168.68.50 ceph.local 192.168.68.51 ceph1.local ceph1 192.168.68.52 ceph2.local ceph2 192.168.68.53 ceph3.local ceph3
新增用戶
各ceph節點新增cephuser用戶
useradd cephuser echo "123456" | passwd --stdin cephuser echo "cephuser ALL = (root) NOPASSWD:ALL" > /etc/sudoers.d/cephuser
安裝rpm包
ceph-deploy節點安裝所需的包,root用戶操作yum install ceph-deploy python2-pip.noarch ceph-common -y
部署節點新增用戶
deploy管理節點新增manager用戶
useradd manager echo "123456" | passwd --stdin manager
copy密鑰
在ceph-deploy節點上生成并copy密鑰,做免密登陸su - manager ssh-keygen #一頓回車或者根據自己情況選擇 ssh-copy-id cephuser@192.168.68.51 ssh-copy-id cephuser@192.168.68.52 ssh-copy-id cephuser@192.168.68.53
簡化ssh配置
ceph-deply節點的manger用戶家目錄下, 修改config后deploy節點所建的用戶名登錄Ceph節點無需每次指定 --username cephuser ,簡化了ssh和scp的用法 vim /home/manager/.ssh/configHost ceph1
Hostname ceph1
User cephuser
Host ceph2
Hostname ceph2
User cephuser
Host ceph3
Hostname ceph3
User cephuser
chmod 600 .ssh/config
創建集群
創建作業目錄
mkdir ceph-cluster cd ceph-cluster
創建集群
ceph-deploy new ceph1
或 指定網段,如果有多個網卡,可使用不同的網段
ceph-deploy new --cluster-network 192.168.68.0/24 --public-network 192.168.68.0/24 ceph1

安裝ceph
ceph-deploy install ceph1 ceph2 ceph3 --stable --release nautilus --repo-url=https://mirrors.aliyun.com/ceph/rpm-nautilus/el7/ --gpg-url=https://mirrors.aliyun.com/ceph/keys/release.asc
--stable 指名為穩定版 --release 指定版本 nautilus ,即就是14.2版本 可指定repo為國內源 --repo-url=https://mirrors.aliyun.com/ceph/rpm-nautilus/el7/ --gpg-url=https://mirrors.aliyun.com/ceph/keys/release.asc

初始化monitor
ceph-deploy mon create-initial #初始monitor、并收集所有密鑰

部署MGR
部署mgr
ceph-deploy mgr create ceph1 ceph2 ceph3
復制key
ceph-deploy admin ceph1 ceph2 ceph3給deploy本身也復制一份,需要用root操作,以方便用deploy管理ceph集群
cp /home/manager/ceph-cluster/ceph.client.admin.keyring /etc/ceph/ chmod 644 /etc/ceph/ceph.client.admin.keyring
查看集群狀態
ceph -s
WARN解決
1. Module 'restful' has failed dependency: No module named 'pecan' (這個在centos7上安裝13版本不會出現) yum install python36-devel pip3 install werkzeug pecan systemctl restart ceph-mon.target systemctl restart ceph-mgr.target 2. mon is allowing insecure global_id reclaim 如果有警告,則禁用安全模式 ceph config set mon auth_allow_insecure_global_id_reclaim false 3.OSD count 0 < osd_pool_default_size 3 這個是因為還沒有添加osd,等一會添加后就好了添加OSD
列出磁盤
ceph-deploy disk list ceph1 【ceph2 ceph3】
添加osd
ceph-deploy osd create --data /dev/sdb ceph1 ceph-deploy osd create --data /dev/sdc ceph1 ceph-deploy osd create --data /dev/sdb ceph2 ceph-deploy osd create --data /dev/sdc ceph2 ceph-deploy osd create --data /dev/sdb ceph3 ceph-deploy osd create --data /dev/sdc ceph3

擴展高可用
ceph-deploy mon add ceph2
開啟dashboard
提示:默認情況下,dashboard的所有HTTP連接均使用SSL/TLS進行保護,以上內置命令可快速生成并安裝自簽名證書,各ceph節點安裝dashboard
yum install ceph-mgr-dashboard.noarch -y
啟用dashboard
ceph mgr module enable dashboard ceph dashboard create-self-signed-cert echo admin > pass.txt #設定管理員密碼
ceph dashboard ac-user-create admin -i pass.txt #創建管理員
或者 ceph dashboard set-login-credentials admin -i pass.txt ceph mgr services #確認驗證
或者關閉ssl
ceph mgr module enable dashboard ceph config set mgr mgr/dashboard/ssl false echo admin > pass.txt #創建管理員 ceph dashboard set-login-credentials admin -i pass.txt

阿里云鏡像源
aliyun-base.repo
[base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 enabled=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7base.repo
阿里云epel源
aliyun-epel.repo
[epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=http://mirrors.aliyun.com/epel/7/$basearch failovermethod=priority enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7eple.repo
阿里云ceph源
[ceph-noarch] name=Ceph noarch packages baseurl=https://mirrors.aliyun.com/ceph/rpm-15.2.9/el7/noarch/ #baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/noarch enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://mirrors.aliyun.com/ceph/keys/release.ascceph.repo
總結
octopus ,即就是15.2版本,在centos7上問題比較多,dashboard沒法使用, yum install ceph-mgr-dashboard
缺的這三個報在centos8上有,centos7上沒有,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/373811.html
標籤:其他

