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版本 节点
node01 172.16.50.104 CentOS Linux release 7.4.1708 (Core)  minic 13.2 mon,osd
node02 172.16.50.111 CentOS Linux release 7.4.1708 (Core)  minic 13.2 osd
node03 172.16.50.131 CentOS Linux release 7.4.1708 (Core)  minic 13.2 osd


系统初始化

  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





猜你喜欢

转载自blog.51cto.com/11889458/2139175
今日推荐