{"id":198448,"date":"2013-10-22T12:04:03","date_gmt":"2013-10-22T08:04:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=198448"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=198448","title":{"rendered":"<span class=\"post_title\">HAPRoxy \u0434\u043b\u044f Percona \u0438\u043b\u0438 Galera \u043d\u0430 CantOS. \u0415\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0432 Zabbix<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/687\/a95\/321\/687a9532176415b2444ba2046be343ab.png\"\/><\/p>\n<h4>\u041e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043f\u0440\u043e \u0442\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c HAProxy \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0434\u043b\u044f multi-master \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MySQL, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a Percona \u0438\u043b\u0438 Galera.<\/h4>\n<p>  <b>\u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 HAProxy, \u0446\u0438\u0442\u0430\u0442\u0430 \u043e \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430:<\/b>  <\/p>\n<blockquote><p> \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u043b\u0438 \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u0438\u0441\u043a\u0430 \u0438 \u0442.\u0434) \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043a\u0438\u0439 \u043f\u0440\u0435\u0434\u0435\u043b \u0438 \u043d\u0435 \u0434\u0430\u0435\u0442 \u043e\u0449\u0443\u0442\u0438\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0445\u043e\u0434 \u0438\u0434\u0435\u0442 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 c \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438, \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u2014 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0442\u044c. <\/p><\/blockquote>\n<p>  <b>\u041e\u0442 \u0441\u043b\u043e\u0432 \u043a \u0434\u0435\u043b\u0443, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b:<\/b><br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043b \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u044f \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u043b \u043d\u0430\u0434 \u0447\u0438\u0441\u0442\u043e\u0439 CentOS 6.4, \u043c\u043e\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0438 \u0442\u0443\u0442, \u0432\u0441\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435:<\/p>\n<p>  <b>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 HAProxy:<\/b><\/p>\n<p>  <b># \u0421\u0442\u0430\u0432\u0438\u043c haproxy<\/b>  <\/p>\n<blockquote><p>yum install haproxy mariadb-client php-mysql php-cli -y<\/p><\/blockquote>\n<p>  <b># \u041f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438<\/b>  <\/p>\n<blockquote><p>mv \/etc\/haproxy\/haproxy.cfg \/etc\/haproxy\/haproxy.cfg.old<\/p><\/blockquote>\n<p>  <b>[root@rs-haproxy ~]# nano \/etc\/haproxy\/haproxy.cfg<\/b>  <\/p>\n<blockquote><p>global<br \/>   daemon<br \/>   maxconn 4096<\/p>\n<p>  <b># \u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0443\u043d\u043a\u0442 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/b><br \/>   quiet<\/p>\n<p>  <b># \u0410 \u044d\u0442\u043e\u0442 \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0440\u0430\u0441\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/b><br \/>  # debug<\/p>\n<p>  user haproxy<br \/>   group haproxy<\/p>\n<p>  <b># \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043e\u043a\u0435\u0442 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0432 zabbix<\/b><br \/>   stats socket \/var\/run\/haproxy<\/p>\n<p>  pidfile \/var\/run\/haproxy.pid<\/p>\n<p>  defaults<br \/>   mode http<br \/>   option tcplog<br \/>   log global<br \/>   option dontlognull retries 3 option redispatch<br \/>   maxconn 2000<br \/>   contimeout 5000<br \/>   clitimeout 50000<br \/>   srvtimeout 50000<br \/>   option tcplog<\/p>\n<p>  <b># \u0423\u043a\u0430\u0436\u0438\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u043f\u043e\u0440\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u043d\u0430\u0448 haproxy<\/b><br \/>   listen MySQL \u0430\u0434\u0440\u0435\u0441-\u043d\u0430-\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0448\u0430\u0435\u043c-:3306<\/p>\n<p>  mode tcp<\/p>\n<p>  <b># roundrobin \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0438\u0448\u0435\u0442 \u0432\u043e \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u0431\u0430\u0437\u0443<\/b><br \/>  # balance roundrobin<\/p>\n<p>  <b># leastconn \u044d\u0442\u043e\u0442 \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 haproxy \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 failover \u043f\u0440\u043e\u043a\u0441\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d<\/b><br \/>   balance leastconn<\/p>\n<p>  <b># httpchk \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 haproxy \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 \u0435\u0433\u043e \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/b><br \/>   option httpchk<\/p>\n<p>  <b># \u041d\u0438\u0436\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0438\u0445 \u043f\u043e\u0440\u0442 \u0438 \u043f\u043e\u0440\u0442 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0436\u0438\u0437\u043d\u0435\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438<\/b><br \/>   server \u0430\u0434\u0440\u0435\u0441 \u0430\u0434\u0440\u0435\u0441:3306 check port 50005 inter 12000 rise 3 fall 3<br \/>   server \u0430\u0434\u0440\u0435\u0441 \u0430\u0434\u0440\u0435\u0441:3306 check port 50005 inter 12000 rise 3 fall 3<\/p>\n<p>  <b># \u0421\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c backup \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b <\/b><br \/>   server \u0430\u0434\u0440\u0435\u0441 \u0430\u0434\u0440\u0435\u0441:3306 check port 50005 inter 12000 rise 3 fall 3 backup<\/p><\/blockquote>\n<p>  <b>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c \u043d\u0430\u0448\u0435\u0439 percona \u0438\u043b\u0438 galera<\/b><\/p>\n<p>  <b># \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u0448\u0438\u0445 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f xinetd<\/b>  <\/p>\n<blockquote><p>yum install -y xinetd<\/p><\/blockquote>\n<p>  <b>[root@xtrabackup-node-01 ~]# nano \/etc\/xinetd.d\/mysqlchk<\/b>  <\/p>\n<blockquote><p># default: on<br \/>  # description: mysqlchk<br \/>  service mysqlchk<br \/>  {<br \/>   disable = no<br \/>   flags = REUSE<br \/>   socket_type = stream<\/p>\n<p>  <b># \u043f\u043e\u0440\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432\u044b\u0448\u0435<\/b><br \/>   port = 50005<\/p>\n<p>  wait = no<br \/>   user = nobody<br \/>   server = \/usr\/bin\/clustercheck<br \/>   log_on_failure += USERID<\/p>\n<p>  <b># \u0410\u0434\u0440\u0435\u0441\u0430 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u043b\u0443\u0436\u0431\u044b MySQL<\/b><br \/>   only_from = 10.100.100.0\/24<\/p>\n<p>  per_source = UNLIMITED<br \/>  }<\/p><\/blockquote>\n<p>  <b># \u041e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u043f\u0438\u0441\u044c, \u0438\u043d\u0430\u0447\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f <\/b><br \/>  <b>root@xtrabackup-node-01 ~]# nano \/etc\/services<\/b>  <\/p>\n<blockquote><p>mysqlchk 50005\/tcp # mysqlchk<\/p><\/blockquote>\n<p>  <b># \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0443\u0436\u0431\u0443 \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0435\u0435<\/b>  <\/p>\n<blockquote><p>chkconfig xinetd on<br \/>  \/etc\/init.d\/xinetd start<\/p><\/blockquote>\n<p>  <b># \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0440\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 <\/b>  <\/p>\n<blockquote><p>iptables -A INPUT -p tcp -m state &#8212;state NEW -m tcp &#8212;dport 50005 -j ACCEPT<br \/>  service iptables save<\/p><\/blockquote>\n<p>  <b># \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 clustercheck<\/b>  <\/p>\n<blockquote><p>GRANT PROCESS ON *.* TO &#8216;clustercheckuser&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;clustercheckpassword!&#8217;;<br \/>  flush privileges;<\/p><\/blockquote>\n<p>  <b># \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u043b\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435<\/b><br \/>  <b>[root@xtrabackup-node-01 ~]# \/usr\/bin\/clustercheck<\/b>  <\/p>\n<blockquote><p>HTTP\/1.1 200 OK<br \/>  Content-Type: text\/plain<br \/>  Connection: close<br \/>  Content-Length: 40<\/p>\n<p>  Percona XtraDB Cluster Node is synced.<\/p><\/blockquote>\n<p>  <b># \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043d\u0430\u0448\u0435\u0433\u043e haproxy \u0445\u043e\u0441\u0442\u0430<\/b>  <\/p>\n<blockquote><p>[root@rs-haproxy ~]# telnet \u0430\u0434\u0440\u0435\u0441 50005<br \/>  Trying \u0430\u0434\u0440\u0435\u0441\u2026<br \/>  Connected to \u0430\u0434\u0440\u0435\u0441.<br \/>  Escape character is &#8216;^]&#8217;.<br \/>  HTTP\/1.1 200 OK<br \/>  Content-Type: text\/plain<br \/>  Connection: close<br \/>  Content-Length: 40<\/p>\n<p>  Percona XtraDB Cluster Node is synced.<br \/>  Connection closed by foreign host.  <\/p><\/blockquote>\n<p>  <b>\u0413\u043e\u0442\u043e\u0432\u043e! \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445 percona\/galera<\/b><\/p>\n<h4><b>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 HAProxy \u0434\u043b\u044f MYSQL \u0432 Zabbix<\/b><\/h4>\n<p>  <b># \u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0433\u043e<\/b>  <\/p>\n<blockquote><p>yum install -y socat <\/p><\/blockquote>\n<p>  <b># \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c sudo \u0434\u043b\u044f zabbix, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0440\u0430\u043d\u044c\u0448\u0435 <\/b>  <\/p>\n<blockquote><p>usermod -s \/bin\/bash zabbix<br \/>  echo &#8216;zabbix ALL=(ALL) NOPASSWD: ALL&#8217; &gt;&gt; \/etc\/sudoers<br \/>  sed -i &#8216;s\/Defaults\\ requiretty\/#Defaults\\ requiretty\/g&#8217; \/etc\/sudoers<\/p><\/blockquote>\n<p>  <b># \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432<\/b>  <\/p>\n<blockquote><p>mkdir -p \/etc\/zabbix\/scripts\/<br \/>  chmod 750 \/etc\/zabbix\/scripts\/<\/p><\/blockquote>\n<p>  <b># \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442<\/b><br \/>  <b>rm -f \/etc\/zabbix\/scripts\/haproxy.mysql<br \/>  nano \/etc\/zabbix\/scripts\/haproxy.mysql<\/b><\/p>\n<blockquote><p>if [[ -z $1 || -z $2 ]]; then<br \/>   servers=`echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $2}&#8217; | grep -v -e \u00abpxname\u00bb -e &#8216;^$&#8217;`<br \/>   if [[ -n ${servers} ]]; then<br \/>   JSON=&quot;{ \\\u00abdata\\\u00bb:[&quot;<br \/>   for DEV in ${servers}; do<br \/>   JSON=${JSON}&quot;{ \\&quot;{#SRV}\\&quot;:\\&quot;${DEV}\\&quot;},&quot;<br \/>   done<br \/>   JSON=${JSON}&quot;]}&quot;<br \/>   echo ${JSON}<br \/>   fi<br \/>   exit 0<br \/>  else<\/p>\n<p>  server=&quot;$2&quot;<br \/>  # echo $server<br \/>  if [ ${1} = \u00abqcur\u00bb ]; then<br \/>  # echo $1<br \/>  echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | grep \u00abMySQL,${server}\u00bb| sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $3}&#8217;<br \/>   exit 0<br \/>   fi<br \/>   if [ ${1} = \u00abqmax\u00bb ]; then<br \/>  echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | grep \u00abMySQL,${server}\u00bb | sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $4}&#8217;<br \/>   exit 0<br \/>   fi<br \/>  if [ ${1} = \u00abscur\u00bb ]; then<br \/>  echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | grep \u00abMySQL,${server}\u00bb | sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $5}&#8217;<br \/>   exit 0<br \/>   fi<br \/>   if [ ${1} = \u00absmax\u00bb ]; then<br \/>  echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | grep \u00abMySQL,${server}\u00bb | sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $6}&#8217;<br \/>   exit 0<br \/>   fi<br \/>   if [ ${1} = \u00abecon\u00bb ]; then<br \/>  echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | grep \u00abMySQL,${server}\u00bb | sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $14}&#8217;<br \/>   exit 0<br \/>   fi<br \/>  if [ ${1} = \u00abqlimit\u00bb ]; then<br \/>  echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | grep \u00abMySQL,${server}\u00bb | sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $26}&#8217;<br \/>   exit 0<br \/>   fi<br \/>   fi<\/p><\/blockquote>\n<p>  <b>\u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u0430\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0445 zabbix<br \/>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e:<\/b><\/p>\n<blockquote><p>[root@rs-haproxy ~]# echo \u00abshow stat\u00bb | sudo socat \/var\/run\/haproxy stdio | sed &#8216;s\/,\/\\ \/g&#8217; | awk &#8216;{print $2}&#8217; | grep -v -e \u00abpxname\u00bb -e &#8216;^$&#8217;<br \/>  FRONTEND<br \/>  10.100.100.246<br \/>  BACKEND<\/p><\/blockquote>\n<p>  <b># \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e zabbix-agent<\/b>  <\/p>\n<blockquote><p>echo Timeout=30 &gt;&gt; \/etc\/zabbix\/zabbix_agentd.conf<br \/>  echo Include=\/etc\/zabbix\/zabbix_agentd.d\/ &gt;&gt; \/etc\/zabbix\/zabbix_agentd.conf<\/p><\/blockquote>\n<p>  <b># \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0443 <\/b>  <\/p>\n<blockquote><p>chown zabbix:zabbix -R \/etc\/zabbix\/scripts\/<br \/>  chmod +x \/etc\/zabbix\/scripts\/haproxy.mysql<\/p><\/blockquote>\n<p>  # \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c zabbix \u043d\u0430\u0448\u0438 UserParameter  <\/p>\n<blockquote><p>mkdir -p \/etc\/zabbix\/zabbix_agentd.d\/<br \/>  rm -f \/etc\/zabbix\/zabbix_agentd.d\/haproxy.mysql.conf<br \/>  touch \/etc\/zabbix\/zabbix_agentd.d\/haproxy.mysql.conf<\/p><\/blockquote>\n<p>  <\/p>\n<blockquote><p>echo &#8216;UserParameter=haproxy.mysql[*],\/etc\/zabbix\/scripts\/haproxy.mysql &quot;$1&quot; &quot;$2&quot;&#8217; &gt;&gt; \/etc\/zabbix\/zabbix_agentd.d\/haproxy.mysql.conf<\/p><\/blockquote>\n<p>  <b>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442:<\/b>  <\/p>\n<blockquote><p>su zabbix<\/p><\/blockquote>\n<p>  <b># \u0412\u043e\u0442 \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0448\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432<br \/>  bash-4.1$ \/etc\/zabbix\/scripts\/haproxy.mysql<\/b>  <\/p>\n<blockquote><p>{ \u00abdata\u00bb:[{ &quot;{#SRV}&quot;:\u00abFRONTEND\u00bb},{ &quot;{#SRV}&quot;:\u00ab10.100.100.246\u00bb},{ &quot;{#SRV}&quot;:\u00abBACKEND\u00bb},]}<\/p><\/blockquote>\n<p>  <b># \u0421\u043f\u0440\u043e\u0441\u0438\u043c \u043b\u044e\u0431\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/b>  <\/p>\n<blockquote><p>bash-4.1$ \/etc\/zabbix\/scripts\/haproxy.mysql qcur FRONTEND<br \/>  115  <\/p><\/blockquote>\n<p>  <b>\u041f\u043e\u0445\u043e\u0436\u0435 \u0447\u0442\u043e \u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435! \u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u043b\u0443\u0436\u0431\u0443 \u0438 \u043b\u044e\u0431\u0443\u0435\u043c\u0441\u044f \u043b\u043e\u0433\u0430\u043c\u0438<\/b>  <\/p>\n<blockquote><p>\/etc\/init.d\/zabbix-agent restart &#038;&#038; tail -f -n 100 \/var\/log\/zabbix\/zabbix_agentd.log<\/p><\/blockquote>\n<p>  <b>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u0448 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u0434 haproxy <\/b><br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/228\/a2a\/d9c\/228a2ad9cb1bd5da53f55365a08b1afc.png\"\/><\/p>\n<p>  <b>\u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0432 zabbix <\/b><\/p>\n<h4>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435! <\/h4>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/198448\/\"> http:\/\/habrahabr.ru\/post\/198448\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/687\/a95\/321\/687a9532176415b2444ba2046be343ab.png\"\/><\/p>\n<h4>\u041e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043f\u0440\u043e \u0442\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c HAProxy \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0434\u043b\u044f multi-master \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MySQL, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a Percona \u0438\u043b\u0438 Galera.<\/h4>\n<p>  <b>\u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 HAProxy, \u0446\u0438\u0442\u0430\u0442\u0430 \u043e \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430:<\/b>  <\/p>\n<blockquote><p> \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u043b\u0438 \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u0438\u0441\u043a\u0430 \u0438 \u0442.\u0434) \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043a\u0438\u0439 \u043f\u0440\u0435\u0434\u0435\u043b \u0438 \u043d\u0435 \u0434\u0430\u0435\u0442 \u043e\u0449\u0443\u0442\u0438\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0445\u043e\u0434 \u0438\u0434\u0435\u0442 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 c \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438, \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u2014 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0442\u044c. <\/p><\/blockquote>\n<p>  <b>\u041e\u0442 \u0441\u043b\u043e\u0432 \u043a \u0434\u0435\u043b\u0443, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b:<\/b>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-198448","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/198448","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198448"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/198448\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}