1 获取osdmap

		
root@host1:~/bean# ceph osd getmap -o om
got osdmap epoch 142

2 获取crushmap

		
root@host1:~/bean# osdmaptool om --export-crush crush
osdmaptool: osdmap file 'om'
osdmaptool: exported crush map to crush
或者可以使用如下命令:
 ceph osd getcrushmap -o cm

3 获取某个pool上pg的分布情况

		
 
root@host1:~/bean# osdmaptool om --import-crush cm --test-map-pgs --pool 2
osdmaptool: osdmap file 'om'
osdmaptool: imported 669 byte crush map from cm
pool 2 pg_num 1024
#osd count first primary c wt wt
osd.0 224 138 138 0.00563049 1
osd.1 304 139 139 0.00563049 1
osd.2 302 137 137 0.00563049 1
osd.3 223 121 121 0.00563049 1
osd.4 315 131 131 0.00563049 1
osd.5 317 140 140 0.00563049 1
osd.6 363 218 218 0.00947571 1
 in 7
 avg 292 stddev 47.5455 (0.162827x) (expected 15.8359 0.0542325x))
 min osd.3 223
 max osd.6 363
size 0 0
size 1 0
size 2 1024
size 3 0
osdmaptool: writing epoch 144 to om

可以看出,PG在各个OSD上的分布并不均匀,如果用户几乎所有的数据都在该pool上,假以时日,各个OSD必然不均衡。很多客户报会遇到,集群总体空间只用了60%多,可是已经有OSD使用率超过了85%甚至马上到了95%。

因此,对于这种绝大多数数据位于一个pool上的场景,在部署阶段,就将PG均匀地分布在各个OSD上是十分重要的,也是可能的。具体方法,下回分解。

12-17 03:25