調節bluestore_rocksdb參數,fio來測試ceph隨機寫的性能,指望進行優化。
在 上一篇文章中測試了在ceph環境下,經過gdbprof分析4k-randwrite的性能,能夠看出rocksdb線程耗用資源較多,由於ceph的底層就是基於rocksdb進行存儲的,所以嘗試着去調節ceph中導出的rocksdb參數,來達到一個調優效果。
$ceph osd tree
$ceph -s
vim
接下來對參數進行說明:
"bluestore_rocksdb_options": "compression=kNoCompression,max_write_buffer_number=4,min_write_buffer_number_to_merge=1,recycle_log_file_num=4,write_buffer_size=268435456,writable_file_max_buffer_size=0,compaction_readahead_size=2097152"Compression=kNoCompression
:表示數據不進行壓縮。對每一個SST文件,數據塊和索引塊都會被單獨壓縮,默認是Snappywrite_buffer_size=268435456(2^28)
:memtable的最大size,若是超過這個值,RocksDB會將其變成immutable memtable,並使用另外一個新的memtable。插入數據時RocksDB首先會將其放到memtable裏,因此寫入很快,當一個memtable full以後,RocksDB會將該memtable變成immutable,用另外一個新的memtable來存儲新的寫入,immutable的memtable就被等待flush到level0max_write_buffer_number=4
:最大的memtable個數。若是active memtable都full了,而且active memtable+immutable memtable個數超過max_write_buffer_number,則RocksDB會中止寫入,一般緣由是寫入太快而flush不及時形成的。min_write_buffer_number_to_merge=1
:在flush到level0以前,最少須要被merge的memtable個數,如min_write_buffer_number_to_merge =2,那麼至少當有兩個immutable的memtable時,RocksDB纔會將這兩個immutable memTable先merge,再flush到level0。Merge 的好處是,譬如在一個key在不一樣的memtable裏都有修改,能夠merge造成一次修改。min_write_buffer_number_to_merge太大會影響讀取性能,由於Get會遍歷全部的memtable來看該key是否存在。compaction_readahead_size=2097152(2^21)
:預讀大小,在進行compression時,執行更大的數據讀取,writable_file_max_buffer_size=0
:可寫文件的最大寫緩存緩存
首先分爲服務端機器server_host和客戶端機器client_host
修改server_host的/etc/ceph/ceph.conf中bluestore rocksdb項
$vim /etc/ceph/ceph.conf
添加如下參數配置app
[osd] bluestore rocksdb options = compression=kNoCompression,max_write_buffer_number=8,min_write_buffer_number_to_merge=4,recycle_log_file_num=4,write_buffer_size=356870912,writable_file_max_buffer_size=0,compaction_readahead_size=8388608 [osd.0] [osd.1] [osd.2]
wq保存退出性能
systemctl restart ceph-osd@0.service
systemctl restart ceph-osd@1.service
systemctl restart ceph-osd@2.service注
:osd一個一個的重啓,不要快速重啓三個,等一個osd重啓並運行正常後(可用$ceph osd tree查看),再重啓第二個,否則集羣容易掛掉測試
ceph daemon osd.0 config show | grep bluestore_rocksdb
ceph daemon osd.1 config show | grep bluestore_rocksdb
ceph daemon osd.2 config show | grep bluestore_rocksdb優化
(1)先建立image再進行4k-randwrite操做spa
**$rbd create --pool ymg --image img01 --size 40G**
(2)填充image線程
**$fio -direct=1 -iodepth=256 -ioengine=rbd -pool=ymg -rbdname=img01 -rw=write -bs=1M -size=40G -ramp_time=5 -group_reporting -name=full-fill**
(3)randwrite命令rest
**$fio -direct=1 -iodepth=256 -ioengine=rbd -pool=ymg -rbdname=img01 -rw=randwrite -bs=4K -runtime=300 -numjobs=1 -ramp_time=5 -group_reporting -name=parameter1**
compression=kNoCompression
max_write_buffer_number=4
min_write_buffer_number_to_merge=1
recycle_log_file_num=4
write_buffer_size=268435456
writable_file_max_buffer_size=0
compaction_readahead_size=2097152
時間段:16:57:04~17:02:04
結果以下
code