ceph手动部署全流程

该文提供了在Ubuntu22.04服务器上手动部署Ceph集群的详细步骤,包括环境预配置、Mon、Mgr和Osd服务的部署,以及Dashboard的启用和块存储服务的测试。部署涉及多个节点,每个节点的角色包括Mon、Mgr和Osd,并且强调了安全性和配置文件的同步。
摘要由CSDN通过智能技术生成

基础环境信息

CPU: amd64
OS版本:ubuntu22.04.2 server
Ceph版本:Ceph 17.2.5 (基于源码制作的deb,解压源码后,通过make-deb.sh脚本制作即可)

部署目标

进行Ceph 集群典型架构(最小化)手动部署测试。
可对外提供块存储、对象存储、文件存储服务。支持Dashboard管理。

Ceph集群角色

主机名ip地址ceph角色
node110.12.224.92mon,mgr,osd
node210.12.224.34mon,mgr,osd
node310.12.224.93mon,mgr,osd
client10.12.224.44client

手动部署流程

1: 安装依赖,执行ceph源码中的install-debs.sh脚本即可,之后安装ceph debs
2:环境预配置
3:部署mon服务
4:部署mgr服务,并开启dashboard服务
5:部署osd服务
6:块设备服务测试(client执行)

1. 安装依赖(所有节点)

a. 获取源码
https://mirrors.aliyun.com/ceph/tarballs/ceph-17.2.5.tar.gz?spm=a2c6h.25603864.0.0.513869fbZljYok

b. 进行解压
tar -zxvf ceph-17.2.5.tar.gz

c.执行脚本
cd ceph-17.2.5 && ./install-deps.sh

d.安装ceph debs
./install-ceph-debs.sh

2. 环境预配置

a. 切换root权限
sudo -i

b. 修改主机名
hostnamectl set-hostname 主机名

c. 配置hosts文件,所有节点操作
cat > /etc/hosts <<EOF
127.0.0.1 localhost
127.0.1.1 主机名

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

10.12.224.92 node1
10.12.224.34 node2
10.12.224.93 node3
10.12.224.44 client
EOF

d.关闭防火墙
systemctl disable --now firewalld


e. 配置时间同步(enable 暂时不行)
apt-get install ntp
/etc/init.d/ntp restart
systemctl enable ntp.service
systemctl status ntp.service

f. ssh配置
ssh-keygen -t rsa
ssh-copy-id root@node2
ssh-copy-id root@node3
ssh-copy-id root@client

3. 部署mon服务,非明确指定,均在node1执行

a. 生成uuid
uuidgen
> 9bf24809-220b-4910-b384-c1f06ea80728

b. 创建ceph配置文件
cat > /etc/ceph/ceph.conf <<EOF
[global]
fsid = 871a4ca1-60dc-4f7c-97ac-e9398e6dd6a3
mon_initial_members = node1,node2,node3
mon_host = 10.12.224.92,10.12.224.34,10.12.224.93
public_network = 10.12.224.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
EOF

c. 创建集群monitor密钥
ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'

d. 创建client.admin用户密钥,client.bootstrap-osd用户密钥, 并添加到集群密钥中
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 *'
ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring

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-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring


e. 使用主机名,ip,fsid生成monitor map
monmaptool --create --add node1 10.12.224.92 --add node2 10.12.224.34 --add node3 10.12.224.93 --fsid 9bf24809-220b-4910-b384-c1f06ea80728 /tmp/monmap

f. 启动monitor服务
rm -rf /var/lib/ceph/mon/ceph-node1
sudo -u ceph mkdir /var/lib/ceph/mon/ceph-node1
chown ceph.ceph -R /var/lib/ceph /etc/ceph /tmp/ceph.mon.keyring /tmp/monmap
sudo -u ceph ceph-mon --mkfs -i node1 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
ls /var/lib/ceph/mon/ceph-node1/

systemctl restart ceph-mon@node1
systemctl enable ceph-mon@node1
systemctl status ceph-mon@node1

g. 同步配置文件、密钥、monmap到其他节点中
scp /etc/ceph/ceph.client.admin.keyring root@node2:/etc/ceph/
scp /etc/ceph/ceph.client.admin.keyring root@node3:/etc/ceph/

