{"id":1052,"date":"2018-05-29T22:23:41","date_gmt":"2018-05-29T14:23:41","guid":{"rendered":"https:\/\/www.xiaobo.li\/?p=1052"},"modified":"2018-05-29T22:25:59","modified_gmt":"2018-05-29T14:25:59","slug":"ceph-%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/1052","title":{"rendered":"ceph \u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"<p>1\u3001ceph pool\u914d\u7f6e<br \/>\n1 \u521b\u5efapool<br \/>\nceph osd pool create {pool-name} {pg-num} [{pgp-num}]<\/p>\n<p>2 \u67e5\u770bpool<br \/>\nceph osd lspools<\/p>\n<p>3 \u8bbe\u7f6epool\u7684\u6307\u6807pool\u6c60\u4e2d\u6700\u5927\u5b58\u50a8\u5bf9\u8c61\u6570\u6216\u6700\u5927\u5b58\u50a8\u5b57\u8282\u6570 \u6709\u5176\u4e00\u5373\u53ef<br \/>\nceph osd pool set-quota {pool-name} [max_objects{obj-count}] [max_bytes {bytes}]<\/p>\n<p>4 \u91cd\u547d\u540dpool<br \/>\nceph osd pool rename {current-pool-name} {new-pool-name}<\/p>\n<p>5 \u67e5\u770bpool\u7684\u72b6\u6001<br \/>\nrsdosdf<\/p>\n<p>6 \u7ed9pool\u5236\u4f5c\u5feb\u7167<br \/>\nceph osd pool mksnap {pool-name} {snap-name}<\/p>\n<p>7 \u5220\u9664pool\u7684\u5feb\u7167<br \/>\nceph osd pool rmsnap {pool-name} {snap-name}<\/p>\n<p>8 \u5220\u9664\u4e00\u4e2apool<br \/>\nceph osd pool delete {pool-name} [{pool-name} --yes-i-really-really-mean-it]<\/p>\n<p>2\u3001ceph pg\u914d\u7f6e<br \/>\n1 \u8bbe\u7f6epool \u4e2d pgs \u7684\u5927\u5c0f<br \/>\nceph osd poolset {pool-name} pg_num<\/p>\n<p>2 \u83b7\u5f97 pool \u4e2d pgs \u7684\u5927\u5c0f<br \/>\nceph osd pool get {pool-name} pg_num<\/p>\n<p>3 \u8bbe\u7f6e pool \u4e2d pgs \u7ec4\u7684\u5927\u5c0f<br \/>\nceph osd poolset {pool-name} pgp_num<\/p>\n<p>4 \u83b7\u5f97 pool \u4e2d pgs \u7ec4\u7684\u5927\u5c0f<br \/>\nceph osd poolget {pool-name} pgp_num<\/p>\n<p>5 \u67e5\u770b\u96c6\u7fa4\u4e2d pgs \u7684\u72b6\u6001<br \/>\nceph pg dump<\/p>\n<p>6 \u67e5\u770b\u6307\u5b9apg \u7684 map<br \/>\nceph pg map{pg-id}<\/p>\n<p>7 \u67e5\u770b\u6307\u5b9apg \u7684\u72b6\u6001<br \/>\nceph pg {pg-id}query<\/p>\n<p>8 \u6e05\u9664\u4e00\u4e2a pg<br \/>\nceph pg scrub{pg-id}<\/p>\n<p>3\u3001ceph\u955c\u50cf\u914d\u7f6e<br \/>\n1 \u67e5\u770b\u66f4\u65b0Linux\u5185\u6838\u7248\u672c\uff0c<\/p>\n<p>\u9700\u76f8\u5e94Linux\u5185\u6838\u652f\u6301modproberbd \u67e5\u770b\uff1auname \u2013r<\/p>\n<p>\u82e5\u4e0d\u652f\u6301\uff1a<br \/>\n\u6267\u884c\u4e0b\u8ff0\u64cd\u4f5c\uff1a<\/p>\n<p>sudo rpm --import https:\/\/www.elrepo.org\/RPM-GPG-KEY-elrepo.org<br \/>\nsudo rpm -Uvh http:\/\/www.elrepo.org\/elrepo-release-7.0-2.el7.elrepo.noarch.rpm<br \/>\nsudo yum --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel<\/p>\n<p>\u6539\u4e3a\u65b0\u5185\u6838\uff1a<br \/>\nsudo grub2-set-default 'CentOS Linux (4.4.0-1.el7.elrepo.x86_64) 7 (Core)'<br \/>\ngrub2-editenv list \u67e5\u770b\u4fee\u6539<\/p>\n<p>\u6700\u7ec8\u66f4\u65b0\u8bbe\u7f6e\u5185\u6838\uff1a<br \/>\nsudo grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/p>\n<p>2 \u521b\u5efa\u4e00\u4e2a\u8bbe\u5907\u7684\u955c\u50cf\uff0csize\u4ee5M\u4e3a\u5355\u4f4d<br \/>\nrbd create{image-name} --size {megabytes} \u2013pool {pool-name}<\/p>\n<p>\u5982\uff1a<br \/>\nrbd createtestImage --size 512 --pool testPool<\/p>\n<p>3 \u5217\u51fa\u4e00\u4e2a pool \u91cc\u9762\u7684\u5757\u8bbe\u5907\uff0c\u5373\u521b\u5efa\u7684\u955c\u50cf<br \/>\nrbd list{pool-name}<\/p>\n<p>4 \u8bfb\u51fa\u4e00\u4e2a\u955c\u50cf\u91cc\u9762\u7684\u4fe1\u606f<br \/>\nrbd --image{image-name} -p {pool-name} info<\/p>\n<p>5 \u91cd\u65b0\u4fee\u6539\u955c\u50cf\u7684\u5927\u5c0f<br \/>\nrbd resize--image {image-name} \u2013p {pool-name} --size 1024<\/p>\n<p>6 \u5c06\u5757\u8bbe\u5907\u6620\u5c04\u5230\u672c\u5730<br \/>\n1 sudomodprobe rbd<br \/>\n2 sudo rbd map{image-name} --pool {pool-name}<\/p>\n<p>7 \u663e\u793a\u6620\u5c04\u7684\u6a21\u5757<br \/>\nrbd showmapped<\/p>\n<p>8 \u4ece\u4e00\u4e2a\u5177\u4f53\u7684 pool \u4e2d\u5220\u9664\u4e00\u4e2a\u5757\u8bbe\u5907<br \/>\nrbd rm {image-name} -p{pool-name}<\/p>\n<p>9 \u53d6\u6d88\u5757\u8bbe\u5907\u7684\u6620\u5c04<br \/>\nsudo rbdunmap \/dev\/rbd\/{poolname}\/{imagename}<\/p>\n<p>4\u3001ceph\u5feb\u7167\u914d\u7f6e<br \/>\n1 \u521b\u5efa\u5feb\u7167<\/p>\n<p>1 \u7ed9\u955c\u50cf\u521b\u5efa\u4e00\u4e2a\u5feb\u7167<br \/>\nrbd snap create {pool-name}\/{image-name}@{snap-name}<\/p>\n<p>2 \u5217\u51fa\u4e00\u4e2a\u955c\u50cf\u7684\u6240\u6709\u5feb\u7167<br \/>\nrbd snap ls {pool-name}\/{image-name}<\/p>\n<p>3 \u5feb\u7167\u56de\u6eda<br \/>\nrbd snap rollback {pool-name}\/{image-name}@{snap-name}<\/p>\n<p>4 \u5220\u9664\u5feb\u7167<br \/>\nrbd snap rm {pool-name}\/{image-name}@{snap-name}<\/p>\n<p>5 \u5220\u9664\u4e00\u4e2a\u955c\u50cf\u7684\u5168\u90e8\u5feb\u7167<br \/>\nrbd snap purge{pool-name}\/{image-name}<\/p>\n<p>2 \u5206\u5c42\u5feb\u7167<\/p>\n<p>1 \u9996\u5148\u521b\u5efa\u4e00\u4e2a\u7279\u6b8a\u683c\u5f0f\u7684\u7684\u955c\u50cf\uff0c\u683c\u5f0f\u8981\u6c42\uff1aformat 2<br \/>\nrbd create --image-format 2 {image-name}--size { megabytes } --pool {pool-name}<\/p>\n<p>2 \u521b\u5efa\u5feb\u7167<br \/>\nrbd snap create {pool-name}\/{image-name}@{snap-name}<\/p>\n<p>3 \u514b\u9686\u54c1\u8bbf\u95ee\u7236\u5feb\u7167\u3002\u7236\u5feb\u7167\uff0c\u6240\u6709\u514b\u9686\u54c1\u90fd\u4f1a\u635f\u574f\u3002\u4e3a\u9632\u6b62\u6570\u636e\u4e22\u5931\uff0c\u5fc5\u987b\u5148\u4fdd\u62a4\u3001\u7136\u540e\u518d\u514b\u9686\u5feb\u7167\u3002<\/p>\n<p>rbd snap protect {pool-name}\/{image-name}@{snapshot-name}<br \/>\n$ rbd clone rbd\/testImage2@test2Snap rbd\/testImage3<\/p>\n<p>4 \u514b\u9686\u5feb\u7167\uff0c\u5c06\u4e00\u4e2a\u5b58\u50a8\u6c60\u4e2d\u7684\u955c\u50cf\u7684\u5feb\u7167\u514b\u9686\u5230\u53e6\u4e00\u5b58\u50a8\u6c60\u4e2d\uff0c\u6210\u4e3a\u4e00\u4e2a\u955c\u50cf<br \/>\nrbd clone {pool-name}\/{parent-image}@{snap-name} {pool-name}\/{child-image-name}<\/p>\n<p>5 \u5220\u9664\u5feb\u7167<\/p>\n<p>1] \u5220\u9664\u65b9\u5f0f\u4e00\uff1a<br \/>\n\u5220\u9664\u6240\u6709\u5feb\u7167 \u53d6\u6d88\u5feb\u7167\u4fdd\u62a4 \u5220\u9664\u5feb\u7167<\/p>\n<p>2] \u5220\u9664\u65b9\u5f0f\u4e8c\uff1a<br \/>\n\u9996\u5148\u5c06\u514b\u9686\u54c1\u538b\u7f29 \u89e3\u9664\u4fdd\u62a4 \u5220\u9664\u5feb\u7167<\/p>\n<p>6 \u53d6\u6d88\u5feb\u7167\u4fdd\u62a4<br \/>\nrbd snapunprotect {pool-name}\/{image-name}@{snapshot-name}<\/p>\n<p>7 \u5217\u51fa\u4e00\u5757\u955c\u50cf\u7684\u5b50\u5b59<br \/>\nrbd children {pool-name}\/{image-name}@{snapshot-name}<\/p>\n<p>8 \u514b\u9686\u955c\u50cf\u538b\u7f29\uff0c\u8fdb\u800c\u6d88\u9664\u7236\u5feb\u7167\u7684\u5f15\u7528<br \/>\nrbd flatten {pool-name}\/{imag<\/p>\n<p>5\u3001ceph qemu\u914d\u7f6e<br \/>\n1 \u4f7f\u7528 qemu \u521b\u5efa\u955c\u50cf<br \/>\nqemu-img create-f raw rbd:{pool-name}\/{image-name} {size}<br \/>\n\u4f8b\u5982\uff1a qemu-img create -f raw rbd:testPool\/testImage0 1G<\/p>\n<p>2 \u8c03\u6574 qemu \u955c\u50cf\u7684\u5927\u5c0f<br \/>\nqemu-img resizerbd:{pool-name}\/{image-name} {size}<\/p>\n<p>3 \u67e5\u770b\u4e00\u4e2a qemu \u955c\u50cf\u5c5e\u6027\u4fe1\u606f<br \/>\nqemu-img inforbd:{pool-name}\/{image-name}<\/p>\n<p>4 \u8f6c\u6362 qemu \u5176\u4ed6\u683c\u5f0f\u7684\u955c\u50cf\u4e3a\u5757\u8bbe\u5907\u955c\u50cf<br \/>\nqemu-img convert-p -f \u6e90\u955c\u50cf-O \u76ee\u6807\u955c\u50cf\u683c\u5f0f\u6587\u4ef6<br \/>\nrbd:poolname\/imagename\u8f6c\u6362\u540e\u7684\u6587\u4ef6<\/p>\n<p>5 \u8fd0\u884c\u955c\u50cf\u4e2d\u7684\u865a\u62df\u673a<br \/>\nqemu -m \u5185\u5b58\u5927\u5c0f -driveformat=raw,file=rbd:poolname\/imagename<\/p>\n<p>6 qemu \u7684\u5e26\u7f13\u5b58\u63a7\u5236<\/p>\n<p>1 qemu -m1024 -drive format=rbd,file=rbd:poolname\/imagename,cache=writeback<br \/>\n2 qemu \u2013m 1024 \\<br \/>\n-driveformat=raw,file=rbd:poolname\/imagename:rbd_cache=true,cache=writeback<\/p>\n<p>\u6ce8\uff1a\u5982\u82e5\u8bbe\u7f6e\u4e86rbd_cache=ture\u90a3\u4e48\u5fc5\u987b\u8bbe\u7f6ecache=writeback\u6216\u8005risk data loss \u5426\u5219\u7684\u8bdd\uff0cqemu\u5c06\u4e0d\u4f1a\u53d1\u9001\u8bf7\u6c42\u7ed9librbd\u5982\u679cqemu\u6ca1\u6709\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6307\u5b9a\u6e05\u695a\uff0c\u90a3\u4e48\u57fa\u4e8erbd\u7684\u4e0a\u5c42\u6587\u4ef6\u7cfb\u7edf\u53ef\u80fd\u80fd\u88ab\u635f\u574f<\/p>\n<p>7 qemu \u7f13\u51b2\u64cd\u4f5c<\/p>\n<p>\u56de\u5199\uff1a<br \/>\nrbd_cache = true<br \/>\n\u76f4\u5199\uff1a<br \/>\nrbd_cache = ture<br \/>\nrbd_cache_max_dirty = 0<br \/>\n\u65e0\uff1a<br \/>\nrbd_cache = false<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001ceph pool\u914d\u7f6e 1 \u521b\u5efapool ceph osd pool cre &hellip; <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/1052\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[292],"tags":[264],"class_list":["post-1052","post","type-post","status-publish","format-standard","hentry","category-storage","tag-ceph"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/1052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=1052"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/1052\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=1052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=1052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=1052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}