{"id":254078,"date":"2022-10-10T10:02:27","date_gmt":"2022-10-10T02:02:27","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=254078"},"modified":"2022-10-04T11:07:28","modified_gmt":"2022-10-04T03:07:28","slug":"ceph-osd-pool","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ceph-osd-pool.html","title":{"rendered":"Ceph\u96c6\u7fa4\u4e2d\u6307\u5b9aOSD \u521b\u5efa pool"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5982\u4f55\u5229\u7528crush\u6765\u5bf9\u4e0d\u540c\u6570\u636e\u6307\u5b9a\u4e0d\u540c\u8bbe\u5907\u7684osd\u5b58\u50a8\uff0c\u8fd9\u8fb9\u6211\u662f\u7528\u865a\u62df\u673a\u6f14\u793a\uff0c\u6240\u4ee5\u90fd\u662fhdd\uff0c\u8fd9\u8fb9\u5047\u8bbeosd0,2,4\u4e3assd\u8bbe\u5907\uff0cosd 1,3,5\u4e3asata\u8bbe\u5907\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u80cc\u666f<\/strong><\/div>\n

\u5728\u6211\u4eec\u7684ceph\u96c6\u7fa4\u4e2d\uff0c\u53ef\u80fd\u4e0d\u53ea\u6709sata\u76d8\u6216\u8005ssd\u76d8\uff0c\u6709\u4e9b\u65f6\u5019\u670d\u52a1\u5668\u4e0a\u540c\u65f6\u63d2\u4e86ssd\u548csata\u76d8\u7528\u4f5cosd\uff0c\u90a3\u5982\u679c\u6211\u4eec\u6309\u7167\u9ed8\u8ba4\u7684crush\u5206\u5e03\u89c4\u5219\uff0c\u90a3\u4f1a\u4f7f\u6240\u6709pg\u5747\u5206\u5728ssd\u548csata\u76d8\u4e0a\uff0c\u9020\u6210sata\u76d8\u7684\u5b58\u50a8\u7a7a\u95f4\u6d6a\u8d39\u548c\u6574\u4e2aceph\u96c6\u7fa4\u7684\u6027\u80fd\u6d6a\u8d39\uff0c\u5176\u5b9e\u6211\u4eec\u53ef\u4ee5\u6539\u53d8ceph\u7684\u9ed8\u8ba4\u5b58\u50a8\u89c4\u5219\uff0c\u6765\u4f7f\u90a3\u4e9bio\u8981\u6c42\u8f83\u9ad8\u7684\u6570\u636e\u5b58\u50a8\u5728\u7531ssd\u7684osd\u7ec4\u6210\u7684\u5b58\u50a8\u6c60\u4e0a\uff0c\u5c06\u5907\u4efd\u6570\u636e\u6216\u8005\u65f6\u6548\u6027\u8981\u6c42\u4e0d\u9ad8\u7684\u6570\u636e\u5b58\u50a8\u5728\u7531sata\u7684osd\u7ec4\u6210\u7684\u5b58\u50a8\u6c60\u4e0a\uff0c\u65e2\u63d0\u9ad8\u4e86\u6027\u80fd\uff0c\u53c8\u53ef\u4ee5\u51cf\u5c11\u8f83\u5927\u6570\u636e\u91cf\u5b58\u50a8\u7684\u6210\u672c\u3002 <\/p>\n

\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u6f14\u793a\u5982\u4f55\u5229\u7528crush\u6765\u5bf9\u4e0d\u540c\u6570\u636e\u6307\u5b9a\u4e0d\u540c\u8bbe\u5907\u7684osd\u5b58\u50a8\uff0c\u8fd9\u8fb9\u6211\u662f\u7528\u865a\u62df\u673a\u6f14\u793a\uff0c\u6240\u4ee5\u90fd\u662fhdd\uff0c\u8fd9\u8fb9\u5047\u8bbeosd0,2,4\u4e3assd\u8bbe\u5907\uff0cosd 1,3,5\u4e3asata\u8bbe\u5907\u3002<\/p>\n

\u83b7\u53d6\u5f53\u524dcrushmap\u5e76\u53cd\u7f16\u8bd1\u4ed6<\/strong><\/div>\n
\r\nceph osd getcrushmap -o crushmapdump\r\ncrushtool -d crushmapdump -o crushmapdump-decompiled<\/pre>\n

\"\"<\/p>\n

\u7f16\u8f91crushmapdump\u6587\u4ef6\uff0c\u5e76\u5728root default\u914d\u7f6e\u4e4b\u540e\u6dfb\u52a0\u4ee5\u4e0b\u90e8\u5206\uff0c\u5206\u522b\u521b\u5efassd\u548csata\u4e24\u4e2abucket\uff0c\u5c06osd [0,2,4]\u4f5c\u4e3assd bucket\uff0cosd[1,3,5]\u4f5c\u4e3asata bucket\u3002<\/p>\n

\r\nroot ssd {\r\n        id -5\r\n        alg straw\r\n        hash 0\r\n        item osd.0 weight 0.010\r\n        item osd.2 weight 0.010\r\n        item osd.4 weight 0.010\r\n}\r\n\r\nroot sata {\r\n        id -6\r\n        alg straw\r\n        hash 0\r\n        item osd.1 weight 0.010\r\n        item osd.3 weight 0.010\r\n        item osd.5 weight 0.010\r\n}<\/pre>\n
\u521b\u5efacrush rule<\/strong><\/div>\n

crush map\u5305\u542bcrush rule\u7684\u6982\u5ff5\u3002\u6bcf\u4e2a\u6c60\u90fd\u6709\u81ea\u5df1\u7684crush ruleset\u548crule\u3002<\/p>\n

\r\nrule ssd-pool {\r\n        ruleset 1\r\n        type replicated\r\n        min_size 1\r\n        max_size 10\r\n        step take ssd  \r\n        step chooseleaf firstn 0 type osd\r\n        step emit\r\n}\r\nrule sata-pool {\r\n        ruleset 2\r\n        type replicated\r\n        min_size 1\r\n        max_size 10\r\n        step take sata  \r\n        step chooseleaf firstn 0 type osd\r\n        step emit\r\n}<\/pre>\n
\u5728ceph\u6025\u7fa4\u4f17\u7f16\u8bd1\u5e76\u6ce8\u5165\u65b0\u7684crush map\u3002<\/strong><\/div>\n
\r\ncrushtool -c crushmapdump-decompiled -o crushmapdump-compiled \r\nceph osd setcrushmap -i crushmapdump-compiled<\/pre>\n

\u6dfb\u52a0\u4e0b\u5217\u53c2\u6570\u5230ceph.conf\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u9632\u6b62\u4e0b\u6b21\u91cd\u542f\u65f6crush\u6062\u590d\u56de\u9ed8\u8ba4\u914d\u7f6e\u3002<\/p>\n

\r\nosd_crush_update_on_start=false\r\n<\/pre>\n

\u5c06crushmap\u6620\u5c04\u5230ceph\u96c6\u7fa4\u540e\uff0c\u67e5\u770bosd tree\u5206\u5e03\uff0c\u8fd9\u91cc\u7531\u4e8e\u6211\u662f\u865a\u62df\u673a\uff0c\u6240\u4ee5\u6240\u6709\u7684\u78c1\u76d8\u90fd\u662f\u522bhdd,\u8fd9\u70b9\u8bf7\u5ffd\u7565\u3002<\/p>\n

\"\"<\/p>\n

\u521b\u5efa\u5e76\u9a8c\u8bc1ssd-pool\u3002<\/p>\n

\r\nceph osd pool create ssd-pool 8 8\r\n<\/pre>\n

\u67e5\u770bcrush_rule\u4e3a0\u3002<\/p>\n

\"\"<\/p>\n

\u4fee\u6539\u89c4\u5219\u96c6\u4e3a1\uff0c\u628assd-pool\u653e\u5230ssd\u78c1\u76d8\u4e0b\u3002<\/p>\n

ceph osd pool set ssd-pool crush_rule ssd-pool<\/pre>\n

\"\"<\/p>\n

\u53ef\u4ee5\u770b\u5230ssd-pool\u7684\u6c60\u5df2\u7ecf\u4f7f\u7528crush_rule 1\u4e86 \u6211\u4eec\u518d\u521b\u5efasata-pool\u6c60\uff0c\u5e76\u505a\u4e0a\u9762\u64cd\u4f5c\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u770b\u5230sata-pool\u7684\u6c60\u5df2\u7ecf\u4f7f\u7528crush_rule 2\u4e86\u3002<\/p>\n

\"\"<\/p>\n

\u5206\u522b\u5f80\u4e24\u4e2a\u6c60\u91cc\u5199\u5165\u6570\u636e\u6d4b\u8bd5<\/strong><\/div>\n
rados -p  put  <\/file_name><\/object_name><\/pool_name><\/pre>\n

\"\"<\/p>\n

\u73b0\u5728\u9a8c\u8bc1\u5bf9\u8c61\u662f\u5426\u5b58\u50a8\u5728\u6b63\u786e\u7684osd\u4e0a\uff0cssd\u7684osd\u96c6\u5408\u4e3a[0 2 4]\uff0csata\u7684osd\u96c6\u5408\u4e3a[1,3,5]\uff0c\u4e0b\u56fe\u4e0e\u6211\u4eec\u5b9a\u4e49\u7684\u914d\u7f6e\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n

\"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u6211\u4eec\u7684ceph\u96c6\u7fa4\u4e2d\uff0c\u53ef\u80fd\u4e0d\u53ea\u6709sata\u76d8\u6216\u8005ssd\u76d8\uff0c\u6709\u4e9b\u65f6\u5019\u670d\u52a1\u5668\u4e0a\u540c\u65f6\u63d2\u4e86ssd\u548csata\u76d8\u7528\u4f5cosd […]<\/p>\n","protected":false},"author":317,"featured_media":99596,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-254078","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=254078"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254078\/revisions"}],"predecessor-version":[{"id":254087,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254078\/revisions\/254087"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/99596"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=254078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=254078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=254078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}