scp /var/lib/ceph/bootstrap-osd/ceph.keyring root@node2:/var/lib/ceph/bootstrap-osd/
scp /var/lib/ceph/bootstrap-osd/ceph.keyring root@node3:/var/lib/ceph/bootstrap-osd/

scp /tmp/ceph.mon.keyring root@node2:/tmp/
scp /tmp/ceph.mon.keyring root@node3:/tmp/
scp /tmp/ceph.mon.keyring root@client:/tmp/

scp /tmp/monmap root@node2:/tmp/
scp /tmp/monmap root@node3:/tmp/

scp /etc/ceph/ceph.conf root@node2:/etc/ceph/
scp /etc/ceph/ceph.conf root@node3:/etc/ceph/

h. 启动node2节点的monitor服务
sudo -i
rm -rf /var/lib/ceph/mon/ceph-node2
sudo -u ceph mkdir /var/lib/ceph/mon/ceph-node2
chown ceph.ceph -R /var/lib/ceph /etc/ceph /tmp/ceph.mon.keyring /tmp/monmap
sudo -u ceph ceph-mon --mkfs -i node2 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
ls /var/lib/ceph/mon/ceph-node2/

systemctl restart ceph-mon@node2
systemctl enable ceph-mon@node2
systemctl status ceph-mon@node2

i. 启动node3节点的monitor服务
sudo -i
rm -rf /var/lib/ceph/mon/ceph-node3
sudo -u ceph mkdir /var/lib/ceph/mon/ceph-node3
chown ceph.ceph -R /var/lib/ceph /etc/ceph /tmp/ceph.mon.keyring /tmp/monmap
sudo -u ceph ceph-mon --mkfs -i node3 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
ls /var/lib/ceph/mon/ceph-node3/

systemctl restart ceph-mon@node3
systemctl enable ceph-mon@node3
systemctl status ceph-mon@node3

j. 查看集群状态 任意节点
	ceph -s

>   cluster:
>     id:     9bf24809-220b-4910-b384-c1f06ea80728
>     health: HEALTH_OK
>   services:
>     mon: 3 daemons, quorum controller2,controller3,controller1 (age 2s)
>     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:


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

4. 部署mgr服务,并开启dashboard服务

a. node1 开启mgr服务
sudo -i
rm -rf /var/lib/ceph/mgr/ceph-node1
mkdir -p /var/lib/ceph/mgr/ceph-node1
chown ceph.ceph -R /var/lib/ceph
ceph-authtool --create-keyring /etc/ceph/ceph.mgr.node1.keyring --gen-key -n mgr.node1 --cap mon 'allow profile mgr' --cap osd 'allow *' --cap mds 'allow *'
ceph auth import -i /etc/ceph/ceph.mgr.node1.keyring
ceph auth get-or-create mgr.node1 -o /var/lib/ceph/mgr/ceph-node1/keyring

systemctl restart ceph-mgr@node1
systemctl enable ceph-mgr@node1
systemctl status ceph-mgr@node1

b. node2 开启mgr服务
sudo -i
rm -rf /var/lib/ceph/mgr/ceph-node2
mkdir -p /var/lib/ceph/mgr/ceph-node2
chown ceph.ceph -R /var/lib/ceph
ceph-authtool --create-keyring /etc/ceph/ceph.mgr.node2.keyring --gen-key -n mgr.node2 --cap mon 'allow profile mgr' --cap osd 'allow *' --cap mds 'allow *'
ceph auth import -i /etc/ceph/ceph.mgr.node2.keyring
ceph auth get-or-create mgr.node2 -o /var/lib/ceph/mgr/ceph-node2/keyring

systemctl restart ceph-mgr@node2
systemctl enable ceph-mgr@node2
systemctl status ceph-mgr@node2

c. node3 开启mgr服务
sudo -i
rm -rf /var/lib/ceph/mgr/ceph-node3
mkdir -p /var/lib/ceph/mgr/ceph-node3
chown ceph.ceph -R /var/lib/ceph
ceph-authtool --create-keyring /etc/ceph/ceph.mgr.node3.keyring --gen-key -n mgr.node3 --cap mon 'allow profile mgr' --cap osd 'allow *' --cap mds 'allow *'
ceph auth import -i /etc/ceph/ceph.mgr.node3.keyring
ceph auth get-or-create mgr.node3 -o /var/lib/ceph/mgr/ceph-node3/keyring

