您好,登录后才能下订单哦!
本篇内容主要讲解“Ceph常用的命令总结”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Ceph常用的命令总结”吧!
1. 创建自定义pool
ceph osd pool create pg_num pgp_num
其中pgp_num为pg_num的有效归置组个数,是一个可选参数。pg_num应该足够大,不要拘泥于官方文档的计算方法,根据实际情况选择256、512、1024、2048、4096。
2. 设置pool的副本数、最小副本数、最大副本数
ceph osd pool set <poolname> size 2 ceph osd pool set <poolname> min_size 1 ceph osd pool set <poolname> max_size 10
资源所限,如果不希望保存3副本,可以用该命令对特定的pool更改副本存放数。
利用get可以获得特定pool的副本数。
ceph osd pool get <poolname> size
3. 增加osd
可以利用ceph-deploy增加osd:
ceph-deploy osd prepare monosd1:/mnt/ceph osd2:/mnt/ceph ceph-deploy osd activate monosd1:/mnt/ceph osd2:/mnt/ceph #相当于: ceph-deploy osd create monosd1:/mnt/ceph osd2:/mnt/ceph #还有一种方法,在安装osd时同时指定对应的journal的安装路径 ceph-deploy osd create osd1:/cephmp1:/dev/sdf1 /cephmp2:/dev/sdf2
也可以手动增加:
## Prepare disk first, create partition and format it <insert parted oneliner> mkfs.xfs -f /dev/sdd mkdir /cephmp1 mount /dev/sdd /cephmp1 cd /cephmp1 ceph-osd -i 12 --mkfs --mkkey ceph auth add osd.12 osd 'allow *' mon 'allow rwx' -i /cephmp1/keyring #change the crushmap ceph osd getcrushmap -o map crushtool -d map -o map.txt vim map.txt crushtool -c map.txt -o map ceph osd setcrushmap -i map ## Start it /etc/init.d/ceph start osd.12
4. 删除osd
先将此osd停止工作:
## Mark it out ceph osd out 5 ## Wait for data migration to complete (ceph -w), then stop it service ceph -a stop osd.5 ## Now it is marked out and down
再对其进行删除操作:
## If deleting from active stack, be sure to follow the above to mark it out and down ceph osd crush remove osd.5 ## Remove auth for disk ceph auth del osd.5 ## Remove disk ceph osd rm 5 ## Remove from ceph.conf and copy new conf to all hosts
5. 查看osd总体情况、osd的详细信息、crush的详细信息
ceph osd tree ceph osd dump --format=json-pretty ceph osd crush dump --format=json-pretty
6. 获得并修改CRUSH maps
## save current crushmap in binary ceph osd getcrushmap -o crushmap.bin ## Convert to txt crushtool -d crushmap.bin -o crushmap.txt ## Edit it and re-convert to binary crushtool -c crushmap.txt -o crushmap.bin.new ## Inject into running system ceph osd setcrushmap -i crushmap.bin.new ## If you've added a new ruleset and want to use that for a pool, do something like: ceph osd pool default crush rule = 4 #也可以这样设置一个pool的rule cpeh osd pool set testpool crush_ruleset <ruleset_id>
-o=output; -d=decompile; -c=compile; -i=input
记住这些缩写,上面的命令就很容易理解了。
7. 增加/删除journal
为了提高性能,通常将ceph的journal置于单独的磁盘或分区中:
先利用以下命令设置ceph集群为nodown:
ceph osd set nodown
# Relevant ceph.conf options -- existing setup -- [osd] osd data = /srv/ceph/osd$id osd journal = /srv/ceph/osd$id/journal osd journal size = 512 # stop the OSD: /etc/init.d/ceph osd.0 stop /etc/init.d/ceph osd.1 stop /etc/init.d/ceph osd.2 stop # Flush the journal: ceph-osd -i 0 --flush-journal ceph-osd -i 1 --flush-journal ceph-osd -i 2 --flush-journal # Now update ceph.conf - this is very important or you'll just recreate journal on the same disk again -- change to [filebased journal] -- [osd] osd data = /srv/ceph/osd$id osd journal = /srv/ceph/journal/osd$id/journal osd journal size = 10000 -- change to [partitionbased journal (journal in this case would be on /dev/sda2)] -- [osd] osd data = /srv/ceph/osd$id osd journal = /dev/sda2 osd journal size = 0 # Create new journal on each disk ceph-osd -i 0 --mkjournal ceph-osd -i 1 --mkjournal ceph-osd -i 2 --mkjournal # Done, now start all OSD again /etc/init.d/ceph osd.0 start /etc/init.d/ceph osd.1 start /etc/init.d/ceph osd.2 start
记得将nodown设置回来:
ceph osd unset nodown
8. ceph cache pool
经初步测试,ceph的cache pool性能并不好,有时甚至低于无cache pool时的性能。可以利用flashcache等替代方案来优化ceph的cache。
ceph osd tier add satapool ssdpool ceph osd tier cache-mode ssdpool writeback ceph osd pool set ssdpool hit_set_type bloom ceph osd pool set ssdpool hit_set_count 1 ## In this example 80-85% of the cache pool is equal to 280GB ceph osd pool set ssdpool target_max_bytes $((280*1024*1024*1024)) ceph osd tier set-overlay satapool ssdpool ceph osd pool set ssdpool hit_set_period 300 ceph osd pool set ssdpool cache_min_flush_age 300 # 10 minutes ceph osd pool set ssdpool cache_min_evict_age 1800 # 30 minutes ceph osd pool set ssdpool cache_target_dirty_ratio .4 ceph osd pool set ssdpool cache_target_full_ratio .8
9. 查看运行时配置
ceph --admin-daemon /var/run/ceph/ceph-osd.0.asok config show
10. 查看监控集群状态
ceph health cehp health detail ceph status ceph -s #可以加上--fortmat=json-pretty ceph osd stat ceph osd dump ceph osd tree ceph mon stat ceph quorum_status ceph mon dump ceph mds stat ceph mds dump
11. 查看所有的pool
ceph osd lspools rados lspools
12. 查看kvm和qemu是否支持rbd
qemu-system-x86_64 -drive format=? qemu-img -h | grep rbd
13, 查看特定的pool及其中的文件
rbd ls testpool rbd create testpool/test.img -s 1024 --image-format=2 rbd info testpool/test.img rbd rm testpool/test.img #统计块数 rados -p testpool ls | grep ^rb.0.11a1 | wc -l
#导入并查看文件 rados makepool testpool rados put -p testpool logo.png logo.png ceph osd map testpool logo.png rbd import logo.png testpool/logo.png rbd info testpool/logo.png
14. 挂载/卸载创建的块设备
ceph osd pool create testpool 256 256 rbd create testpool/test.img -s 1024 --image-format=2 rbd map testpool/test.img rbd showmapped mkfs.xfs /dev/rbd0 rbd unmap /dev/rbd0
15. 创建快照
#创建 rbd snap create testpool/test.img@test.img-snap1 #查看 rbd snap ls testpool/test.img #回滚 rbd snap rollback testpool/test.img@test.img-snap1 #删除 rbd snap rm testpool/test.img@test.img-snap1 #清除所有快照 rbd snap purge testpool/test.img
16. 计算合理的pg数
官方建议每OSD50-100个pg。total pgs=osds*100/副本数,例如6osd、2副本的环境,pgs为6*100/2=300
pg数只能增加,无法减少;增加pg_num后必须同时增减pgp_num
17. 对pool的操作
ceph osd pool create testpool 256 256 ceph osd pool delete testpool testpool --yes-i-really-really-mean-it ceph osd pool rename testpool anothertestpool ceph osd pool mksnap testpool testpool-snap
18. 重新安装前的格式化
ceph-deploy purge osd0 osd1 ceph-deploy purgedata osd0 osd1 ceph-deploy forgetkeys ceph-deploy disk zap --fs-type xfs osd0:/dev/sdb1
19. 修改osd journal的存储路径
#noout参数会阻止osd被标记为out,使其权重为0 ceph osd set noout service ceph stop osd.1 ceph-osd -i 1 --flush-journal mount /dev/sdc /journal ceph-osd -i 1 --mkjournal /journal service ceph start osd.1 ceph osd unset noout
20. xfs挂载参数
mkfs.xfs -n size=64k /dev/sdb1 #/etc/fstab挂载参数 rw,noexec,nodev,noatime,nodiratime,nobarrier
21. 认证配置
[global] auth cluser required = none auth service required = none auth client required = none #0.56之前 auth supported = none
22. pg_num不够用,进行迁移和重命名
ceph osd pool create new-pool pg_num rados cppool old-pool new-pool ceph osd pool delete old-pool ceph osd pool rename new-pool old-pool #或者直接增加pool的pg_num
23. 推送config文件
ceph-deploy --overwrite-conf config push mon1 mon2 mon3
24. 在线修改config参数
ceph tell osd.* injectargs '--mon_clock_drift_allowde 1'
使用此命令需要区分配置的参数属于mon、mds还是osd。
到此,相信大家对“Ceph常用的命令总结”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。