{"id":3592,"date":"2020-07-22T17:25:18","date_gmt":"2020-07-22T09:25:18","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=3592"},"modified":"2020-07-22T17:43:45","modified_gmt":"2020-07-22T09:43:45","slug":"haproxy-%e5%90%af%e5%8a%a8%e5%a4%b1%e8%b4%a5%e9%97%ae%e9%a2%98%e5%bd%92%e7%ba%b3","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=3592","title":{"rendered":"haproxy \u542f\u52a8\u5931\u8d25\u95ee\u9898\u5f52\u7eb3"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>\u5728\u5b89\u88c5\u3001\u5347\u7ea7\u3001\u5378\u8f7d\u91cd\u88c5 TDH\uff0c\u6216\u8005\u670d\u52a1\u5668\u7cfb\u7edf\u6253\u8865\u4e01\u6216\u5347\u7ea7\u7b49\u573a\u666f\u4e0b\uff0c\u91cd\u542f TOS \u65f6\u4f1a\u9047\u5230\u542f\u52a8\u5931\u8d25\u7684\u95ee\u9898\u3002\u68c0\u67e5\u542f\u52a8\u9875\u9762\u7684\u62a5\u9519\u8be6\u7ec6\u4fe1\u606f\u4f1a\u53d1\u73b0\u662f haproxy \u542f\u52a8\u5931\u8d25\uff0c\u672c\u6587\u5c31\u6765\u5bf9\u51e0\u7c7b\u9519\u8bef\u8fdb\u884c\u5f52\u7eb3\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<h4>TDH \u5347\u7ea7\u3001\u5378\u8f7d\u91cd\u88c5\u65f6 TOS \u542f\u52a8\u5931\u8d25<\/h4>\n<p>\u8be5\u7c7b\u573a\u666f\u4e0b\uff0c\u542f\u52a8 TOS \u76f8\u5173\u89d2\u8272\u65f6\u5931\u8d25\uff0c<code>systemctl status haproxy<\/code> \u6216 <code>journalctl -u haproxy | egrep -i &quot;fail|error&quot;<\/code> \u51fa\u73b0\u5982\u4e0b\u7c7b\u4f3c\u9519\u8bef\uff1a<\/p>\n<pre><code>--\nFailed at step EXEC spawning \/usr\/sbin\/haproxy-systemd-wrapper:No such file or directory\n--<\/code><\/pre>\n<p><strong>\u5206\u6790<\/strong>\uff1a\u8be5\u95ee\u9898\u53ef\u80fd\u662f\u5b89\u88c5\u65f6\u7f3a\u5931\u6587\u4ef6\u5bfc\u81f4<\/p>\n<p><strong>\u89e3\u51b3<\/strong>\uff1a\u4ee5 Centos7 \u4e3a\u4f8b\uff0c\u53ef\u7528\u5982\u4e0b\u65b9\u6cd5\u89e3\u51b3<\/p>\n<pre><code># \u5907\u4efd haproxy.service \u6587\u4ef6\n[root@amen01-7 ~]# mv \/usr\/lib\/systemd\/system\/haproxy.service{,.rpmsave} \n\n# \u91cd\u88c5 haproxy\n[root@amen01-7 ~]# yum erase -y haproxy && yum install -y haproxy\n\n# \u628a\u5907\u4efd\u597d\u7684 haproxy.service \u8fd8\u539f\n[root@amen01-7 ~]# mv -f \/usr\/lib\/systemd\/system\/haproxy.service.rpmsave \/usr\/lib\/systemd\/system\/haproxy.service \n\n# \u91cd\u542f haproxy\n[root@amen01-7 ~]# systemctl daemon-reload && systemctl restart haproxy && systemctl enable haproxy<\/code><\/pre>\n<p><\/br><\/p>\n<h4>\u670d\u52a1\u5668\u7cfb\u7edf\u6253\u8865\u4e01\u6216\u5347\u7ea7\u540e\uff0cTOS \u542f\u52a8\u5931\u8d25<\/h4>\n<p>\u8be5\u7c7b\u573a\u666f\u4e0b\u542f\u52a8 TOS \u76f8\u5173\u89d2\u8272\u65f6\uff0cTOS slave \u80fd\u542f\u52a8\u6210\u529f\uff0c\u4f46\u662f\u5176\u4f59 TOS \u89d2\u8272\u542f\u52a8\u5931\u8d25\uff0c\u6392\u67e5\u7ebf\u7d22\u5982\u4e0b\uff1a<\/p>\n<pre><code># K8s \u8fde\u63a5 apiserver \u88ab\u62d2\n[root@amen01-7 ~]# kubectl get po -n kube-system\nThe connection to the server 127.0.0.1:6443 was refused - did you specify the right host or port?\n\n# \u67e5\u770b 6443 \u7aef\u53e3\u6ca1\u5728\u76d1\u542c\n[root@amen01-7 ~]# ss -lanp | egrep 6443 | grep -i listen\n[root@amen01-7 ~]# \n\n# \u67e5\u770b haproxy \u72b6\u6001\u6b63\u5e38 running\n[root@amen01-7 ~]# systemctl status haproxy.service \n\u25cf haproxy.service - HAProxy Load Balancer\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/haproxy.service; enabled; vendor preset: disabled)\n   Active: active (running) since Wed 2020-07-22 16:47:57 CST; 12min ago\n--<\/code><\/pre>\n<p>\u4f46\u53ef\u4ee5\u770b\u5230 haproxy \u7684\u542f\u52a8\u53c2\u6570\u91cc\u7684\u5f02\u5e38\u5982\u4e0b\u56fe\uff0c\u8def\u5f84\u4e0d\u5bf9\uff1a<br \/>\n<img decoding=\"async\" src=\"\/.\/wp-content\/uploads\/2020\/07\/image-1595408701357.png\" alt=\"file\" \/><\/p>\n<p>\u6b63\u5e38 TOS \u7684 haproxy \u89d2\u8272\u8be5\u542f\u52a8\u53c2\u6570\u5e94\u4e3a\uff1a<code>\/etc\/tos\/conf\/haproxy.cfg<\/code><\/p>\n<p><strong>\u89e3\u51b3<\/strong>\uff1a <\/p>\n<ul>\n<li>\n<p>\u4fee\u6539 <code>\/usr\/lib\/systemd\/system\/haproxy.service<\/code>\uff0c\u6216\u8005\u4ece\u6b63\u5e38\u8282\u70b9\u62f7\u8d1d\u4e00\u4e2a\u5230\u6709\u95ee\u9898\u7684\u8282\u70b9\u3002<br \/>\n<img decoding=\"async\" src=\"\/.\/wp-content\/uploads\/2020\/07\/image-1595409287347.png\" alt=\"file\" \/><\/p>\n<\/li>\n<li>\n<p>\u91cd\u542f haproxy\uff0c\u4ee5 Centos7 \u4e3a\u4f8b\uff0c\u53ef\u4ee5\u770b\u5230 6443 \u7aef\u53e3\u5df2\u7ecf\u5904\u4e8e LISTEN \u72b6\u6001\uff0c\u7136\u540e\u518d\u91cd\u8bd5\u542f\u52a8 TOS<\/p>\n<pre><code>[root@amen01-7 ~]# systemctl daemon-reload && systemctl restart haproxy && ss -lanp | egrep 6443 | grep -i listen\ntcp    LISTEN     0      1024      *:6443                  *:* <\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u5728\u5b89\u88c5\u3001\u5347\u7ea7\u3001\u5378\u8f7d\u91cd\u88c5 TDH\uff0c\u6216\u8005\u670d\u52a1\u5668\u7cfb\u7edf\u6253\u8865\u4e01\u6216\u5347\u7ea7\u7b49\u573a\u666f\u4e0b\uff0c\u91cd\u542f TOS \u65f6\u4f1a\u9047\u5230\u542f\u52a8\u5931\u8d25\u7684 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=3592\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,44,35,33,43],"tags":[98,125],"class_list":["post-3592","post","type-post","status-publish","format-standard","hentry","category-install","category-start_failed","category-upgrade","category-installation","category-service_abnormal","tag-tos","tag-haproxy"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/3592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3592"}],"version-history":[{"count":1,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/3592\/revisions"}],"predecessor-version":[{"id":3599,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/3592\/revisions\/3599"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}