systemctl restart ceph-mgr@node3
systemctl enable ceph-mgr@node3
systemctl status ceph-mgr@node3

d.使能dashboard服务,任意节点执行
sudo -i
ceph mgr module disable dashboard
ceph mgr module enable dashboard
ceph dashboard create-self-signed-cert
ceph config set mgr mgr/dashboard/server_addr 10.12.224.34
ceph config set mgr mgr/dashboard/server_port 8080
ceph config set mgr mgr/dashboard/ssl_server_port 8443

echo '88888888' > /tmp/password.txt
ceph dashboard ac-user-create admin  administrator -i /tmp/password.txt

e. 通过dashboard访问cluster,用户名密码为admin/88888888
https://10.12.224.92:8443

5. 部署osd服务

a. 所有节点进行硬盘设置
ceph-volume lvm create --data /dev/sda

6. 块设备服务测试(client执行)

a. 拷贝服务器端的配置文件及密钥
scp root@node1:/etc/ceph/ceph.conf /etc/ceph/
scp root@node1:/etc/ceph/ceph.client.admin.keyring /etc/ceph/

b. 测试连接状态
ceph -s
> cluster:
> 		id:     cf3862c5-f8f6-423e-a03e-beb40fecb74a
> 		health: HEALTH_OK
>
> services:
> 		mon: 	3 daemons, quorum ceph03,ceph02,ceph01 (age 12d)
> 		mgr:	ceph01(active, since 3w), standbys: ceph02、ceph03
> 		osd:    9 osds: 9 up (since 89s), 9 in (since 89s)
>
> data:
> 	 	pools:   0 pools, 0 pgs
> 		objects: 0 objects, 0 B
> 		usage:   9.0 GiB used, 16 TiB / 16 TiB avail
> 		pgs:


c. 创建块设备池
ceph osd pool create test-pool 128
ceph osd pool application enable test-pool rbd
ceph osd lspools

d. 创建块设备镜像
rbd create --size 1T disk01 --pool test-pool
rbd ls test-pool -l
rbd info test-pool/disk01

e. 修改块设备镜像能力
rbd feature disable test-pool/disk01 exclusive-lock, object-map, fast-diff, deep-flatten

f. 映射块设备
rbd map test-pool/disk01
mkfs.xfs /dev/rbd0
rbd showmapped

g. 挂载并使用块设备
mkdir /home/loongson/ceph_disk01
mount /dev/rbd0 /home/loongson/ceph_disk01
cd /home/loongson/ceph_disk01


df -Th 可以查询容量
dd if=/dev/zero of=/home/loongson/ceph_disk01/rbd-test-file bs=1M count=10
注意事项1

添加osd设备前使用脚本进行预处理,脚本内容如下:

#!/bin/bash
DISK="/dev/sda"

# Zap the disk to a fresh, usable state (zap-all is important, b/c MBR has to be clean)
sgdisk --zap-all $DISK

# Wipe a large portion of the beginning of the disk to remove more LVM metadata that may be present
dd if=/dev/zero of="$DISK" bs=1M count=100 oflag=direct,dsync

# SSDs may be better cleaned with blkdiscard instead of dd
blkdiscard $DISK

# Inform the OS of partition table changes
partprobe $DISK
注意事项2
查看端口是否占用
lsof -i:port

可以删除对应的pid
kill -9 pid

如果是8443占用
可以使用以下命令进行解除占用
ceph mgr module disable dashboard
注意事项3
在scp,create过程中遇见失败,可以先删除对应的文件,然后进行操作
注意事项4
在做service相关操作时,可以使用systemctl disable servername + table一下查看之前的服务,判断某些服务上是否需要关闭
注意事项5
ssh root 输入正确密码也无法连接的处理办法

vim /etc/ssh/sshd_config
将PasswordAuthentication和PermitRootLogin的注释去掉(删除#),并且将值改为yes。

重启sshd 服务
systemctl restart sshd
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值