一 前期准备
1.1 前置条件
至少有三个不同的主机运行monitor (MON)节点;
至少三个直接存储(非外部SAN硬件)的OSD节点主;
至少两个不同的manager (MGR)节点;
ASP站长网如果使用CephFS,则至少有两个完全相同配置的MDS节点;
如果使用Ceph对象网关,则至少有两个不同的RADOSGW节点。
一个部署节点,可以使用ceph-ansible包中的Ansible剧本来部署和配置集群。
提示:Red Hat Ceph存储还支持在Red Hat OpenStack平台计算节点上部署OSDs、MONs、RGWs,但不支持部署mon和osd。
红帽Ceph存储,默认配置将所有流量放在一个网络上。生产环境中建议公共通信和集群通信配置单独的网络。公共网络用于客户端通信和与mon的通信。集群网络用于OSD心跳、复制、回填和恢复流量。
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参数
 
变量
 
 

 
 
含义
 
 
fetch_directory
 
 
~/ceph-ansible-keys
 
 
用于将身份验证密钥复制到集群节点的临时目录的位置。
 
 
ceph_origin
 
 
repository
 
 
Ceph来源,repository表示使用包存储库
 
 
ceph_repository
 
 
rhcs
 
 
用于安装Red Hat的存储库Ceph存储。rhcs使用官方红帽Ceph存储包。
 
 
ceph_repository_type
 
 
cdn or iso
 
 
rhcs的安装源,CDN或本地ISO映像。
 
 
ceph_rhcs_iso_path
 
 
path to iso
 
 
如果使用iso存储库类型,则指向Red Hat Ceph存储iso的路径。
 
 
ceph_rhcs_version
 
 
3
 
 
Red Hat Ceph安装的版本。
 
 
monitor_interface
 
 
network interface
 
 
Monitor用于侦听的网络接口。
 
 
public_network
 
 
address and netmask
 
 
集群的公共网络的子网,如192.168.122.0/24。
 
 
cluster_network
 
 
address and netmask
 
 
集群专用网络的子网。默认设置为public_network的值。
 
 
journal_size
 
 
size in MB
 
 
分配给OSD日志的大小。应该是预期的两倍。在大多数情况下不应小于5120 MB。
 
提示:可以在group_vars/all.yml中将common_single_host_mode这个特殊参数设置为true。用于部署一个单节点、集所有功能于一身的Ceph集群作为测试学习使用。
osds.ym
 
变量
 
 

 
 
含义
 
 
osd_scenario
 
 
collocated
 
or non-collocated
 
 
OSD日志部署类型。
 
 
devices
 
 
用于OSDs的设备的名称列表。
 
 
用于并行OSD数据和日志分区或非并行OSD数据分区的设备。
 
 
dedicated_devices
 
 
用于非并列OSD期刊的设备名称列表。
 
 
OSD日志设备。
 
并置方案:假定所有OSD主机具有相同的硬件并使用相同的设备名称。
group_vars/osds.yml配置示例:
osd_scenario: "collocated"
devices:
- /dev/sdb
- /dev/sdc
- /dev/sdd
非并置方案:将不同的存储设备用于OSD数据和OSD日志。
group_vars/osds.yml配置示例:
osd_scenario: "non-collocated"
devices:
- /dev/sdb
- /dev/sdc
dedicated_devices:
- /dev/sdd
- /dev/sde
2.4 客户端相关命令
 
命令
 
 
含义
 
 
ceph -s
 
 
查看集群状态。
 
 
ceph -w
 
 
动态观察集群更改。
 
 
ceph df
 
 
查看集群剩余空间状态。
 
 
ceph osd df
 
 
查看OSD使用情况。
 
 
ceph auth get-or-create
 
 
创建用户。
 
 
aeph auth list
 
 
查看用户列表。
 
 
ceph auth caps
 
 
查看用户权限。
 
 
ceph auth del
 
 
删除用户。
 
2.5 对象object相关命令
 
命令
 
 
含义
 
 
rados -p pool_name ls
 
 
查看一个pool中的object。
 
 
rados -p pool_name put object_name file_path
 
 
上传一个文件作为对象。
 
 
rados -p pool_name get object_name file_path
 
 
以文件的形式检索object。
 
 
rados -p pool_name stat object_name
 
 
显示object的统计数据。
 
 
rados -p pool_name rm object_name
 
 
删除一个object。
 
三 正式部署
 
节点
 
 
类型
 
 
IP
 
 
备注
 
 
servera
 
 
部署节点
 
 
172.25.250.10
 
 
 
serverc
 
 
mons
 
mgrs
 
osds
 
 
172.25.250.12
 
 
 
serverd
 
 
mons
 
mgrs
 
osds
 
 
172.25.250.13
 
 
 
servere
 
 
mons
 
mgrs
 
osds
172.25.250.14
 
 
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组节点
 
提示:ceph ansible playbook为每种Ceph节点类型使用一个主机组:monitors节点使用mons, osds节点使用osds,managers节点使用mgrs,MDSs使用mdss, Ceph客户端使用clients, RADOS网关节点使用raws, iSCSI网关使用iscsi-gws,启用RBD mirroring使用rd-mirror。
因此需要需要根据Ceph主机的角色将它们在对应的Inventory文件中配置为对应的组。
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行左右)添加此行
 
提示:添加serial: 1添,会减慢了OSD的部署,但是使我们更有可能预测哪个OSD编号被分配给哪个OSD主机,以便将来的实验室练习。
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   #仅为以后的练习启用一组特定的客户机功能

dawei

【声明】:九江站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。