Ansible部署RHCS存储集群详解
Ansible部署RHCS存储集群详解
一 前期准备
1.1 前置条件
- 至少有三个不同的主机运行monitor (MON)节点;
- 至少三个直接存储(非外部SAN硬件)的OSD节点主;
- 至少两个不同的manager (MGR)节点;
- 如果使用CephFS,则至少有两个完全相同配置的MDS节点;
- 如果使用Ceph对象网关,则至少有两个不同的RADOSGW节点。
- 一个部署节点,可以使用ceph-ansible包中的Ansible剧本来部署和配置集群。
1.2 准备工作
- 具备相同操作系统的集群节点,建议RHEL7;
- 配置软件仓库(CentOS epel源、Ubuntu apt源、RedHat使用subscription-manager命令注册系统);
- 所有节点配置网络及NTP时间同步;
- 关闭selinux与防火墙,或放通所有相关流量和端口;
- 在部署节点安装ansbile;
- 添加hosts,并确保能正确解析到所有主机;
- 配置部署节点使用Ansible任务的用户到其他所有节点可以ssh免密登录;
- 验证部署节点能够在集群节点上能正常运行ansible任务。
1.3 其他注意事项
- OSD磁盘不建议使用RAID,Ceph使用复制或纠删码来保护数据
- 在生产环境部署Ceph集群,为便于管理,OSD主机应尽量使用统一的硬件。尽可能配置数量、大小和名称都相同的磁盘,有助于确保性能一致,并且简化故障排除;
- 需要确认每个OSD主机提供的OSD的数量。密度较小的存储集群意味着osd守护进程分布到更多的主机上,分发工作负载。密度较高的存储意味着重平衡和数据恢复需要更高的流量
附一:组件端口说明
Monitor 6789/TCP:Communication within the Ceph cluster Manager 7000/TCP:Communication with the Ceph Manager dashboard 8003/TCP:Communication with the Ceph Manager RESTful API via HTTPS 9283/TCP:Communication with the Ceph Manager Prometheus plug-in OSD 6800-7300/TCP:Each OSD uses three ports in this range: one for communicating with clients and monitors over the public network; one for sending data to other OSDs over a cluster network,or over the public network if the former does not exist; and another for exchanging heartbeat packets over a cluster network or over the public network if the former does not exists. RADOS Gateway 7480/TCP:RADOS Gateway uses port 7480/TCP,but you can change it, for example to port 80/TCP,or to port 443/TCP if using the SSL/TLS service.二 部署相关知识点
2.1 Ansible介绍
略,具体Ansible操作见本博客Ansible文章。2.2 Ansible部署Ceph相关yml
/usr/share/ceph-ansible/group_vars/all.yml:所有节点相关yml配置; /usr/share/ceph-ansible/group_vars/osds.yml:所有OSD节点的yml配置; /usr/share/ceph-ansible/group_vars/client.yml:客户端节点的yml配置。 /usr/share/ceph-ansible:运行Ansible部署的主目录。2.3 yml主要相关参数
- all.yml参数
- osds.ym
2.4 客户端相关命令
2.5 对象object相关命令
三 正式部署
3.1 部署节点配置主机名
[root@servera ~]# vi /etc/hosts 172.25.250.10 servera 172.25.250.12 serverc 172.25.250.13 serverd 172.25.250.14 servere提示:主机名应该能正确解析主机名,若管理节点同时也是一个Ceph节点,也要确认能正确解析自己的主机名和IP地址。本实验环境此3.1步骤可省略。
3.2 创建相关用户
[root@servera ~]# useradd student
[root@servera ~]# echo student | passwd --stdin student #创建非root的管理用户
[root@servera ~]# for i in {a..e}; do echo "====server${i}====";ssh root@server${i} 'useradd -d /home/student -m student; echo "student" | passwd --stdin student'; done #所有OSD server节点创建student用户
[root@servera ~]# for i in {a..e}; do echo "====server${i}====";ssh root@server${i} 'useradd -d /home/ceph -m ceph; echo "redhat" | passwd --stdin ceph'; done
[root@servera ~]# for i in {a..e}; do echo "====server${i}====";ssh root@server${i} 'echo "student ALL = (root) NOPASSWD:ALL" > /etc/sudoers'; done
[root@servera ~]# for i in {a..e}; do echo "====server${i}====";ssh root@server${i} 'chmod 0440 /etc/sudoers'; done
3.3 配置部署节点免密钥
[root@servera ~]# su - student [student@servera ~]$ ssh-keygen -f ~/.ssh/id_rsa -N '' [student@servera ~]$ for i in {a..e}; do echo "====server${i}====";ssh-copy-id student@server$i;ssh-copy-id ceph@server$i; done
3.4 配置Ansible Inventory
[student@servera ~]$ sudo vi /usr/share/ceph-ansible/ansible.cfg log_path = /tmp/ansible.log #修改日志路径为student用户可写入的/tmp路径 deprecation_warnings = False #禁用在ansible-playbook输出结果相关必须要警告提示:Ansible默认使用/etc/ansible/hosts作为Inventory文件,也可使用-f参数手动指定其他文件。
[student@servera ~]$ sudo vi /etc/ansible/hosts
[mons]
server[c:e]
[mgrs]
server[c:e]
[student@servera ~]$ ansible mons -m ping #测试mons组节点通信
[student@servera ~]$ ansible mgrs -m ping #测试mgrs组节点通信
[student@servera ~]$ ansible mons -m command -a id #通过命令测试mons组节点
[student@servera ~]$ ansible mgrs -m command -a id #通过命令测试mgrs组节点
3.5 创建site.yml
[student@servera ~]$ cd /usr/share/ceph-ansible/
[student@servera ceph-ansible]$ sudo cp site.yml.sample site.yml
[student@servera ceph-ansible]$ sudo vi site.yml
#……
- hosts: osds
gather_facts: false
become: True
serial: 1 #在osd(80行左右)添加此行
3.6 创建all.yml
[student@servera ~]$ cd /usr/share/ceph-ansible/group_vars/
[student@servera group_vars]$ sudo cp all.yml.sample all.yml
[student@servera group_vars]$ sudo vi all.yml
---
dummy:
ntp_service_enabled: false #本实验采用chrony进行时钟同步
ceph_origin: repository
ceph_repository: rhcs
ceph_rhcs_version: "3"
ceph_repository_type: cdn
rbd_cache: "true" #开启RBD回写缓存
rbd_cache_writethrough_until_flush: "false" #在切换回写之前,不从写透开始。
rbd_client_directories: false #不要创建客户机目录(它们应该已经存在)。
monitor_interface: eth0
journal_size: 1024 #本环境存储设备很小,OSD日志比通常建议的要小
public_network: 172.25.250.0/24
cluster_network: "{{ public_network }}"
ceph_conf_overrides:
global:
mon_osd_allow_primary_affinity: 1
mon_clock_drift_allowed: 0.5 #允许MON时钟间隔最多0.5秒
osd_pool_default_size: 2
osd_pool_default_min_size: 1 #降低存储池复制大小的默认设置
mon_pg_warn_min_per_osd: 0 #见提示一
mon_pg_warn_max_per_osd: 0 #见提示二
mon_pg_warn_max_object_skew: 0 #见提示三
client:
rbd_default_features: 1 #仅为以后的练习启用一组特定的客户机功能
3.7 正式部署Ceph集群
[student@servera ~]$ cd /usr/share/ceph-ansible/ [student@servera ceph-ansible]$ ansible-playbook site.yml提示:若部署成功,则对于每个MON节点,前面的命令输出应该显示failed=0。在playbook执行过程中,可能会有许多非致命的警告,它们不会被当做“失败”任务,可以忽略。
3.8 确认验证Ceph集群
[student@servera ~]$ ssh ceph@serverc ceph -s
[student@servera ~]$ ssh ceph@serverc cat /etc/ceph/ceph.conf
[student@servera ~]$ ssh ceph@serverc ps aux | grep ceph-mon
3.9 创建osds.yml
[student@servera ~]$ cd /usr/share/ceph-ansible/group_vars/
[student@servera group_vars]$ sudo cp osds.yml.sample osds.yml
[student@servera group_vars]$ sudo vi osds.yml
---
dummy:
osd_scenario: "collocated" #OSD使用并列的OSD形式
devices:
- /dev/vdb #使用/dev/vdb作为后端存储设备
3.10 配置Ansible Inventory
[student@servera ~]$ sudo vi /etc/ansible/hosts
[mons]
server[c:e]
[mgrs]
server[c:e]
[osds]
server[c:e] #追加osds组
3.11 正式部署OSD节点
[student@servera ~]$ cd /usr/share/ceph-ansible/ [student@servera ceph-ansible]$ ansible-playbook site.yml提示:若部署成功,则对于每个OSD节点,前面的命令输出应该显示failed=0。在playbook执行过程中,可能会有许多非致命的警告,它们不会被当做“失败”任务,可以忽略。
3.12 确认验证OSD节点
[student@servera ~]$ ssh ceph@serverc ceph -s
[student@servera ~]$ ssh ceph@serverc ceph -w #使用此命令监视集群事件提示:ceph -w命令将继续显示集群的运行状况和当前事件。要终止该命令,可按ctrl+c。
3.13 测试及验证
[ceph@serverc ~]$ sudo systemctl stop ceph-mon.target #停止serverc的mon进程 [ceph@serverc ~]$ ceph -s #观察Ceph状态
[ceph@serverc ~]$ sudo systemctl start ceph-mon.target #重启开启mon进程 [ceph@serverc ~]$ sudo systemctl stop ceph-osd.target #停止serverc的osd进程 [ceph@serverc ~]$ ceph -s #观察Ceph状态
[ceph@serverc ~]$ ceph osd tree #查看osd情况
[ceph@serverc ~]$ sudo systemctl start ceph-osd.target #重启开启osd进程 [ceph@serverc ~]$ sudo systemctl stop ceph-osd@0 #停止serverc的osd id为0的进程 [ceph@serverc ~]$ ceph osd tree #查看osd情况
[ceph@serverc ~]$ sudo systemctl start ceph-osd@0 #重启开启osd 0进程 [ceph@serverc ~]$ ceph -s #观察Ceph状态
[ceph@serverc ~]$ ceph -v #查看Ceph版本
3.14 创建client.yml
[student@servera ~]$ cd /usr/share/ceph-ansible/group_vars/
[student@servera group_vars]$ sudo cp clients.yml.sample clients.yml
[student@servera group_vars]$ sudo vi clients.yml
---
dummy:
copy_admin_key: true
3.15 配置Ansible Inventory
[student@servera ~]$ sudo vi /etc/ansible/hosts
[mons]
server[c:e]
[mgrs]
server[c:e]
[osds]
server[c:e]
[clients]
servera #追加client客户端
3.16 正式部署client节点
[student@servera ~]$ cd /usr/share/ceph-ansible/ [student@servera ceph-ansible]$ ansible-playbook site.yml提示:若部署成功,则对于每个OSD节点,前面的命令输出应该显示failed=0。在playbook执行过程中,可能会有许多非致命的警告,它们不会被当做“失败”任务,可以忽略。
3.17 确认验证
[kiosk@foundation0 ~]$ ssh ceph@servera #使用ceph用户登录servera [ceph@servera ~]$ ceph -s #查看Ceph集群
四 扩容Ceph集群
4.1 扩容前置条件
- 在不中断服务的前提下,扩展ceph集群存储容量
- 可通过ceph-ansible以两种方式扩展集群中的存储:
- 可以添加额外OSD主机到集群(scale-out)
- 可以添加额外存储设备到现有的OSD主机(scale-up)
- 开始部署额外的OSD前,需确保集群处于HEALTH_OK状态
- 相关主机解析已正常添加指hosts
4.2 创建相关用户
[root@serverf ~]# useradd student
[root@serverf ~]# echo student | passwd --stdin student #创建非root的管理用户
[root@serverf ~]# useradd -d /home/student -m student; echo "student" | passwd --stdin student' #所有OSD server节点创建student用户
[root@serverf ~]# useradd -d /home/ceph -m ceph; echo "redhat" | passwd --stdin ceph'
[root@serverf ~]# echo "student ALL = (root) NOPASSWD:ALL" > /etc/sudoers'
[root@serverf ~]# chmod 0440 /etc/sudoers
4.3 配置部署节点免密钥
[root@servera ~]# su - student [student@servera ~]$ ssh-copy-id student@serverf;ssh-copy-id ceph@serverf
4.4 扩容额外的OSD主机
[student@servera ~]$ sudo vi /etc/ansible/hosts #配置Ansible Inventory
[student@servera ~]$ sudo vi /etc/ansible/hosts
[mons]
server[c:e]
[mgrs]
server[c:e]
[osds]
server[c:e]
serverf #追加serverf
[clients]
servera
4.5 添加额外OSD存储设备
devices: - /dev/vdb - /dev/vdc - /dev/vdd #追加存储设备
4.6 正式部署OSD节点
[student@servera ~]$ cd /usr/share/ceph-ansible/ [student@servera ceph-ansible]$ ansible-playbook site.yml提示:若部署成功,则对于每个OSD节点,前面的命令输出应该显示failed=0。在playbook执行过程中,可能会有许多非致命的警告,它们不会被当做“失败”任务,可以忽略。
4.7 确认验证
[ceph@servera ~]$ ceph -s
[ceph@servera ~]$ ceph osd tree
[ceph@servera ~]$ ceph osd df
linuxboy的RSS地址:https://www.linuxboy.net/rssFeed.aspx
本文永久更新链接地址:https://www.linuxboy.net/Linux/2019-03/157530.htm
评论暂时关闭