{"id":523,"date":"2024-04-25T18:46:59","date_gmt":"2024-04-25T10:46:59","guid":{"rendered":"https:\/\/windywind.tk\/?p=523"},"modified":"2025-02-06T10:58:23","modified_gmt":"2025-02-06T02:58:23","slug":"%e4%bd%bf%e7%94%a8corosync-pacemaker%e5%ae%9e%e7%8e%b0ubuntu-20-04%e4%b8%8a%e7%9a%84ha-cluster","status":"publish","type":"post","link":"https:\/\/windywind.tk\/?p=523","title":{"rendered":"\u4f7f\u7528Corosync\/Pacemaker\u5b9e\u73b0Ubuntu 20.04\u4e0a\u7684HA cluster"},"content":{"rendered":"\n<p><a>1. <\/a><strong>\u6240\u6709<\/strong><strong>\u8282\u70b9\u5b89\u88c5\u8f6f\u4ef6<\/strong><\/p>\n\n\n\n<p>apt install pacemaker corosync pcs<\/p>\n\n\n\n<p><a>2. <\/a><strong>\u5173\u95ed\u9632\u706b\u5899<\/strong><\/p>\n\n\n\n<p>ufw disable<\/p>\n\n\n\n<p><a>3. <\/a><strong>\u6240\u6709<\/strong><strong>\u8282\u70b9\u542f\u52a8<\/strong><strong>pcsd<\/strong><\/p>\n\n\n\n<p>systemctl enable &#8211;now pcsd<\/p>\n\n\n\n<p><a>4. <\/a><strong>\u6240\u6709<\/strong><strong>\u8282\u70b9\u4e3a<\/strong><strong>hacluster<\/strong><strong>\u7528\u6237\u8bbe\u7f6e\u5bc6\u7801\u4e3a<\/strong><strong>supos<\/strong><\/p>\n\n\n\n<p>echo &#8220;hacluster:supos&#8221; |chpasswd hacluster<\/p>\n\n\n\n<p><a>5. <\/a><strong>\u6240\u6709<\/strong><strong>\u8282\u70b9\u7f16\u8f91<\/strong><strong>\/etc\/hosts<\/strong><strong>\uff0c\u8bbe\u7f6e<\/strong><strong>IP<\/strong><strong>\u548c<\/strong><strong>hostname<\/strong><strong>\u6620\u5c04\u5173\u7cfb\uff0c\u6bd4\u5982<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>192.168.31.201 supos-nfs1<br>192.168.31.202 supos-nfs2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><a>6. <\/a><strong><s>\u7f16\u8f91<\/s><\/strong><strong><s>\/etc\/corosync\/corosync.conf<\/s><\/strong><\/p>\n\n\n\n<p><a>7. <\/a><strong>\u5728\u4e00\u4e2a\u8282\u70b9\u4e0a\u64cd\u4f5c\u8282\u70b9\u95f4\u8ba4\u8bc1<\/strong><\/p>\n\n\n\n<p>pcs host auth supos-nfs1 addr=192.168.31.201 supos-nfs2 addr=192.168.31.202 -u hacluster<\/p>\n\n\n\n<p>addr= \u7528\u6765\u6307\u5b9a\u8282\u70b9IP<\/p>\n\n\n\n<p>-u \u6307\u5b9a\u4f7f\u7528\u7684\u7528\u6237\u540d\u4e3ahacluster<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"80\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image.png\" alt=\"\" class=\"wp-image-524\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image.png 1000w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-300x24.png 300w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-768x61.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure>\n\n\n\n<p>\u53ef\u80fd\u4f1a\u6709\u56fe\u4e2d\u7684\u62a5\u9519Error: Unable to synchronize and save known-hosts on nodes: supos-nfs2. \u5efa\u8bae\u68c0\u67e5\u672c\u5730\/var\/lib\/pcsd\/known-hosts\u6587\u4ef6\uff0c\u786e\u4fdd\u5176\u4e2d\u5305\u542b\u4e86\u96c6\u7fa4\u5185\u6240\u6709\u8282\u70b9\uff0c\u5e76\u4e14\u90fd\u6709token\u3002\u7136\u540e\uff0c\u5c06\u8fd9\u4e2a\u6587\u4ef6\u590d\u5236\u5230\u96c6\u7fa4\u5185\u5176\u4ed6\u8282\u70b9\u4e0a\uff0c\u4ee5\u4fdd\u8bc1\u4e92\u76f8\u8ba4\u8bc1\u7684\u6210\u529f\u3002<br>\/var\/lib\/pcsd\/known-hosts\u6587\u4ef6\u5185\u5bb9\u53ef\u80fd\u5982\u4e0b<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"424\" height=\"510\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-1.png\" alt=\"\" class=\"wp-image-525\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-1.png 424w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-1-249x300.png 249w\" sizes=\"(max-width: 424px) 100vw, 424px\" \/><\/a><\/figure>\n\n\n\n<p><a>8. <\/a><strong>\u5728\u4e00\u4e2a\u8282\u70b9\u4e0a\u64cd\u4f5c\u7ec4\u5efa\u96c6\u7fa4<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>\u4e0d\u540c\u7684pcs\u53ef\u80fd\u4f1a\u5728\u7ec4\u5efa\u96c6\u7fa4\u7684\u65f6\u5019\u6709\u4e0d\u540c\u7684\u547d\u4ee4\u8bed\u6cd5\uff0c\u6bd4\u5982\u662f\u5426\u901a\u8fc7&#8211;name\u6307\u5b9a\u96c6\u7fa4\u540d\u79f0\u7b49\u3002<br>pcs &#8211;version\u83b7\u53d6\u5230\u7248\u672c\u4fe1\u606f\uff0c\u6b64\u6b21\u4f7f\u7528\u7684\u662f0.10.4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>pcs cluster setup &#8211;force nfs-cluster supos-nfs1 addr=192.168.31.201 supos-nfs2 addr=192.168.31.202<\/p>\n\n\n\n<p>\u6b64\u5904\u4f7f\u7528\u7684pcs\uff0c\u5728setup\u547d\u4ee4\u540e\u9762\u7684\u7d27\u63a5\u7684\u662f\u96c6\u7fa4\u540d\uff0c\u8001\u7248\u672c\u662f\u901a\u8fc7&#8211;name\u6307\u5b9a\u7684\u3002\u5927\u81f4\u683c\u5f0f\u5982\u4e0b<\/p>\n\n\n\n<p>pcs cluster setup &lt;cluster_name> &lt;node_1_hostname> addr=&lt;node_1_IP> &lt;node_2_hostname> addr=&lt;node_2_IP><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"327\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-2-1024x327.png\" alt=\"\" class=\"wp-image-526\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-2-1024x327.png 1024w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-2-300x96.png 300w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-2-768x245.png 768w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-2.png 1129w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>\u5982\u679c\u9047\u5230\u4e0b\u56fe\u65e0\u6cd5\u89e3\u6790known-hosts\u6587\u4ef6\u7684\u62a5\u9519\uff0c\u53ef\u4ee5\u5c1d\u8bd5pcs cluster destroy\u547d\u4ee4\uff0c\u7136\u540e\u518d\u521b\u5efa\u96c6\u7fa4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"56\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-3-1024x56.png\" alt=\"\" class=\"wp-image-527\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-3-1024x56.png 1024w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-3-300x16.png 300w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-3-768x42.png 768w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-3.png 1086w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>\u5982\u679c\u96c6\u7fa4\u88ab\u6b63\u786e\u7ec4\u5efa\uff0c\u90a3\u4e48\u5728\u5176\u4ed6\u8282\u70b9\u4e0a\u53ef\u4ee5\u770b\u5230\u540c\u6b65\u8fc7\u6765\u7684\/etc\/corosync\/corosync.conf\u548c\/var\/lib\/pcsd\/known-hosts<br>\u5185\u5bb9\u5e94\u8be5\u5982\u4e0b\uff0c\u5305\u542b\u4e86\u6240\u6709node\u4fe1\u606f<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"361\" height=\"534\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-5.png\" alt=\"\" class=\"wp-image-529\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-5.png 361w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-5-203x300.png 203w\" sizes=\"(max-width: 361px) 100vw, 361px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"425\" height=\"512\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-7.png\" alt=\"\" class=\"wp-image-531\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-7.png 425w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-7-249x300.png 249w\" sizes=\"(max-width: 425px) 100vw, 425px\" \/><\/a><\/figure>\n\n\n\n<p><a>9. <\/a><strong>\u5728\u4e00\u4e2a\u8282\u70b9\u4e0a\u542f\u52a8\u96c6\u7fa4\u5185\u6240\u6709\u8282\u70b9<\/strong><\/p>\n\n\n\n<p>pcs cluster start &#8211;all<\/p>\n\n\n\n<p>\u5e76\u8bbe\u7f6e\u670d\u52a1\u5f00\u673a\u81ea\u542f<\/p>\n\n\n\n<p>pcs cluster enable &#8211;all<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"423\" height=\"138\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-8.png\" alt=\"\" class=\"wp-image-532\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-8.png 423w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-8-300x98.png 300w\" sizes=\"(max-width: 423px) 100vw, 423px\" \/><\/a><\/figure>\n\n\n\n<p><a>10. <\/a><strong>\u68c0\u67e5\u96c6\u7fa4\u72b6\u6001<\/strong><\/p>\n\n\n\n<p>pcs status<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"556\" height=\"324\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-9.png\" alt=\"\" class=\"wp-image-533\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-9.png 556w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-9-300x175.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/a><\/figure>\n\n\n\n<p>Node List\u4e2d\uff0c\u6240\u6709\u8282\u70b9\u5747\u5e94\u5904\u4e8eOnline\u72b6\u6001<\/p>\n\n\n\n<p><a>11. <\/a><strong>\u8bbe\u7f6e\u96c6\u7fa4\u5c5e\u6027\uff08\u5177\u4f53\u4f5c\u7528\u672a\u77e5\uff0c\u5f85\u7814\u7a76\uff09<\/strong><\/p>\n\n\n\n<p>pcs property set stonith-enabled=false<br>pcs property set no-quorum-policy=ignore<\/p>\n\n\n\n<p><a>12. <\/a><strong>\u521b\u5efa<\/strong><strong>IPaddr2<\/strong><strong>\u7c7b\u578b\u7684\u6d6e\u52a8<\/strong><strong>IP<\/strong><strong>\u8d44\u6e90<\/strong><\/p>\n\n\n\n<p>pcs resource create floating_ip ocf:heartbeat:IPaddr2 ip=192.168.31.200 cidr_netmask=24 op monitor interval=10s<\/p>\n\n\n\n<p><a>13. <\/a><strong>\u5c06\u8d44\u6e90\u7ed1\u5b9a\u5230<\/strong><strong>nfs-cluster<\/strong><\/p>\n\n\n\n<p>crm configure group nfs-cluster floating_ip<\/p>\n\n\n\n<p>pcs status resources\u67e5\u770b<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"580\" height=\"316\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-10.png\" alt=\"\" class=\"wp-image-534\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-10.png 580w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-10-300x163.png 300w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/a><\/figure>\n\n\n\n<p>\u6b64\u65f6\uff0c\u5e94\u8be5\u53ef\u4ee5\u5728\u4e00\u53f0\u4e0a\u770b\u5230\u6b64\u6d6e\u52a8IP\u3002\u6267\u884cip -4 addr \u53ef\u4ee5\u770b\u5230192.168.31.200\u7684IP\u5730\u5740\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"152\" src=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-11.png\" alt=\"\" class=\"wp-image-535\" srcset=\"https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-11.png 727w, https:\/\/windywind.tk\/wp-content\/uploads\/2024\/04\/image-11-300x63.png 300w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><\/a><\/figure>\n\n\n\n<p>\u6d4b\u8bd5\u8d44\u6e90\uff08VIP\uff09\u662f\u5426\u53ef\u4ee5\u6210\u529f\u6f02\u79fb\u5230\u5176\u4ed6\u8282\u70b9<\/p>\n\n\n\n<p>pcs resource move floating_ip supos-nfs2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u6240\u6709\u8282\u70b9\u5b89\u88c5\u8f6f\u4ef6 apt install pacemaker corosync pcs 2. \u5173\u95ed\u9632\u706b\u5899 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-523","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/windywind.tk\/index.php?rest_route=\/wp\/v2\/posts\/523"}],"collection":[{"href":"https:\/\/windywind.tk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/windywind.tk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/windywind.tk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/windywind.tk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=523"}],"version-history":[{"count":2,"href":"https:\/\/windywind.tk\/index.php?rest_route=\/wp\/v2\/posts\/523\/revisions"}],"predecessor-version":[{"id":564,"href":"https:\/\/windywind.tk\/index.php?rest_route=\/wp\/v2\/posts\/523\/revisions\/564"}],"wp:attachment":[{"href":"https:\/\/windywind.tk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/windywind.tk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/windywind.tk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}