使用ceph-ansible部署docker化的ceph集羣
安裝ansible
關於安裝ansible,這裏就不再累述,請參考官方文檔。
下載ceph-ansible
git clone https://github.com/ceph/ceph-ansible.git
cd ceph-ansible
# 關於分支說明請參考ceph-ansible的官方文檔 http://docs.ceph.com/ceph-ansible/master/
# stable-3.1 Support for Ceph version luminous and mimic. This branch supports Ansible version 2.4.
git checkout stable-3.1
配置ceph-ansible
cp group_vars/all.yml.sample group_vars/all.yml
cp group_vars/osds.yml.sample group_vars/osds.yml
cp site-docker.yml.sample site-docker.yml
編輯group_vars/all.yml文件,以下信息請根據實際的情況進行適配修改。
generate_fsid: true
monitor_interface: ens5f0
journal_size: 5120
public_network: 192.168.74.0/24
cluster_network: 192.168.74.0/24
ceph_docker_image: "ceph/daemon"
ceph_docker_image_tag: master-d4b8dde-mimic-centos-7-x86_64
containerized_deployment: true
ceph_docker_registry: docker.io
radosgw_interface: ens5f0
編輯group_vars/osds.yml文件,以下信息請根據實際的情況進行適配修改。
osd_scenario: non-collocated
osd_objectstore: bluestore
dmcrypt: false
devices:
- /dev/sda
- /dev/sdb
- /dev/sdc
dedicated_devices:
- /dev/sdd
- /dev/sdd
- /dev/sdd
bluestore_wal_devices:
- /dev/sdd
- /dev/sdd
- /dev/sdd
創建hosts文件,以下信息請根據實際的情況進行適配修改。
[mons]
192.168.74.200 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.201 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.202 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
[mgrs]
192.168.74.200 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.201 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.202 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
[osds]
192.168.74.200 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.201 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.202 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
[rgws]
192.168.74.200 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.201 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
192.168.74.202 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xxx
啓動部署
若下面的命令出錯,日誌文件默認在/var/log/ansible.log,可參考出錯的日誌進行處理。(注:在部署過程中,會在每個節點上默認安裝docker,這一步腳本中並不會判斷當前機器是否已經安裝過docker,若目標機器已經安裝過docker了,這裏可能會出錯,解決的辦法就是註釋掉相應的安裝docker的步驟,相應的內容在roles/ceph-docker-common/tasks/pre_requisites/prerequisites.yml。)
ansible-playbook site-docker.yml -i hosts
銷燬集羣(謹慎)
這裏會默認卸載docker,若不想卸載docker,註釋掉infrastructure-playbooks/purge-docker-cluster.yml中相應的代碼即可。
ansible-playbook infrastructure-playbooks/purge-docker-cluster.yml -i hosts