{"id":51881,"date":"2024-12-03T08:49:23","date_gmt":"2024-12-03T00:49:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/51881\/"},"modified":"2024-12-03T08:49:23","modified_gmt":"2024-12-03T00:49:23","slug":"%e5%9c%a8linux%e4%b8%8a%e5%ae%9e%e7%8e%b0%e9%ab%98%e5%8f%af%e7%94%a8%e8%99%9a%e6%8b%9f%e5%8c%96%e5%ad%98%e5%82%a8%e7%9a%84%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/51881\/","title":{"rendered":"\u5728Linux\u4e0a\u5b9e\u73b0\u9ad8\u53ef\u7528\u865a\u62df\u5316\u5b58\u50a8\u7684\u914d\u7f6e\u6307\u5357"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5728Linux\u4e0a\u5b9e\u73b0\u9ad8\u53ef\u7528\u865a\u62df\u5316\u5b58\u50a8\u7684\u914d\u7f6e\u6307\u5357<\/h1>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300a\u5728Linux\u4e0a\u5b9e\u73b0\u9ad8\u53ef\u7528\u865a\u62df\u5316\u5b58\u50a8\u7684\u914d\u7f6e\u6307\u5357\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01<\/p>\n<p>\u5982\u4f55\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\uff08\u5982Ceph\uff09<\/p>\n<p>\u5f15\u8a00\uff1a<br \/>\u5728\u73b0\u4ee3\u7684\u4e91\u8ba1\u7b97\u73af\u5883\u4e2d\uff0c\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002Ceph\u662f\u4e00\u79cd\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u5b58\u50a8\u7cfb\u7edf\uff0c\u5b83\u80fd\u591f\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u53ef\u4f38\u7f29\u6027\uff0c\u800c\u4e14\u5728\u865a\u62df\u5316\u73af\u5883\u4e2d\u5f97\u5230\u4e86\u5e7f\u6cdb\u5e94\u7528\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\uff0c\u5e76\u63d0\u4f9b\u76f8\u5173\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<p>\u7b2c\u4e00\u90e8\u5206\uff1aCeph\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5Ceph<br \/>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5Ceph\uff1a<\/p>\n<pre>sudo apt-get install ceph<\/pre>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u914d\u7f6eCeph\u96c6\u7fa4<br \/>\u7f16\u8f91<code>\/etc\/ceph\/ceph.conf<\/code>\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>[global]\nfsid = &lt;fsid&gt;\nmon initial members = &lt;mon-node1&gt;, &lt;mon-node2&gt;, &lt;mon-node3&gt;\nmon host = &lt;ip-node1&gt;, &lt;ip-node2&gt;, &lt;ip-node3&gt;\n\n[osd]\nosd journal size = 1024\n\n[mon]\nmon data = \/var\/lib\/ceph\/mon\/$cluster-$id\nmon initial members = &lt;mon-node1&gt;, &lt;mon-node2&gt;, &lt;mon-node3&gt;\n\n[mds]\nmds data = \/var\/lib\/ceph\/mds\/$cluster-$id<\/pre>\n<p>\u66ff\u6362<code>&lt;fsid&gt;<\/code>\u3001<code>&lt;mon-node1&gt;<\/code>\u3001<code>&lt;mon-node2&gt;<\/code>\u3001<code>&lt;mon-node3&gt;<\/code>\u3001<code>&lt;ip-node1&gt;<\/code>\u3001<code>&lt;ip-node2&gt;<\/code>\u548c<code>&lt;ip-node3&gt;<\/code>\u4e3a\u76f8\u5e94\u7684\u503c\u3002\u8fd9\u4e9b\u503c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u7684\u73af\u5883\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u542f\u52a8Ceph\u96c6\u7fa4<br \/>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u542f\u52a8Ceph\u96c6\u7fa4\uff1a<\/p>\n<pre>sudo systemctl start ceph-mon.target\nsudo systemctl start ceph-osd.target\nsudo systemctl start ceph-mds.target<\/pre>\n<p>\u7b2c\u4e8c\u90e8\u5206\uff1a\u914d\u7f6e\u9ad8\u53ef\u7528\u6027<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5Corosync\u548cPacemaker<br \/>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5Corosync\u548cPacemaker\uff1a<\/p>\n<pre>sudo apt-get install corosync pacemaker<\/pre>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u914d\u7f6eCorosync<br \/>\u7f16\u8f91<code>\/etc\/corosync\/corosync.conf<\/code>\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>totem {\n        cluster_name: &lt;cluster-name&gt;\n        token: &lt;token&gt;\n        secauth: off\n        transport: udpu\n        interface {\n                ringnumber: 0\n                bindnetaddr: &lt;ip-node1&gt;\n                mcastaddr: &lt;mcast-addr&gt;\n                mcastport: &lt;mcast-port&gt;\n        }\n        interface {\n                ringnumber: 1\n                bindnetaddr: &lt;ip-node2&gt;\n                mcastaddr: &lt;mcast-addr&gt;\n                mcastport: &lt;mcast-port&gt;\n        }\n        interface {\n                ringnumber: 2\n                bindnetaddr: &lt;ip-node3&gt;\n                mcastaddr: &lt;mcast-addr&gt;\n                mcastport: &lt;mcast-port&gt;\n        }\n}\n\nquorum {\n        provider: corosync_votequorum\n        expected_votes: &lt;num-nodes&gt;\n        two_node: 1\n}\n\nnodelist {\n        node {\n                ring0_addr: &lt;ip-node1&gt;\n                nodeid: 1\n        }\n        node {\n                ring0_addr: &lt;ip-node2&gt;\n                nodeid: 2\n        }\n        node {\n                ring0_addr: &lt;ip-node3&gt;\n                nodeid: 3\n        }\n}<\/pre>\n<p>\u66ff\u6362<code>&lt;cluster-name&gt;<\/code>\u3001<code>&lt;token&gt;<\/code>\u3001<code>&lt;ip-node1&gt;<\/code>\u3001<code>&lt;ip-node2&gt;<\/code>\u3001<code>&lt;ip-node3&gt;<\/code>\u3001<code>&lt;mcast-addr&gt;<\/code>\u3001<code>&lt;mcast-port&gt;<\/code>\u548c<code>&lt;num-nodes&gt;<\/code>\u4e3a\u76f8\u5e94\u7684\u503c\u3002<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u542f\u52a8Corosync\u548cPacemaker<br \/>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u542f\u52a8Corosync\u548cPacemaker\uff1a<\/p>\n<pre>sudo systemctl enable corosync\nsudo systemctl enable pacemaker\nsudo systemctl start corosync\nsudo systemctl start pacemaker<\/pre>\n<p>\u7b2c\u56db\u6b65\uff1a\u914d\u7f6eCeph\u8d44\u6e90<br \/>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u914d\u7f6eCeph\u8d44\u6e90\uff1a<\/p>\n<pre>sudo pcs resource create ceph_mon ocf:ceph:mon \n--params mon_name=mon \nop monitor interval=10s\n\nsudo pcs resource create ceph_osd ocf:ceph:osd \n--params osd_device=\/dev\/sdb \nop start timeout=90s \nop stop timeout=90s \nop monitor interval=10s\n\nsudo pcs resource create ceph_mds ocf:ceph:mds \n--params mds_name=mds \nop monitor interval=10s<\/pre>\n<p>\u8fd9\u4e9b\u547d\u4ee4\u5c06\u521b\u5efaCeph\u7684mon\u3001osd\u548cmds\u8d44\u6e90\uff0c\u5e76\u6307\u5b9a\u4e00\u4e9b\u53c2\u6570\u3002<\/p>\n<p>\u7ed3\u8bba\uff1a<br \/>\u4ee5\u4e0a\u5c31\u662f\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\u7684\u65b9\u6cd5\u3002\u901a\u8fc7\u4f7f\u7528Ceph\u548cCorosync-Pacemaker\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5b9e\u73b0\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\u73af\u5883\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u8bfb\u8005\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\u63d0\u4f9b\u4e00\u4e9b\u5e2e\u52a9\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li>Ceph\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/docs.ceph.com\/<\/li>\n<li>Corosync\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/corosync.github.io\/corosync-docs\/index.html<\/li>\n<li>Pacemaker\u5b98\u65b9\u6587\u6863\uff1ahttp:\/\/clusterlabs.org\/<\/li>\n<li>Linux\u72b6\u6001\u7ba1\u7406\u5668\u4f7f\u7528\u6307\u5357\uff1ahttps:\/\/access.redhat.com\/documentation\/en-us\/red_hat_enterprise_linux\/7\/html\/high_availability_add-on_reference\/<\/li>\n<li>Linux\u96c6\u7fa4\u5305\u6307\u5357\uff1ahttps:\/\/access.redhat.com\/documentation\/en-us\/red_hat_enterprise_linux\/7\/html\/high_availability_add-on_guide\/<\/li>\n<\/ul>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300a\u5728Linux\u4e0a\u5b9e\u73b0\u9ad8\u53ef\u7528\u865a\u62df\u5316\u5b58\u50a8\u7684\u914d\u7f6e\u6307\u5357\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u5427\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   UniApp\u8bed\u97f3\u8bc6\u522b\u548c\u8bed\u97f3\u5408\u6210\u7684\u5b9e\u73b0\u6280\u5de7\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Linux\u4e0a\u5b9e\u73b0\u9ad8\u53ef\u7528\u865a\u62df\u5316\u5b58\u50a8\u7684\u914d\u7f6e\u6307\u5357 \u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300a\u5728Linux\u4e0a\u5b9e\u73b0\u9ad8\u53ef\u7528\u865a\u62df\u5316\u5b58\u50a8\u7684\u914d\u7f6e\u6307\u5357\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01 \u5982\u4f55\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\uff08\u5982Ceph\uff09 \u5f15\u8a00\uff1a\u5728\u73b0\u4ee3\u7684\u4e91\u8ba1\u7b97\u73af\u5883\u4e2d\uff0c\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002Ceph\u662f\u4e00\u79cd\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u5b58\u50a8\u7cfb\u7edf\uff0c\u5b83\u80fd\u591f\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u53ef\u4f38\u7f29\u6027\uff0c\u800c\u4e14\u5728\u865a\u62df\u5316\u73af\u5883\u4e2d\u5f97\u5230\u4e86\u5e7f\u6cdb\u5e94\u7528\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u7684\u865a\u62df\u5316\u5b58\u50a8\uff0c\u5e76\u63d0\u4f9b\u76f8\u5173\u4ee3\u7801\u793a\u4f8b\u3002 \u7b2c\u4e00\u90e8\u5206\uff1aCeph\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e \u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5Ceph\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5Ceph\uff1a sudo apt-get install ceph \u7b2c\u4e8c\u6b65\uff1a\u914d\u7f6eCeph\u96c6\u7fa4\u7f16\u8f91\/etc\/ceph\/ceph.conf\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a [global] fsid = &lt;fsid&gt; mon initial members = &lt;mon-node1&gt;, &lt;mon-node2&gt;, &lt;mon-node3&gt; mon host = &lt;ip-node1&gt;, &lt;ip-node2&gt;, &lt;ip-node3&gt; [osd] osd journal size = 1024 [mon] mon data = \/var\/lib\/ceph\/mon\/$cluster-$id mon initial members = &lt;mon-node1&gt;, &lt;mon-node2&gt;, &lt;mon-node3&gt; [mds] mds data = \/var\/lib\/ceph\/mds\/$cluster-$id \u66ff\u6362&lt;fsid&gt;\u3001&lt;mon-node1&gt;\u3001&lt;mon-node2&gt;\u3001&lt;mon-node3&gt;\u3001&lt;ip-node1&gt;\u3001&lt;ip-node2&gt;\u548c&lt;ip-node3&gt;\u4e3a\u76f8\u5e94\u7684\u503c\u3002\u8fd9\u4e9b\u503c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u7684\u73af\u5883\u8fdb\u884c\u8bbe\u7f6e\u3002 \u7b2c\u4e09\u6b65\uff1a\u542f\u52a8Ceph\u96c6\u7fa4\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u542f\u52a8Ceph\u96c6\u7fa4\uff1a sudo systemctl [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-51881","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/51881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=51881"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/51881\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=51881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=51881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=51881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}