{"id":5851,"date":"2021-12-10T10:03:36","date_gmt":"2021-12-10T02:03:36","guid":{"rendered":"https:\/\/www.gycysygg.icu\/?p=5851"},"modified":"2021-12-17T11:50:35","modified_gmt":"2021-12-17T03:50:35","slug":"keepalived-3","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2021\/12\/10\/keepalived-3\/","title":{"rendered":"keepalived\u90e8\u7f72\u811a\u672c"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\r\n: '\r\n @function: install keepalived\r\n @author: gongguan\r\n @date: 2021-12-10\r\n'\r\nset -e\r\necho \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u5b89\u88c5\u4f9d\u8d56\u5305>>>>>>>>>>>>>>>>>>>>>>\"\r\n#yum install -y gcc* openssl-devel libnl* net-snmp-devel libnfnetlink-devel\r\necho \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u6267\u884c\u89e3\u538b\u547d\u4ee4>>>>>>>>>>>>>>>>>>>>\"\r\ntar -xf keepalived-2.0.0.tar.gz\r\n&#91; $? -eq 0 ] &amp;&amp; echo \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u89e3\u538b\u6210\u529f,\u8fdb\u5165\u8def\u5f84\u6267\u884c\u7f16\u8bd1>>>>>>>>>>>>>\"\r\ncd keepalived-2.0.0\r\n.\/configure --prefix=\/usr\/local\/keepalived\r\necho \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u5b89\u88c5>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\r\nmake &amp;&amp; make install\r\necho \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u590d\u5236keepalived\u542f\u52a8\u6587\u4ef6\u5230\/sbin\u76ee\u5f55\u4e0b>>>>>>>>>>>>>\"\r\ncp -a \/usr\/local\/keepalived\/sbin\/keepalived \/sbin\/\r\necho \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u5c06keepalived\u6587\u4ef6\u590d\u5236\u5230\/etc\/sysconfig\/\u4e2d>>>>>>>>>\"\r\ncp \/usr\/local\/keepalived\/etc\/sysconfig\/keepalived \/etc\/sysconfig\/\r\necho \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u590d\u5236\u6587\u4ef6keepalived.conf\u5230\/etc\/keepalived\/\u76ee\u5f55>>>\"\r\n&#91; ! -d \/etc\/keepalived ] &amp;&amp; mkdir -p \/etc\/keepalived\r\ncp \/usr\/local\/keepalived\/etc\/keepalived\/keepalived.conf \/etc\/keepalived\r\necho \"&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u914d\u7f6e\u670d\u52a1\u542f\u52a8\u6587\u4ef6>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\r\ncat  > \/lib\/systemd\/system\/keepalived.service &lt;&lt; EOF\r\n&#91;Unit]\r\nDescription=LVS and VRRP High Availability Monitor\r\nAfter= network-online.target syslog.target\r\nWants=network-online.target\r\n\r\n&#91;Service]\r\nType=forking\r\nPIDFile=\/var\/run\/keepalived.pid\r\nKillMode=process\r\nEnvironmentFile=\/etc\/sysconfig\/keepalived\r\nExecStart=\/sbin\/keepalived $KEEPALIVED_OPTIONS\r\nExecReload=\/bin\/kill -HUP $MAINPID\r\n\r\n&#91;Install]\r\nWantedBy=multi-user.target\r\nEOF\r\nsystemctl enable keepalived\r\nsystemctl start keepalived\r\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff1a\u4e0a\u9762\u53ea\u662f\u90e8\u7f72\uff0c\u5e76\u6ca1\u914d\u7f6eVIP\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u81ea\u884c\u914d\u7f6eVIP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6ce8\u610f\uff1a\u4e0a\u9762\u53ea\u662f\u90e8\u7f72\uff0c\u5e76\u6ca1\u914d\u7f6eVIP\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u81ea\u884c\u914d\u7f6eVIP<\/p>\n","protected":false},"author":3,"featured_media":5852,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-5851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/5851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5851"}],"version-history":[{"count":1,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/5851\/revisions"}],"predecessor-version":[{"id":5853,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/5851\/revisions\/5853"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/5852"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}