[Ubuntu] 透過 Ansible 部署 CEPH

黃馨平
Jackycsie
Published in
6 min readApr 15, 2020

本篇會介紹如何透過 ceph-ansible 工具安裝一個 ceph 叢集,使用的環境是 ubuntu 18.04 LTS ,一個最簡單的 Ceph 儲存叢集至少要一台Monitor與三台OSD。而 MDS 是當需要使用到 CephFS 的時候才需要部署。

1.環境準備

本次安裝會擁有 5 台 node,叢集拓樸圖如下所示:

Tips:

  • 每一台 server 都需要安裝,NTP package。
$ apt install -y ntp
  • 每一台 hostname 必須先設定成未來 host 連接時一樣的名稱。
$ hostnamectl set-hostname {你想要的 hostname}
  • Ansible Node 先設定好可以直接不須密碼連進其他台 node(server).
$ ssh-keygen
$ ssh-copy-id root@ceph-node[1-4]

2.安裝 Ansible

  • 在 Ceph-Ansible 節點上安裝 ansible 工具。
root@ceph-ansible:~# apt-get install -y software-properties-common git cowsayroot@ceph-ansible:~# apt-add-repository -y ppa:ansible/ansible
root@ceph-ansible:~# apt-get update && sudo apt-get install -y ansible
  • 在 Ceph-Ansible 節點中,輸入以下內容。
  • 透過 ansible ping 指令,檢查是否有設置正確 hosts。
root@ceph-ansible:~# ansible all -m ping

3.透過 Ceph-Ansible 部屬 Ceph 叢集

  • 下載 ceph-aisible,轉 branch 到 stable-5.0,安裝必要檔案。
root@ceph-ansible:~# git clone "https://github.com/ceph/ceph-ansible.git"root@ceph-ansible:~# cd ceph-ansibleroot@ceph-ansible:~/ceph-ansible# git checkout -b origin/stable-5.0root@ceph-ansible:~/ceph-ansible# pip install -r requirements.txt
  • ,將 sample 檔轉成 yaml 檔案。
root@ceph-ansible:~/ceph-ansible# cp site.yml.sample site.ymlroot@ceph-ansible:~/ceph-ansible# cp group_vars/all.yml.sample group_vars/all.ymlroot@ceph-ansible:~/ceph-ansible# cp group_vars/osds.yml.sample group_vars/osds.ymlroot@ceph-ansible:~/ceph-ansible# cp group_vars/mgrs.yml.sample group_vars/mgrs.yml
  • 修改 group_vars/all.yml 中的配置。
50: mon_group_name: mons
51: osd_group_name: osds
65: configure_firewall: False
103: ntp_daemon_type: ntpd
125: ceph_origin: repository
132: ceph_repository: community
146: ceph_mirror: http://download.ceph.com
147: ceph_stable_key: https://download.ceph.com/keys/release.asc
148: ceph_stable_release: octopus
149: ceph_stable_repo: "{{ ceph_mirror }}/debian-{{ ceph_stable_release }}"
315: monitor_interface: ens3
380: public_network: "10.1.3.0/24"
385: osd_objectstore: bluestore
748: dashboard_admin_password: password
761: grafana_admin_password: password
  • 修改 group_vars/osds.yml 中的配置。
18: copy_admin_key: true
36: devices:
37: - /dev/vdb
50: osd_scenario: collocated
  • 修改 group_vars/mgrs.yml 中的配置。
26: ceph_mgr_modules: [status]
  • 修改 site.yml 中的配置。
  • 完成上述的編輯以後,透過下面指令進行部署。
root@ceph-ansible:~/ceph-ansible# ansible-playbook site.yml

完成 !

--

--

黃馨平
Jackycsie

閱讀本是尋常事,繁華靜處遇知音