補充内容:
1.修改 crushmap 有兩種方式:線上修改和離線修改
2.為了保險起見一般都是采用離線修改,也就是導出來修改
3.導出預設的 crushmap,這個是二進制檔案打不開
ceph osd getcrushmap -o {compiled-crushmap-filename}
4.将剛才的二進制檔案轉換成可視化的文本檔案
crushtool -d {compiled-crushmap-filename} -o {decompiled-crushmap-filename}
5.轉換成可視化的文本檔案之後,建議不要把預設的二進制檔案删掉避免修改 crushmap 造成 ceph 叢集癱瘓,這樣我們還留了一個備份
6.修改 crushmap,也就是下面講述的 crushmap 詳解,根據實際情況修改
7.将剛才修改的可視化文本檔案轉換成二進制檔案
crushtool -c {decompiled-crush-map-filename} -o {compiled-crush-map-filename}
8.設定 OSD 的 crushmap,也就是把剛才轉換的二進制檔案讓他生效
ceph osd setcrushmap -i {compiled-crushmap-filename}
9.建立 ssd 和 sata 兩個 pool
ceph osd pool create ssd 128
ceph osd pool create sata 128
10.建立完 ssd 和 sata 兩個 pool 之後更新下 cinder 密鑰的權限
ceph auth caps client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes,
allow rx pool=images, allow rwx pool=ssd, allow rwx pool=sata'
Cinder multi backend思路以及步驟:
<a href="http://s3.51cto.com/wyfs02/M01/58/B3/wKiom1S4geyQE7JaAAIXoR8ElKo171.jpg" target="_blank"></a>
一、根據實際情況在ceph上建立相應的pool,例如ssd,sata等等
二、根據實際情況編寫crushmap,下面是我摘抄sebastien-han的一篇配置ssd,sata的文章裡面的crushmap。
将其配置摘錄如下:
##
# OSD SATA DECLARATION
host ceph-osd2-sata {
id -2 # do not change unnecessarily
# weight 0.000
alg straw
hash 0 # rjenkins1
item osd.0 weight 1.000
item osd.3 weight 1.000
}
host ceph-osd1-sata {
id -3 # do not change unnecessarily
item osd.2 weight 1.000
item osd.5 weight 1.000
host ceph-osd0-sata {
id -4 # do not change unnecessarily
item osd.1 weight 1.000
item osd.4 weight 1.000
# OSD SSD DECLARATION
host ceph-osd2-ssd {
id -22 # do not change unnecessarily
item osd.6 weight 1.000
item osd.9 weight 1.000
host ceph-osd1-ssd {
id -23 # do not change unnecessarily
item osd.8 weight 1.000
item osd.11 weight 1.000
host ceph-osd0-ssd {
id -24 # do not change unnecessarily
item osd.7 weight 1.000
item osd.10 weight 1.000
# SATA ROOT DECLARATION
root sata {
id -1 # do not change unnecessarily
item ceph-osd2-sata weight 2.000
item ceph-osd1-sata weight 2.000
item ceph-osd0-sata weight 2.000
root ssd {
id -21 # do not change unnecessarily
item ceph-osd2-ssd weight 2.000
item ceph-osd1-ssd weight 2.000
item ceph-osd0-ssd weight 2.000
# SSD RULE DECLARATION
# rules
rule ssd {
ruleset 0
type replicated
min_size 1
max_size 10
step take ssd
step chooseleaf firstn 0 type host
step emit
# SATA RULE DECLARATION
rule sata {
ruleset 1
step take sata
這個crushmap是将SSD和SATA的盤分到了多個邏輯host然後再針對于邏輯host進行bucket分組,一個bucket對應一個rule。
預設的crushmap的話應該是下面這樣的一個組織架構:
<a href="http://s3.51cto.com/wyfs02/M02/58/B0/wKioL1S4hN2iK_RfAACbIG3Cdhs428.jpg" target="_blank"></a>
三、他将所有的host分為了一個bucket然後針對于bucket做了一個default的rule。
設定pool的crushmap
ceph osd pool set [pool name] crush_ruleset 0 #注解:這裡的crush_ruleset 0 是你在crushmap裡面的rule選項
ceph osd pool set [pool name] crush_ruleset 1 #注解:這裡的crush_ruleset 1 是你在crushmap裡面的rule選項
至此ceph端已經配置完畢,接下來配置cinder端
四、在cinder-volumes節點配置
vi /etc/cinder/cinder.conf 添加如下
enabled_backends=ssd,sata
[ssd]volume_driver=cinder.volume.driver.RBDDriverrbd_pool=ssdvolume_backend_name=ssd
rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_flatten_volume_from_snapshot = false
rbd_max_clone_depth = 5
rbd_store_chunk_size = 4
rados_connect_timeout = -1
glance_api_version = 2
rbd_user = cinder
rbd_secret_uuid = XXXXXXXXX
[sata]volume_driver=cinder.volume.driver.RBDDriverrbd_pool=satavolume_backend_name=sata
五、建立兩個cinder 卷類型
cinder type-create ssd
cinder type-create ssta
root@controller:~# cinder type-list
+--------------------------------------+------+
| ID | Name |
| 707e887d-95e5-45ca-b7df-53a51fadf458 | ssd |
| 82c32938-f1e5-4e22-a4b9-b0920c4543e7 | sata |
六、設定卷類型的key鍵值
cinder type-key ssd set volume_backend_name=ssd
cinder type-key ssd set volume_backend_name=sata
root@controller:~# cinder extra-specs-list
+--------------------------------------+------+-----------------------------------+
| ID | Name | extra_specs |
| 707e887d-95e5-45ca-b7df-53a51fadf458 | ssd | {u'volume_backend_name': u'ssd'} |
| 82c32938-f1e5-4e22-a4b9-b0920c4543e7 | sata | {u'volume_backend_name': u'sata'} |
七、最後重新開機服務
restart cinder-api ; sudo restart cinder-scheduler
在cinder-volumes節點
restart cinder-volume
八、驗證是否成功
<a href="http://s3.51cto.com/wyfs02/M00/58/B0/wKioL1S4hOKD5Fh9AACIQQY7rxw778.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/58/B0/wKioL1S4hOrR6UFAAADt5X4HkgI361.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/58/B0/wKioL1S4hO6gFVbIAACPEbZC4nA858.jpg" target="_blank"></a>
故障總結:
在修改ceph的crushmap的過程中一般會遇到以下幾種情況:
<a href="http://s3.51cto.com/wyfs02/M00/59/27/wKiom1TIp3OgelehAAEzCsPq5Yk795.jpg" target="_blank"></a>
這種情況呢是因為我的pool size設定的是2,而我改了crushmap之後變成了已單個host為bucket的是以要把pool size設定成1.
但是當我改了pool size之後還是會有些問題,他狀态變成了以下,Pg正常重新映射關系,可能pg映射的osd集合與根據crush計算的不一樣。
<a href="http://s3.51cto.com/wyfs02/M01/59/27/wKiom1TIp3Tjdbq5AAEDnLuMyrE093.jpg" target="_blank"></a>
檢視remapped狀态的pg都在哪些osd上
<a href="http://s3.51cto.com/wyfs02/M02/59/27/wKiom1TIp3aztJDjAAIizcrYveM873.jpg" target="_blank"></a>
根據pg dump出來的顯示雖然我把pool size設定成了1,但是還有些pg size是2,pg 1.7e的acting集合有2和0兩個osd,于是把osd2和osd0重新開機,讓這2個osd上的pg重新peering
<a href="http://s3.51cto.com/wyfs02/M00/59/27/wKiom1TIp3jSBvb8AAEFU_HkHyA708.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/59/27/wKiom1TIp3jzavqsAAEe_8UsHtg918.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/59/27/wKiom1TIp3jgpGNIAAEG_hd54_E509.jpg" target="_blank"></a>
狀态在逐漸變好,最後我重新開機了全部osd
<a href="http://s3.51cto.com/wyfs02/M00/59/27/wKiom1TIp3nB0EG6AADg_2cE9A8427.jpg" target="_blank"></a>
本文轉自Devin 51CTO部落格,原文連結:http://blog.51cto.com/devingeng/1609285