下面的过程说明了手动安装 Ceph 存储集群时需要使用的命令。
为要运行的 Ceph 服务生成密钥机密。可以使用下面的命令生成密钥机密:
python -c "import os ; import struct ; import time; import base64 ; \ key = os.urandom(16) ; header = struct.pack('<hiih',1,int(time.time()),0,len(key)) ; \ print base64.b64encode(header + key)"
将密钥添加到相关的密钥环。添加顺序依次为 client.admin
、监视器、其他相关服务(例如 OSD、对象网关或 MDS):
ceph-authtool -n client.admin \ --create-keyring /etc/ceph/ceph.client.admin.keyring \ --cap mds 'allow *' --cap mon 'allow *' --cap osd 'allow *' ceph-authtool -n mon. \ --create-keyring /var/lib/ceph/bootstrap-mon/ceph-osceph-03.keyring \ --set-uid=0 --cap mon 'allow *' ceph-authtool -n client.bootstrap-osd \ --create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring \ --cap mon 'allow profile bootstrap-osd' ceph-authtool -n client.bootstrap-rgw \ --create-keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring \ --cap mon 'allow profile bootstrap-rgw' ceph-authtool -n client.bootstrap-mds \ --create-keyring /var/lib/ceph/bootstrap-mds/ceph.keyring \ --cap mon 'allow profile bootstrap-mds'
创建 monmap,这是集群中所有监视器的数据库:
monmaptool --create --fsid eaac9695-4265-4ca8-ac2a-f3a479c559b1 \ /tmp/tmpuuhxm3/monmap monmaptool --add osceph-02 192.168.43.60 /tmp/tmpuuhxm3/monmap monmaptool --add osceph-03 192.168.43.96 /tmp/tmpuuhxm3/monmap monmaptool --add osceph-04 192.168.43.80 /tmp/tmpuuhxm3/monmap
在该数据库中创建新的密钥环,并从管理员和监视器的密钥环导入密钥。然后使用密钥环来启动监视器:
ceph-authtool --create-keyring /tmp/tmpuuhxm3/keyring \ --import-keyring /var/lib/ceph/bootstrap-mon/ceph-osceph-03.keyring ceph-authtool /tmp/tmpuuhxm3/keyring \ --import-keyring /etc/ceph/ceph.client.admin.keyring sudo -u ceph ceph-mon --mkfs -i osceph-03 \ --monmap /tmp/tmpuuhxm3/monmap --keyring /tmp/tmpuuhxm3/keyring systemctl restart ceph-mon@osceph-03
在 systemd
中检查监视器状态:
systemctl show --property ActiveState ceph-mon@osceph-03
检查 Ceph 是否正在运行并报告监视器状态:
ceph --cluster=ceph \ --admin-daemon /var/run/ceph/ceph-mon.osceph-03.asok mon_status
使用现有密钥检查特定服务的状态:
ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin -f json-pretty status [...] ceph --connect-timeout 5 \ --keyring /var/lib/ceph/bootstrap-mon/ceph-osceph-03.keyring \ --name mon. -f json-pretty status
从现有 Ceph 服务中导入密钥环并检查状态:
ceph auth import -i /var/lib/ceph/bootstrap-osd/ceph.keyring ceph auth import -i /var/lib/ceph/bootstrap-rgw/ceph.keyring ceph auth import -i /var/lib/ceph/bootstrap-mds/ceph.keyring ceph --cluster=ceph \ --admin-daemon /var/run/ceph/ceph-mon.osceph-03.asok mon_status ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin -f json-pretty status
使用 XFS 文件系统为 OSD 准备磁盘/分区:
ceph-disk -v prepare --fs-type xfs --data-dev --cluster ceph \ --cluster-uuid eaac9695-4265-4ca8-ac2a-f3a479c559b1 /dev/vdb ceph-disk -v prepare --fs-type xfs --data-dev --cluster ceph \ --cluster-uuid eaac9695-4265-4ca8-ac2a-f3a479c559b1 /dev/vdc [...]
激活分区:
ceph-disk -v activate --mark-init systemd --mount /dev/vdb1 ceph-disk -v activate --mark-init systemd --mount /dev/vdc1
如果 SUSE Enterprise Storage 为 2.1 或更低版本,请创建默认存储池:
ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .users.swift 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .intent-log 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .rgw.gc 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .users.uid 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .rgw.control 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .users 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .usage 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .log 16 16 ceph --connect-timeout 5 --keyring /etc/ceph/ceph.client.admin.keyring \ --name client.admin osd pool create .rgw 16 16
根据引导密钥创建对象网关实例密钥:
ceph --connect-timeout 5 --cluster ceph --name client.bootstrap-rgw \ --keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring auth get-or-create \ client.rgw.0dc1e13033d2467eace46270f0048b39 osd 'allow rwx' mon 'allow rw' \ -o /var/lib/ceph/radosgw/ceph-rgw.rgw_name/keyring
启用并启动对象网关:
systemctl enable ceph-radosgw@rgw.rgw_name systemctl start ceph-radosgw@rgw.rgw_name
(可选)根据引导密钥创建 MDS 实例密钥,然后启用并启动它:
ceph --connect-timeout 5 --cluster ceph --name client.bootstrap-mds \ --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring auth get-or-create \ mds.mds.rgw_name osd 'allow rwx' mds allow mon \ 'allow profile mds' \ -o /var/lib/ceph/mds/ceph-mds.rgw_name/keyring systemctl enable ceph-mds@mds.rgw_name systemctl start ceph-mds@mds.rgw_name