ceph-ansible(采用Cockpit部署方式)

676 阅读2分钟

一起养成写作习惯!这是我参与「掘金日新计划 · 4 月更文挑战」的第6天,点击查看活动详情

1.基本环境(测试)

  • 每个节点安装两个网卡
  • 每个节点安装ansible-2.9
  • 配置好hosts和免密
主机名IPCPU内存磁盘角色
installer.ceph.com172.168.105.4033GB30GBceph客户端
mon1.ceph.com172.168.105.4133GB30GBMON
mon2.ceph.com172.168.105.4233GB30GBMON
mon3-ceph.com172.168.105.4333GB30GBMON
osd1.ceph.com172.168.105.4433GB30/20/10GBOSD
osd2.ceph.com172.168.105.4533GB30/20/10GBOSD
osd3.ceph.com172.168.105.4633GB30/20/10GBOSD
metrics.ceph.com172.168.105.4733GB30GBMetrics
rgw-mds.ceph.com172.168.105.4833GB30GBRGW/MDS

2.克隆基本环境(installer上操作)

克隆ceph-ansible稳定分支,这里使用稳定版4.0.

yum install -y docker cockpit git epel-release
systemctl enable docker.service
systemctl start docker.service
cd /usr/share
git clone --branch stable-4.0 https://github.com/ceph/ceph-ansible.git
cd ceph-ansible
cp site.yml.sample site.yml
cp site-container.yml.sample site-container.yml
​
cd ~
sudo git clone https://github.com/red-hat-storage/cockpit-ceph-installer.git
cd cockpit-ceph-installer
ln -snf ~/cockpit-ceph-installer/dist /usr/share/cockpit/cockpit-ceph-installer
systemctl restart cockpit.socket
cp utils/ansible/checkrole.yml /usr/share/ceph-ansible
cp utils/ansible/library/ceph_check_role.py /usr/share/ceph-ansible/library/

3.安装前检查

执行以下命令,执行安装服务。

cd utils/
./ansible-runner-service.sh -s -v

img

检查ansible-runner服务是否正常启动:

docker ps 

img

检查Cockpit是否正常启动:

systemctl start cockpit
systemctl status cockpit

img

4.安装

打开installer.ceph.com:9090,也可以用ip地址来代替。

image-20220402155403797

用户名和密码为操作系统的账户密码,输入后登录。在左侧可以看到Ceph Installer的页面。

image-20220406130109065

参考图中的配置。

img

#如果出现结果不是ok,注意使用以下命令传递公钥
#
for i in mon1 mon2 mon3 osd1 osd2 osd3 metrics rgw-mds
do 
ssh-copy-id -f -i /usr/share/ansible-runner-service/env/ssh_key.pub $i  
done

依次加入节点,确保所有的节点状态都是OK。

img

image-20220406135300192

点击Probe Hosts探测机器,需要多等待一会使用结果出来(如何仍不出结果,可以重启docker),我这里使用虚拟机,配置较低,忽略配置较低警告。

image-20220406142822464

点击deploy,系统开始调用playbook自动安装所需组件。

image-20220406154256056

安装报错,如果是ansible的版本问题,需要升级:

docker exec -it runner-service bash

image-20220406160539332

img

cd /usr/share/ceph-ansible/
pip3 install -r requirements.txt --default-timeout=3000
​
## 备用
#pip3 install ansible==2.9 -i https://mirrors.aliyun.com/pypi/simple/

image-20220406162454271

在网页上执行Retry后,程序将继续进行安装,耐心等待安装。

image-20220406164812537

注意网页上的提示,有登录的账号的密码,记下备用。

image-20220406164902783

5.客户端访问

在客户端机器上操作:

yum -y install centos-release-ceph-nautilus.noarch
yum -y install ceph-common
scp mon1:/etc/ceph/ceph.conf /etc/ceph
scp mon1:/etc/ceph/ceph.client.admin.keyring /etc/ceph
ceph -s

image-20220406165407779

ceph config set mon auth_allow_insecure_global_id_reclaim false

image-20220406165428590

5.网页访问

我这里直接使用ip地址访问mon1,注意要使用https,用户名admin,密码为之前预设的密码。

image-20220406165644132

点击登录,可以看到ceph的运行状态。

image-20220406170129347

使用metrics:3000端口,可访问grafana,查看集群的各项目指标。

image-20220406170307500

image-20220406170351487

使用metrics:9092端口,可访问prometheus,查看集群的监控指标。

image-20220406170456435

\