一 前期準備
1.1 前置條件
- 至少有三個不一樣的主機運行monitor (MON)節點;
- 至少三個直接存儲(非外部SAN硬件)的OSD節點主;
- 至少兩個不一樣的manager (MGR)節點;
- 若是使用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主要相關參數
變量
|
值
|
含義
|
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集羣做爲測試學習使用。
變量
|
值
|
含義
|
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 部署節點配置主機名
1 [root@servera ~]# vi /etc/hosts
2 172.25.250.10 servera
3 172.25.250.12 serverc
4 172.25.250.13 serverd
5 172.25.250.14 servere
提示:主機名應該能正確解析主機名,若管理節點同時也是一個Ceph節點,也要確認能正確解析本身的主機名和IP地址。本實驗環境此3.1步驟可省略。
3.2 建立相關用戶
1 [root@servera ~]# useradd student
2 [root@servera ~]# echo student | passwd --stdin student #建立非root的管理用戶
3 [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用戶
5 [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
6 [root@servera ~]# for i in {a..e}; do echo "====server${i}====";ssh root@server${i} 'echo "student ALL = (root) NOPASSWD:ALL" > /etc/sudoers'; done
7 [root@servera ~]# for i in {a..e}; do echo "====server${i}====";ssh root@server${i} 'chmod 0440 /etc/sudoers'; done
3.3 配置部署節點免密鑰
1 [root@servera ~]# su - student
2 [student@servera ~]$ ssh-keygen -f ~/.ssh/id_rsa -N ''
3 [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
1 [student@servera ~]$ sudo vi /usr/share/ceph-ansible/ansible.cfg
2 log_path = /tmp/ansible.log #修改日誌路徑爲student用戶可寫入的/tmp路徑
3 deprecation_warnings = False #禁用在ansible-playbook輸出結果相關必需要警告
提示:Ansible默認使用/etc/ansible/hosts做爲Inventory文件,也可以使用-f參數手動指定其餘文件。
1 [student@servera ~]$ sudo vi /etc/ansible/hosts
2 [mons]
3 server[c:e]
4
5 [mgrs]
6 server[c:e]
7 [student@servera ~]$ ansible mons -m ping #測試mons組節點通訊
8 [student@servera ~]$ ansible mgrs -m ping #測試mgrs組節點通訊
9 [student@servera ~]$ ansible mons -m command -a id #經過命令測試mons組節點
10 [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
1 [student@servera ~]$ cd /usr/share/ceph-ansible/
2 [student@servera ceph-ansible]$ sudo cp site.yml.sample site.yml
3 [student@servera ceph-ansible]$ sudo vi site.yml
4 #……
5 - hosts: osds
6 gather_facts: false
7 become: True
8 serial: 1 #在osd(80行左右)添加此行
提示:添加serial: 1添,會減慢了OSD的部署,可是使咱們更有可能預測哪一個OSD編號被分配給哪一個OSD主機,以便未來的實驗室練習。
3.6 建立all.yml
1 [student@servera ~]$ cd /usr/share/ceph-ansible/group_vars/
2 [student@servera group_vars]$ sudo cp all.yml.sample all.yml
3 [student@servera group_vars]$ sudo vi all.yml
4 ---
5 dummy:
6 ntp_service_enabled: false #本實驗採用chrony進行時鐘同步
7 ceph_origin: repository
8 ceph_repository: rhcs
9 ceph_rhcs_version: "3"
10 ceph_repository_type: cdn
11 rbd_cache: "true" #開啓RBD回寫緩存
12 rbd_cache_writethrough_until_flush: "false" #在切換回寫以前,不從寫透開始。
13 rbd_client_directories: false #不要建立客戶機目錄(它們應該已經存在)。
14 monitor_interface: eth0
15 journal_size: 1024 #本環境存儲設備很小,OSD日誌比一般建議的要小
16 public_network: 172.25.250.0/24
17 cluster_network: "{{ public_network }}"
18 ceph_conf_overrides:
19 global:
20 mon_osd_allow_primary_affinity: 1
21 mon_clock_drift_allowed: 0.5 #容許MON時鐘間隔最多0.5秒
22 osd_pool_default_size: 2
23 osd_pool_default_min_size: 1 #下降存儲池複製大小的默認設置
24 mon_pg_warn_min_per_osd: 0 #見提示一
25 mon_pg_warn_max_per_osd: 0 #見提示二
26 mon_pg_warn_max_object_skew: 0 #見提示三
27 client:
28 rbd_default_features: 1 #僅爲之後的練習啓用一組特定的客戶機功能
提示一:根據每一個OSD的pg數量關閉集羣健康警告。一般,第一個變量被設置爲30,若是OSD中的每一個「in」平均少於30個pg,集羣就會發出警告。
提示二:此變量默認值爲300,若是OSD中的每一個「in」平均超過300個pg,集羣就會發出警告,在本實驗的小集羣中可能沒有不少pg,所以採用禁用。
提示三:根據某個池中對象的數量大於集羣中一組池中對象的平均數量,關閉集羣健康警告。一樣,咱們有一個很是小的集羣,這避免了一般指示咱們須要調優集羣的額外警告。
3.7 正式部署Ceph集羣
1 [student@servera ~]$ cd /usr/share/ceph-ansible/
2 [student@servera ceph-ansible]$ ansible-playbook site.yml
提示:若部署成功,則對於每一個MON節點,前面的命令輸出應該顯示failed=0。在playbook執行過程當中,可能會有許多非致命的警告,它們不會被當作「失敗」任務,能夠忽略。
3.8 確認驗證Ceph集羣
1 [student@servera ~]$ ssh ceph@serverc ceph -s
1 [student@servera ~]$ ssh ceph@serverc cat /etc/ceph/ceph.conf
1 [student@servera ~]$ ssh ceph@serverc ps aux | grep ceph-mon
3.9 建立osds.yml
1 [student@servera ~]$ cd /usr/share/ceph-ansible/group_vars/
2 [student@servera group_vars]$ sudo cp osds.yml.sample osds.yml
3 [student@servera group_vars]$ sudo vi osds.yml
4 ---
5 dummy:
6 osd_scenario: "collocated" #OSD使用並列的OSD形式
7 devices:
8 - /dev/vdb #使用/dev/vdb做爲後端存儲設備
3.10 配置Ansible Inventory
1 [student@servera ~]$ sudo vi /etc/ansible/hosts
2 [mons]
3 server[c:e]
4
5 [mgrs]
6 server[c:e]
7
8 [osds]
9 server[c:e] #追加osds組
3.11 正式部署OSD節點
1 [student@servera ~]$ cd /usr/share/ceph-ansible/
2 [student@servera ceph-ansible]$ ansible-playbook site.yml
提示:若部署成功,則對於每一個OSD節點,前面的命令輸出應該顯示failed=0。在playbook執行過程當中,可能會有許多非致命的警告,它們不會被當作「失敗」任務,能夠忽略。
3.12 確認驗證OSD節點
1 [student@servera ~]$ ssh ceph@serverc ceph -s
1 [student@servera ~]$ ssh ceph@serverc ceph -w #使用此命令監視集羣事件
提示:ceph -w命令將繼續顯示集羣的運行情況和當前事件。要終止該命令,可按ctrl+c。
3.13 測試及驗證
1 [ceph@serverc ~]$ sudo systemctl stop ceph-mon.target #中止serverc的mon進程
2 [ceph@serverc ~]$ ceph -s #觀察Ceph狀態
1 [ceph@serverc ~]$ sudo systemctl start ceph-mon.target #重啓開啓mon進程
2 [ceph@serverc ~]$ sudo systemctl stop ceph-osd.target #中止serverc的osd進程
3 [ceph@serverc ~]$ ceph -s #觀察Ceph狀態
1 [ceph@serverc ~]$ ceph osd tree #查看osd狀況
1 [ceph@serverc ~]$ sudo systemctl start ceph-osd.target #重啓開啓osd進程
2 [ceph@serverc ~]$ sudo systemctl stop ceph-osd@0 #中止serverc的osd id爲0的進程
3 [ceph@serverc ~]$ ceph osd tree #查看osd狀況
1 [ceph@serverc ~]$ sudo systemctl start ceph-osd@0 #重啓開啓osd 0進程
2 [ceph@serverc ~]$ ceph -s #觀察Ceph狀態
1 [ceph@serverc ~]$ ceph -v #查看Ceph版本
3.14 建立client.yml
1 [student@servera ~]$ cd /usr/share/ceph-ansible/group_vars/
2 [student@servera group_vars]$ sudo cp clients.yml.sample clients.yml
3 [student@servera group_vars]$ sudo vi clients.yml
4 ---
5 dummy:
6 copy_admin_key: true
3.15 配置Ansible Inventory
1 [student@servera ~]$ sudo vi /etc/ansible/hosts
2 [mons]
3 server[c:e]
4
5 [mgrs]
6 server[c:e]
7
8 [osds]
9 server[c:e]
10
11 [clients]
12 servera #追加client客戶端
3.16 正式部署client節點
1 [student@servera ~]$ cd /usr/share/ceph-ansible/
2 [student@servera ceph-ansible]$ ansible-playbook site.yml
提示:若部署成功,則對於每一個OSD節點,前面的命令輸出應該顯示failed=0。在playbook執行過程當中,可能會有許多非致命的警告,它們不會被當作「失敗」任務,能夠忽略。
3.17 確認驗證
1 [kiosk@foundation0 ~]$ ssh ceph@servera #使用ceph用戶登陸servera
2 [ceph@servera ~]$ ceph -s #查看Ceph集羣
四 擴容Ceph集羣
4.1 擴容前置條件
- 在不中斷服務的前提下,擴展ceph集羣存儲容量
- 可經過ceph-ansible以兩種方式擴展集羣中的存儲:
- 能夠添加額外OSD主機到集羣(scale-out)
- 能夠添加額外存儲設備到現有的OSD主機(scale-up)
- 開始部署額外的OSD前,需確保集羣處於HEALTH_OK狀態
- 相關主機解析已正常添加指hosts
4.2 建立相關用戶
1 [root@serverf ~]# useradd student
2 [root@serverf ~]# echo student | passwd --stdin student #建立非root的管理用戶
3 [root@serverf ~]# useradd -d /home/student -m student; echo "student" | passwd --stdin student' #全部OSD server節點建立student用戶
4 [root@serverf ~]# useradd -d /home/ceph -m ceph; echo "redhat" | passwd --stdin ceph'
5 [root@serverf ~]# echo "student ALL = (root) NOPASSWD:ALL" > /etc/sudoers'
6 [root@serverf ~]# chmod 0440 /etc/sudoers
4.3 配置部署節點免密鑰
1 [root@servera ~]# su - student
2 [student@servera ~]$ ssh-copy-id student@serverf;ssh-copy-id ceph@serverf
4.4 擴容額外的OSD主機
1 [student@servera ~]$ sudo vi /etc/ansible/hosts #配置Ansible Inventory
2 [student@servera ~]$ sudo vi /etc/ansible/hosts
3 [mons]
4 server[c:e]
5
6 [mgrs]
7 server[c:e]
8
9 [osds]
10 server[c:e]
11 serverf #追加serverf
12
13 [clients]
14 servera
4.5 添加額外OSD存儲設備
1 devices:
2 - /dev/vdb
3 - /dev/vdc
4 - /dev/vdd #追加存儲設備
4.6 正式部署OSD節點
1 [student@servera ~]$ cd /usr/share/ceph-ansible/
2 [student@servera ceph-ansible]$ ansible-playbook site.yml
提示:若部署成功,則對於每一個OSD節點,前面的命令輸出應該顯示failed=0。在playbook執行過程當中,可能會有許多非致命的警告,它們不會被當作「失敗」任務,能夠忽略。
4.7 確認驗證
1 [ceph@servera ~]$ ceph -s
1 [ceph@servera ~]$ ceph osd tree
1 [ceph@servera ~]$ ceph osd df