手動搭建ceph集群


手動部署ceph過程

  • 環境:CentOS7 1611
  • 節點數:1mon,1osd

以下步驟均在root用戶下進行


更改主機名

nmtui

重啟終端

hostnamectl

修改hosts文件

172.30.143.3  cephmon
172.30.46.6   cephn1

獲取軟件

1)刪除默認的源,國外的比較慢

# yum clean all
# rm -rf /etc/yum.repos.d/*.repo

2)下載阿里雲的Base源

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3)下載阿里雲的epel源

# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

4)修改里面的系統版本為7.3.1611,當前用的CentOS的版本的yum源可能已經清空了

# sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo
# sed -i '/aliyuncs/d' /etc/yum.repos.d/epel.repo
# sed -i 's/$releasever/7.3.1611/g' /etc/yum.repos.d/CentOS-Base.repo

5)添加ceph源

vim /etc/yum.repos.d/ceph.repo
[ceph]
name=ceph
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/x86_64/
gpgcheck=0
[ceph-noarch]
name=cephnoarch
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/noarch/
gpgcheck=0

6)進行yum的makecache

yum makecache

7)安裝軟件

yum install ceph

關閉防火牆和SELinux

1)關閉防火牆

# systemctl stop firewalld.service

2)關閉自啟

# systemctl disable firewalld.service

3)打開配置文件/etc/sysconf/selinux

# vim /etc/sysconfig/selinux

4)修改

# SELINUX=enforcing改為disabled

5)保存然后退出

# setenforce 0

6)查看selinux狀態

# getenforce

Mon節點免密登錄OSD

# ssh-keygen
# ssh-copy-id ceph-n1
# ssh-copy-id ceph-mon

配置mon,參考官方文檔

1)確保保存Ceph配置文件的目錄存在,Ceph默認使用/etc/ceph。安裝ceph軟件時,安裝器也會自動創建/etc/ceph目錄。

2)創建Ceph配置文件,ceph默認使用ceph.conf

# vim /etc/ceph/ceph.conf

3)給集群分配唯一ID(fsid)

# uuidgen

4)把此ID寫入Ceph配置文件

# fsid = 7ada51e0-819e-437d-8567-88d72af64847

5)把初始監視器寫入ceph配置文件

# mon initial members = cephmon

6)把初始監視器的IP地址寫入ceph配置文件,並保存。

# mon host = 192.168.1.55

7)為此集群創建密鑰環,並生成監視器密鑰。

# ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'

8)生成管理員密鑰環,生成client.admin用戶並加入密鑰環。

# ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'

9)把alient.admin密鑰加入ceph.mon.keyring。

# ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring

10)用規划好的主機名,對應IP地址,和FSID生成一個監視器圖,並保存為/tmp/monmap。

# monmaptool --create --add ceph-mon 192.168.1.55 --fsid 7ada51e0-819e-437d-8567-88d72af64847 /tmp/monmap

11)在監視器主機上分別創建數據目錄。

# mkdir /var/lib/ceph/mon/ceph-cephmon

12)用監視器圖和密鑰環組裝守護進程所需的初始數據。

# ceph-mon --mkfs -i ceph-mon --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring

13)ceph公共配置文件如下

fsid = 7ada51e0-819e-437d-8567-88d72af64847
mon initial members = cephmon
mon host = 192.168.1.55
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd pool default size = 1

14)創建一個空文件done,表示監視器已經創建、可以啟動了:

# touch /var/lib/ceph/mon/ceph-mon/done

15)啟動監視器

# ceph-mon --id ceph-mon

手動配置OSD(精簡型)

1)准備OSD

# ssh {node-name}
# sudo ceph-disk prepare --cluster {cluster-name} --cluster-uuid {uuid} --fs-type {ext4|xfs|btrfs} {data-path} [{journal-path}]

例如

# ssh cephn1
# sudo ceph-disk prepare --cluster ceph --cluster-uuid a7f64266-0894-4f1e-a635-d0aeaca0e993 --fs-type ext4 /dev/hdd1

2)激活OSD

# ceph-disk activate {data-path} [--activate-key {path}]

例如

# ceph-disk activate /dev/hdd1

注意:如果啟動失敗可以選擇該啟動命令

# ceph-osd --id 0

---恢復內容結束---


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM