Ceph 架構(gòu)及性能優(yōu)化

對(duì)分布式存儲(chǔ)系統(tǒng)的優(yōu)化離不開以下幾點(diǎn):
硬件層面
硬件規(guī)劃
SSD選擇
BIOS設(shè)置
軟件層面
Linux OS
Ceph Configurations
PG Number調(diào)整
CRUSH Map
其他因素
硬件層面
1、CPU
ceph-osd進(jìn)程在運(yùn)行過程中會(huì)消耗CPU資源,所以一般會(huì)為每一個(gè)ceph-osd進(jìn)程綁定一個(gè)CPU核上。
ceph-mon進(jìn)程并不十分消耗CPU資源,所以不必為ceph-mon進(jìn)程預(yù)留過多的CPU資源。
ceph-msd也是非常消耗CPU資源的,所以需要提供更多的CPU資源。
2、內(nèi)存
ceph-mon和ceph-mds需要2G內(nèi)存,每個(gè)ceph-osd進(jìn)程需要1G內(nèi)存。
3、網(wǎng)絡(luò)
萬(wàn)兆網(wǎng)絡(luò)現(xiàn)在基本上是跑Ceph必備的,網(wǎng)絡(luò)規(guī)劃上,也盡量考慮分離cilent和cluster網(wǎng)絡(luò)。網(wǎng)絡(luò)接口上可以使用bond來提供高可用或負(fù)載均衡。
4、SSD
SSD在ceph中的使用可以有幾種架構(gòu)
a、ssd作為Journal
b、ssd作為高速ssd pool(需要更改crushmap)
c、ssd做為tier pool
5、BIOS
a、開啟VT和HT,VH是虛擬化云平臺(tái)必備的,HT是開啟超線程單個(gè)處理器都能使用線程級(jí)并行計(jì)算。
b、關(guān)閉節(jié)能設(shè)置,可有一定的性能提升。
c、NUMA思路就是將內(nèi)存和CPU分割為多個(gè)區(qū)域,每個(gè)區(qū)域叫做NODE,然后將NODE高速互聯(lián)。node內(nèi)cpu與內(nèi)存訪問速度快于訪問其他node的內(nèi)存, NUMA可能會(huì)在某些情況下影響ceph-osd 。解決的方案,一種是通過BIOS關(guān)閉NUMA,另外一種就是通過cgroup將ceph-osd進(jìn)程與某一個(gè)CPU Core以及同一NODE下的內(nèi)存進(jìn)行綁定。但是第二種看起來更麻煩,所以一般部署的時(shí)候可以在系統(tǒng)層面關(guān)閉NUMA。CentOS系統(tǒng)下,通過修改/etc/grub.conf文件,添加numa=off來關(guān)閉NUMA。
軟件層面
1、Kernel pid max
echo 4194303 > /proc/sys/kernel/pid_max
2、設(shè)置MTU,交換機(jī)端需要支持該功能,系統(tǒng)網(wǎng)卡設(shè)置才有效果
配置文件追加MTU=9000
3、read_ahead, 通過數(shù)據(jù)預(yù)讀并且記載到隨機(jī)訪問內(nèi)存方式提高磁盤讀操作
echo "8192" > /sys/block/sda/queue/read_ahead_kb
4、swappiness, 主要控制系統(tǒng)對(duì)swap的使用
echo "vm.swappiness = 0"/>etc/sysctl.conf ; sysctl –p
5、I/O Scheduler,SSD要用noop,SATA/SAS使用deadline
echo "deadline" >/sys/block/sd[x]/queue/scheduler
echo "noop" >/sys/block/sd[x]/queue/scheduler
6、ceph.conf 配置選項(xiàng)
[global]#全局設(shè)置
fsid = 88caa60a-e6d1-4590-a2b5-bd4e703e46d9 #集群標(biāo)識(shí)ID
mon host = 10.0.1.21,10.0.1.22,10.0.1.23 #monitor IP 地址
auth cluster required = cephx #集群認(rèn)證
auth service required = cephx #服務(wù)認(rèn)證
auth client required = cephx #客戶端認(rèn)證
osd pool default size = 2 #最小副本數(shù)
osd pool default min size = 1 #PG 處于 degraded 狀態(tài)不影響其 IO 能力,min_size是一個(gè)PG能接受IO的最小副本數(shù)
osd pool default pg num = 128 #pool的pg數(shù)量
osd pool default pgp num = 128 #pool的pgp數(shù)量
public network = 10.0.1.0/24 #公共網(wǎng)絡(luò)(monitorIP段)
cluster network = 10.0.1.0/24 #集群網(wǎng)絡(luò)
max open files = 131072 #默認(rèn)0#如果設(shè)置了該選項(xiàng),Ceph會(huì)設(shè)置系統(tǒng)的max open fds
mon initial members = controller1, controller2, compute01
#初始monitor (由創(chuàng)建monitor命令而定)
##############################################################
[mon]
mon data = /var/lib/ceph/mon/ceph-$id
mon clock drift allowed = 1 #默認(rèn)值0.05,monitor間的clock drift
mon osd min down reporters = 13 #默認(rèn)值1,向monitor報(bào)告down的最小OSD數(shù)
mon osd down out interval = 600 #默認(rèn)值300,標(biāo)記一個(gè)OSD狀態(tài)為down和out之前ceph等待的秒數(shù)
##############################################################
[osd]
osd data = /var/lib/ceph/osd/ceph-$id
osd journal size = 20000 #默認(rèn)5120,osd journal大小
osd journal = /var/lib/ceph/osd/$cluster-$id/journal #osd journal位置
osd mkfs type = xfs #格式化系統(tǒng)類型
osd mkfs options xfs = -f -i size=2048 #強(qiáng)制格式化
filestore xattr use omap = true #默認(rèn)false,為XATTRS使用object map,EXT4文件系統(tǒng)時(shí)使用,XFS或者btrfs也可以使用
filestore min sync interval = 10 #默認(rèn)0.1,從日志到數(shù)據(jù)盤最小同步間隔(seconds)
filestore max sync interval = 15 #默認(rèn)5,從日志到數(shù)據(jù)盤最大同步間隔(seconds)
filestore queue max ops = 25000 #默認(rèn)500,數(shù)據(jù)盤最大接受的操作數(shù)
filestore queue max bytes = 1048576000 #默認(rèn)100,數(shù)據(jù)盤一次操作最大字節(jié)數(shù)(bytes
filestore queue committing max ops = 50000 #默認(rèn)500,數(shù)據(jù)盤能夠commit的操作數(shù)
filestore queue committing max bytes = 10485760000 #默認(rèn)100,數(shù)據(jù)盤能夠commit的最大字節(jié)數(shù)(bytes)
filestore split multiple = 8 #默認(rèn)值2,#前一個(gè)子目錄分裂成子目錄中的文件的最大數(shù)量
filestore merge threshold = 40 #默認(rèn)值10,#前一個(gè)子類目錄中的文件合并到父類的最小數(shù)量
filestore fd cache size = 1024 #默認(rèn)值128,#對(duì)象文件句柄緩存大小
journal max write bytes = 1073714824 #默認(rèn)值1048560,journal一次性寫入的最大字節(jié)數(shù)(bytes)
journal max write entries = 10000 #默認(rèn)值100,journal一次性寫入的最大記錄數(shù)
journal queue max ops = 50000 #默認(rèn)值50,journal一次性最大在隊(duì)列中的操作數(shù)
journal queue max bytes = 10485760000 #默認(rèn)值33554432,journal一次性最大在隊(duì)列中的字節(jié)數(shù)(bytes)
osd max write size = 512 #默認(rèn)值90,OSD一次可寫入的最大值(MB)
osd client message size cap = 2147483648 #默認(rèn)值100,客戶端允許在內(nèi)存中的最大數(shù)據(jù)(bytes)
osd deep scrub stride = 131072 #默認(rèn)值524288,在Deep Scrub時(shí)候允許讀取的字節(jié)數(shù)(bytes)
osd op threads = 16 #默認(rèn)值2,并發(fā)文件系統(tǒng)操作數(shù)
osd disk threads = 4 #默認(rèn)值1,#OSD密集型操作例如恢復(fù)和Scrubbing時(shí)的線程
osd map cache size = 1024 #默認(rèn)值500,保留OSD Map的緩存(MB)
osd map cache bl size = 128 #默認(rèn)值50,OSD進(jìn)程在內(nèi)存中的OSD Map緩存(MB)
osd mount options xfs = "rw,noexec,nodev,noatime,nodiratime,nobarrier" #默認(rèn)值rw,noatime,inode64,Ceph OSD xfs Mount選項(xiàng)
osd recovery op priority = 2 #默認(rèn)值10,恢復(fù)操作優(yōu)先級(jí),取值1-63,值越高占用資源越高
osd recovery max active = 10 #默認(rèn)值15,同一時(shí)間內(nèi)活躍的恢復(fù)請(qǐng)求數(shù)
osd max backfills = 4 #默認(rèn)值10,一個(gè)OSD允許的最大backfills數(shù)
osd min pg log entries = 30000 #默認(rèn)值3000,修建PGLog是保留的最大PGLog數(shù)
osd max pg log entries = 100000 #默認(rèn)值10000,修建PGLog是保留的最大PGLog數(shù)
osd mon heartbeat interval = 40 #默認(rèn)值30,OSD ping一個(gè)monitor的時(shí)間間隔(默認(rèn)30s)
ms dispatch throttle bytes = 1048576000 #默認(rèn)值 104857600,等待派遣的最大消息數(shù)
objecter inflight ops = 819200 #默認(rèn)值1024 ,客戶端流控,允許的最大未發(fā)送io請(qǐng)求數(shù),超過閥值會(huì)堵塞應(yīng)用io,為0表示不受限
osd op log threshold = 50 #默認(rèn)值5,#一次顯示多少操作的log
osd crush chooseleaf type = 0 #默認(rèn)值為1,CRUSH規(guī)則用到chooseleaf時(shí)的bucket的類型
##############################################################
[client]
rbd cache = true #默認(rèn)值 true ,RBD緩存
rbd cache size = 335544320 #默認(rèn)值33554432,RBD緩存大小(bytes)
rbd cache max dirty = 134217728 #默認(rèn)值25165824,緩存為write-back時(shí)允許的最大dirty字節(jié)數(shù)(bytes),如果為0,使用write-through
rbd cache max dirty age = 30 #默認(rèn)值1,在被刷新到存儲(chǔ)盤前dirty數(shù)據(jù)存在緩存的時(shí)間(seconds)
rbd cache writethrough until flush = false
#默認(rèn)值true,該選項(xiàng)是為了兼容linux-2.6.32之前的virtio驅(qū)動(dòng),避免因?yàn)椴话l(fā)送flush請(qǐng)求,數(shù)據(jù)不回寫。
#設(shè)置該參數(shù)后,librbd會(huì)以writethrough的方式執(zhí)行io,直到收到第一個(gè)flush請(qǐng)求,才切換為writeback方式。
rbd cache max dirty object = 2
#默認(rèn)值0,最大的Object對(duì)象數(shù),默認(rèn)為0,表示通過rbd cache size計(jì)算得到,librbd默認(rèn)以4MB為單位對(duì)磁盤Image進(jìn)行邏輯切分。
#每個(gè)chunk對(duì)象抽象為一個(gè)Object;librbd中以O(shè)bject為單位來管理緩存,增大該值可以提升性能。
rbd cache target dirty = 235544320
#默認(rèn)值16777216,開始執(zhí)行回寫過程的臟數(shù)據(jù)大小,不能超過 rbd_cache_max_dirty
7、PG Number
PG和PGP數(shù)量一定要根據(jù)OSD的數(shù)量進(jìn)行調(diào)整,計(jì)算公式如下,但是最后算出的結(jié)果一定要接近或者等于一個(gè)2的指數(shù)。
Total PGs = (Total_number_of_OSD * 100) / max_replication_count
例:有100個(gè)osd,2副本,5個(gè)pool
Total PGs =100*100/2=5000
每個(gè)pool 的PG=5000/5=1000,那么創(chuàng)建pool的時(shí)候就指定pg為1024
ceph osd pool create pool_name 1024
8、修改crush map
Crush map可以設(shè)置不同的osd對(duì)應(yīng)到不同的pool,也可以修改每個(gè)osd的weight
9、其他因素
ceph osd perf
通過osd perf可以提供磁盤latency的狀況,如果延時(shí)過長(zhǎng),應(yīng)該剔除osd
作者:Jacken_yang
出處:https://blog.51cto.com/linuxnote/1791167
推薦閱讀:
世界的真實(shí)格局分析,地球人類社會(huì)底層運(yùn)行原理
企業(yè)IT技術(shù)架構(gòu)規(guī)劃方案
華為內(nèi)網(wǎng)最火的文章:什么是內(nèi)卷?
不是你需要中臺(tái),而是一名合格的架構(gòu)師(附各大廠中臺(tái)建設(shè)PPT)
【中臺(tái)實(shí)踐】華為大數(shù)據(jù)中臺(tái)架構(gòu)分享.pdf
阿里達(dá)摩院《機(jī)器學(xué)習(xí)算法學(xué)習(xí)指南》火了,限時(shí)開放下載!
