{"id":29,"date":"2016-03-23T01:56:58","date_gmt":"2016-03-22T22:56:58","guid":{"rendered":"https:\/\/qwertys.ru\/?p=29"},"modified":"2016-09-02T19:47:23","modified_gmt":"2016-09-02T16:47:23","slug":"%d1%80%d0%b0%d0%b7%d0%b1%d0%b8%d0%b5%d0%bd%d0%b8%d0%b5-haproxy-cnf-%d0%bd%d0%b0-%d1%84%d0%b0%d0%b9%d0%bb%d1%8b","status":"publish","type":"post","link":"https:\/\/qwertys.ru\/?p=29","title":{"rendered":"\u0420\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 haproxy.cnf \u043d\u0430 \u0444\u0430\u0439\u043b\u044b"},"content":{"rendered":"<p>\u041b\u044e\u0431\u043e\u043c\u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0444\u0430\u0439\u043b\u044b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u0434\u0430 \u0438 \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0442\u0430\u043a \u043b\u0435\u0433\u0447\u0435.<\/p>\n<p>\u0423\u0432\u044b, \u043d\u043e \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c HAProxy \u0442\u0430\u043a \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412 \u043d\u0435\u043c \u043d\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b include \u043d\u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p><!--more--><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre class=\"code_block\">haproxy -c \/path\/to\/file1.cfg -c \/path\/to\/file2.cfg\r\n<\/pre>\n<p>\u0438 \u0442. \u0434.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0438\u043d\u0438\u0442\u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445 \u0443\u043a\u0430\u0437\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043a\u043e\u0444\u0438\u0433, \u0438\u0437 \u0447\u0435\u0433\u043e \u0432\u044b\u0442\u0435\u043a\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u00a0\u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 haproxy \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0438\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, service haproxy reload \u0438\u043b\u0438 systemctl haproxy reload ) \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0435 \u0432\u0435\u0441\u044c \u043a\u043e\u043d\u0444\u0438\u0433. \u0414\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. \u041e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \/etc\/haproxy\/haproxy.draft \u0438, \u0442\u0430\u043c \u0433\u0434\u0435 \u0432\u0441\u0442\u0435\u0440\u0447\u0430\u0435\u0442\u0441\u044f \u0444\u0440\u0430\u0437\u0430 INCLUDE \/path\/to\/file.cfg \u043e\u043d \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre class=\"code_block\">#!\/bin\/bash\r\n\r\nCFG=\/etc\/haproxy\/haproxy.cfg\r\nNEWCFG=\/tmp\/haproxy.cfg.tmp\r\nTMPCFG=\/tmp\/haproxy.cfg.$$\r\nCONFIGDIR=\/etc\/haproxy\/conf.d\/\r\nDRAFT=\/etc\/haproxy\/haproxy.draft\r\n\r\ncp $DRAFT $NEWCFG\r\ngrep_exit=0\r\n\r\nwhile [ $grep_exit -ne 1 ]\r\ndo\r\nconfig_line_count=`cat $NEWCFG | wc -l`\r\ninclude_line_number=`grep -nEm1 'INCLUDE [0-9a-zA-Z_-]*\\.cfg' $NEWCFG | cut -d':' -f1`\r\ninclude_file=`grep -oEm1 'INCLUDE [0-9a-zA-Z_-]*\\.cfg' $NEWCFG | cut -d' ' -f2`\r\n\r\nlet head_line_number=$include_line_number-1\r\nlet tail_line_number=$config_line_count-$include_line_number\r\n\r\nhead -$head_line_number $NEWCFG &gt;&gt; $TMPCFG\r\ncat $CONFIGDIR\/$include_file &gt;&gt; $TMPCFG\r\ntail -$tail_line_number $NEWCFG &gt;&gt; $TMPCFG\r\n\r\nrm $NEWCFG\r\nmv $TMPCFG $NEWCFG\r\n\r\ngrep -sqE 'INCLUDE [0-9a-zA-Z_-]*\\.cfg' $NEWCFG\r\ngrep_exit=$?\r\ndone\r\nmv $NEWCFG $CFG\r\n\r\nexit 0\r\n<\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0430 (\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e) \u0438, \u043f\u043e\u043a\u0430, \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u0441\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &#171;*&#187;).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041b\u044e\u0431\u043e\u043c\u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0444\u0430\u0439\u043b\u044b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u0434\u0430 \u0438 \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0442\u0430\u043a \u043b\u0435\u0433\u0447\u0435. \u0423\u0432\u044b, \u043d\u043e \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c HAProxy \u0442\u0430\u043a \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412 \u043d\u0435\u043c \u043d\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b include \u043d\u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[11,5],"tags":[14,13],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/29"}],"collection":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29"}],"version-history":[{"count":7,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":37,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions\/37"}],"wp:attachment":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}