| 主机名 | IP地址 | Ceph角色 |
|---|---|---|
| ceph01 | 10.40.64.191 | mon×1、mgr×1、osd×3 |
配置主机名称
hostnamectl set-hostname ceph01
bash
关闭防火墙和selinux
systemctl disable --now firewalld
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
配置时间同步
yum install -y chrony
sed -i '/^pool/d' /etc/chrony.conf
sed -i '/^server/d' /etc/chrony.conf
echo "pool ntp.aliyun.com iburst" >> /etc/chrony.conf
systemctl restart chronyd.service && systemctl enable chronyd.service
timedatectl status
chronyc sources
安装Ceph源N版
yum install -y loongnix-release-ceph-nautilus
安装ceph-mon服务程序
yum install -y ceph-mon
初始化mon服务
生成uuid
uuidgen
468e23e9-c98d-48f2-9432-9b17774613c7
创建Ceph集群配置文件
vim /etc/ceph/ceph.conf
fsid = 468e23e9-c98d-48f2-9432-9b17774613c7
mon_initial_members = ceph01
mon_host = 10.40.64.191
public_network = 10.40.64.0/24
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
osd_journal_size = 1024
osd_pool_default_size = 3
osd_pool_default_min_size = 2
osd_pool_default_pg_num = 64
osd_pool_default_pgp_num = 64
osd_crush_chooseleaf_type = 1
fsid: 文件系统ID,用于标识Ceph集群中的特定文件系统。mon_initial_members: 监控器(Mon)服务的初始成员列表,这里只有一个成员"ceph01"。mon_host: 监控器(Mon)服务所在的主机地址。public_network: 公共网络地址范围,用于定义Ceph集群与外部网络的通信范围。auth_cluster_required: 认证集群所需的最小OSD数量。auth_service_required: 认证服务所需的最小OSD数量。auth_client_required: 认证客户端所需的最小OSD数量。osd_journal_size: OSD日志的大小,以MB为单位。osd_pool_default_size: 默认的OSD池大小,以OSD数量为单位。osd_pool_default_min_size: 默认的OSD池最小大小,以OSD数量为单位。osd_pool_default_pg_num: 默认的PG数量,用于副本集中的CRUSH映射。osd_pool_default_pgp_num: 默认的PG优先级数量,用于副本集中的CRUSH映射。osd_crush_chooseleaf_type: 在CRUSH算法中选择叶子节点的类型。创建集群Monitor密钥
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 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'
创建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' --cap mgr 'allow r'
将生成的密钥添加到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生成监视器映射monitor map。
monmaptool --create --add ceph01 10.40.64.191 --fsid 468e23e9-c98d-48f2-9432-9b17774613c7 /tmp/monmap
在监视主机上创建默认数据目录。
sudo -u ceph mkdir /var/lib/ceph/mon/ceph-ceph01
使用监视器映射monitor map和keyring填充监视器守护进程。
chown ceph.ceph -R /var/lib/ceph /etc/ceph /tmp/ceph.mon.keyring /tmp/monmap
sudo -u ceph ceph-mon --mkfs -i ceph01 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
ls /var/lib/ceph/mon/ceph-ceph01/
启动monitor服务
systemctl start ceph-mon@ceph01
systemctl enable ceph-mon@ceph01
systemctl status ceph-mon@ceph01
查看当前集群状态
[root@ceph01 ceph]# ceph -s
HEALTH_WARN警报信息清除
出现警告:mons are allowing insecure global_id reclaim。
解决办法:ceph config set mon auth_allow_insecure_global_id_reclaim false
出现警告:monitors have not enabled msgr2
解决办法:ceph mon enable-msgr2
安装ceph-osd服务程序
yum install -y ceph-osd
初始化osd服务
通过fdisk等工具查看磁盘盘符,然后利用ceph-volume工具自动化创建osd服务。
ceph-volume lvm create: error: GPT headers found, they must be removed on: /dev/sda
sgdisk --zap-all /dev/sda
ceph-volume lvm create --data /dev/sda
ceph-volume lvm create --data /dev/sdb
ceph-volume lvm create --data /dev/sdc
查看当前集群状态
通过ceph osd tree命令查询集群状态,可见集群services中所有osd服务已启动。
ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 43.65807 root default
-3 43.65807 host ceph01
0 hdd 14.55269 osd.0 up 1.00000 1.00000
1 hdd 14.55269 osd.1 up 1.00000 1.00000
2 hdd 14.55269 osd.2 up 1.00000 1.00000
安装ceph-mgr服务程序
yum install -y ceph-mgr
初始化并启动主mgr服务
mkdir -p /var/lib/ceph/mgr/ceph-ceph01
chown ceph.ceph -R /var/lib/ceph
ceph-authtool --create-keyring /etc/ceph/ceph.mgr.ceph01.keyring --gen-key -n mgr.ceph01 --cap mon 'allow profile mgr' --cap osd 'allow *' --cap mds 'allow *'
ceph auth import -i /etc/ceph/ceph.mgr.ceph01.keyring
ceph auth get-or-create mgr.ceph01 -o /var/lib/ceph/mgr/ceph-ceph01/keyring
systemctl start ceph-mgr@ceph01
systemctl enable ceph-mgr@ceph01
systemctl status ceph-mgr@ceph01
查看当前集群状态
[root@ceph01 ceph]# ceph -s
cluster:
id: 468e23e9-c98d-48f2-9432-9b17774613c7
health: HEALTH_OK
services:
mon: 1 daemons, quorum ceph01 (age 2h)
mgr: ceph01(active, since 112m)
osd: 3 osds: 3 up (since 3h), 3 in (since 3h)
data:
pools: 0 pools, 0 pgs
objects: 0 objects, 0 B
usage: 3.0 GiB used, 44 TiB / 44 TiB avail
pgs:
使能Dashboard访问功能
开启mgr dashboard功能
ceph mgr module enable dashboard
生成并安装自签名的证书
ceph dashboard create-self-signed-cert
配置dashboard
ceph config set mgr mgr/dashboard/server_addr 10.40.64.191
ceph config set mgr mgr/dashboard/server_port 8080
ceph config set mgr mgr/dashboard/ssl_server_port 8443
创建一个dashboard登录用户名密码
echo '123456' > password.txt
ceph dashboard ac-user-create admin administrator -i password.txt
通过Web访问Ceph Dashboard,用户名密码为admin/123456
https://10.40.64.191:8443