CEPH 13.2

CEPH簡介

ceph提供:對象存儲,塊設備,文件系統。

Ceph存儲集羣至少需要一個Ceph Monitor,Ceph Manager和Ceph OSD(對象存儲守護進程)。運行Ceph Filesystem客戶端時也需要Ceph元數據服務器。

  • Monitors :ceph-mon 維護集羣狀態的映射管理守護進程和客戶端之間的身份驗證,高可用至少需要3個Monitors 節點

  • Managers:ceph-mgr Ceph集羣的當前狀態高可用性通常至少2Managers節點

  • Ceph OSDs:ceph-osd 存儲數據,處理數據複製,恢復,重新平衡,並通過檢查其他Ceph OSD守護進程來獲取心跳,爲Ceph監視器和管理器提供一些監視信息。冗餘和高可用性通常至少需要3個Ceph OSD。

  • MDSs :ceph-mds 文件系統存儲原數據服,Ceph塊設備和Ceph對象存儲不使用MDS


手動部署

ceph版本 minic 13.2

主機名ip地址系統版本ceph版本節點
node01172.16.50.104CentOS Linux release 7.4.1708 (Core) minic 13.2mon,osd
node02172.16.50.111CentOS Linux release 7.4.1708 (Core) minic 13.2osd
node03172.16.50.131CentOS Linux release 7.4.1708 (Core) minic 13.2osd


系統初始化

  1. 關閉selinux

  2. 啓用epel源:yum install epel-releas

  3. 添加ceph源:/etc/yum.repos.d/ceph.repo 內容如下:


[Ceph]
name=Ceph packages for $basearch
baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1

[Ceph-noarch]
name=Ceph noarch packages
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.asc
priority=1

[ceph-source]
name=Ceph source packages
baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/SRPMS
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1

安裝ceph

yum install ceph ceph-radosgw -y

Mon節點部署

創建配置文件:/etc/ceph/ceph.conf

[global]
fsid = a7f64266-0894-4f1e-a635-d0aeaca0e993
mon initial members = node01
mon host = 172.16.50.104
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd journal size = 1024
osd pool default size = 2
osd pool default min size = 1
osd crush chooseleaf type = 1
[mon]
mon data = /data/ceph/mon/$cluster-$id


爲羣集創建密鑰環,並生成監視器密鑰。

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

生成管理員密鑰;生成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 *' --cap mgr 'allow *'

生成一個bootstrap-osd密鑰環,生成client.bootstrap-osd用戶,並將用戶添加到密鑰環。

ceph-authtool --create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd'

將生成的密鑰添加到ceph.mon.keyring環中

ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring  
ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring  

使用主機名、主機IP地址和FSID生成監視器映射,保存到/tmp/monmap

uuid=a7f64266-0894-4f1e-a635-d0aeaca0e993  
name=node01  
ip=172.16.50.104  

monmaptool --create --add $name $ip --fsid $uuid /tmp/monmap  

在mon主機上創建默認數據目錄

mkdir /data/ceph/mon -p

初始化mon

ceph-mon --mkfs -i $name --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring


touch /data/ceph/mon/ceph-$name/done    
chown ceph:ceph /data/ceph/ -R  
systemctl enable ceph-mon@$name  
systemctl start ceph-mon@$name  

驗證monitor運作

ceph -s  
  cluster:  
    id:     ef88b5bc-3eba-495b-a00c-9851c465bc2b  
    health: HEALTH_OK  
   
  services:  
    mon: 1 daemons, quorum node01  
    mgr: no daemons active  
    osd: 0 osds: 0 up, 0 in  
 
  data:  
    pools:   0 pools, 0 pgs  
    objects: 0  objects, 0 B  
    usage:   0 B used, 0 B / 0 B avail  
    pgs:

在運行ceph-mon守護程序的每個節點上,還應該設置ceph-mgr守護程序。

ceph-mgr部署

創建身份認證密鑰

ceph auth get-or-create mgr.node01 mon 'allow profile mgr' osd 'allow *' mds 'allow *'

將輸出保存到 /var/lib/ceph/mgr/ceph-node01/keyring 文件中

啓動

systemctl enable ceph-mgr@node01  
systemctl start  ceph-mgr@node01  

驗證mgr:

ceph -s 
.....   
services:      
  mgr: node01(active)      
......

添加osd以node02爲列

將配置文件/var/lib/ceph/bootstrap-osd/ceph.keyring/etc/ceph/ceph.conf 拷貝到需要安裝osd服務器

scp /var/lib/ceph/bootstrap-osd/ceph.keyring  root@node02:/var/lib/ceph/bootstrap-osd/ceph.keyring
scp /etc/ceph/ceph.conf root@node02:/etc/ceph
ssh node02   
UUID=$(uuidgen)  
OSD_SECRET=$(ceph-authtool --gen-print-key)   
ID=$(echo "{\"cephx_secret\": \"$OSD_SECRET\"}" | ceph osd new $UUID -i - -n client.bootstrap-osd -k /var/lib/ceph/bootstrap-osd/ceph.keyring)  
     
mkdir /data/ceph/osd -p && ln -s /data/ceph/osd/ /var/lib/ceph/osd/ceph-$ID  
  
ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-$ID/keyring --name osd.$ID --add-key $OSD_SECRET  
ceph-osd -i $ID --mkfs --osd-uuid $UUID  
chown ceph:ceph /var/lib/ceph/osd/ceph-$ID -R  
systemctl enable ceph-osd@$ID  
systemctl start ceph-osd@$ID

在查看集羣狀態

  cluster:    
    id:     a7f64266-0894-4f1e-a635-d0aeaca0e993    
    health: HEALTH_OK   

  services:  
    mon: 1 daemons, quorum node01   
    mgr: node01(active)  
    osd: 3 osds: 3 up, 3 in  

  data:  
    pools:   1 pools, 8 pgs   
    objects: 5  objects, 389 B
    usage:   3.3 GiB used, 297 GiB / 300 GiB avail
    pgs:     8 active+clean


至此可以使用對象存儲,及塊設備(生產不建議這樣使用至少需要3個mon節點,2個mgr節點)

dashboard 部署
它是基於mgr python的插件

啓用dashboard插件

ceph mgr module enable dashboard

生成自簽名證書

ceph dashboard create-self-signed-cert

配置dashboard監聽

ceph config set mgr mgr/dashboard/node01/server_addr 172.16.50.104  
ceph config set mgr mgr/dashboard/node01/server_port 1888  

配置dashboard認證

ceph dashboard set-login-credentials root 123456

訪問:https://172.16.50.104:1888





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章