Ansible-ceph集群

配置hosts解析

cat >> /etc/hosts <<EOF
172.19.200.8 ceph-node1
172.19.200.15 ceph-node2
172.19.200.13 ceph-node3
EOF

关闭防火墙和selinux

systemctl stop firewalld && systemctl disable firewalld
setenforce 0 && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

分别在三个节点设置主机名

hostnamectl set-hostname ceph-node1
hostnamectl set-hostname ceph-node2
hostnamectl set-hostname ceph-node3

分别在三个节点配置主机时间同步

yum install chrony python-netaddr -y-y
timedatectl set-timezone Asia/Shanghai
systemctl restart chronyd.service && systemctl enable chronyd.service

配置免密登录

ssh-keygen
ssh-copy-id -i .ssh/id_rsa.pub ceph-node1
ssh-copy-id -i .ssh/id_rsa.pub ceph-node2
ssh-copy-id -i .ssh/id_rsa.pub ceph-node3

安装pip和ansible、git

yum install python-pip ansible git -y  

部署ceph集群

这里我选择安装的是ceph nautilus 版本 版本: stable-4.0, 推荐这个版本,其他版本会出现无缘无故的问题 依赖: Ansible version 2.9

git clone https://github.com/ceph/ceph-ansible.git
cd ceph-ansible
git checkout stable-4.0

安装ansible依赖包

无法安装则使用指定安装路径 -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install --upgrade pip
pip3 install -U pip setuptools
pip3 install -r requirements.txt

修改hosts文件,添加安装的节点

cat >> ceph-hosts <<EOF
[mons]
ceph-node1
ceph-node2
ceph-node3

[osds]
ceph-node1
ceph-node2
ceph-node3

[mgrs]
ceph-node1
ceph-node2
ceph-node3

[mdss]
ceph-node1
ceph-node2
ceph-node3

[clients]
ceph-node1
ceph-node2
ceph-node3

[rgws]
ceph-node1
ceph-node2
ceph-node3

[grafana-server]
ceph-node1
ceph-node2
ceph-node3
EOF

备份group_vars下的yml文件

cd group_vars
for file in *;do cp $file ${file%.*};done

修改group_vars/all.yml配置

cat > all.yml <<EOF
---
dummy:
############下载包相关的源配置###############
ceph_origin: repository
ceph_origin: repository
ceph_repository: community
ceph_mirror: http://mirrors.aliyun.com/ceph
ceph_stable_key: "{{ ceph_mirror }}/keys/release.asc"
ceph_stable_release: nautilus
ceph_stable_repo: "{{ ceph_mirror }}/rpm-{{ ceph_stable_release }}"

############非常重要参数###################

public_network: "172.19.200.0/24"
cluster_network: "172.19.200.0/24"
monitor_interface: eth0

############创建osd必要的参数###############
osd_auto_discovery: true
osd_objectstore: filestore
radosgw_interface: eth0
dashboard_enabled: true
dashboard_protocol: http
dashboard_port: 8443
dashboard_admin_user: admin
dashboard_admin_password: admin@123!
grafana_admin_user: admin
grafana_admin_password: admin
grafana_uid: 472
grafana_datasource: Dashboard
grafana_dashboard_version: octopus
grafana_port: 3000
grafana_allow_embedding: True
devices:
  - /dev/vdb
  - /dev/vdc

EOF
cd ..
ansible-playbook -i ceph-hosts site.yml

# 等着吧,执行完再去节点上查看: ceph status

Last updated