{"id":280252,"date":"2016-11-01T08:35:04","date_gmt":"2016-11-01T05:35:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=280252"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=280252","title":{"rendered":"\u041a\u041b\u0410\u0421\u0422\u0415\u0420 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 postgresql 9.6 + repmgr + pgbouncer + haproxy + keepalived + \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0447\u0435\u0440\u0435\u0437 telegram"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a17\/d60\/054\/a17d600549ef46759aa32c7c22b4a2fc.png\" alt=\"image\"\/><br \/>   \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <b>\u00abfailover\u00bb <\/b> \u0432 Postgresql \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445. \u0414\u043b\u044f \u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u0435\u0440\u0430 \u2014 \u044d\u0442\u043e \u0437\u0430\u043b\u043e\u0433 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443. \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445 \u2014 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f, \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u043a\u0430\u0437\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0434\u0440\u0443\u0433\u0430\u044f \u043d\u043e\u0434\u0430(standby) \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u00ab\u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c\u00bb, \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u043e\u0434\u044b standby \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u043d\u043e\u0432\u044b\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<br \/>  \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c repmgr \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e Failover \u2014 autofailover, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0442\u0440\u043e\u044f \u043d\u043e\u0434\u044b-\u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0431\u0435\u0437 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430, \u0447\u0442\u043e \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f UPTIME. \u0414\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c telegram.<\/p>\n<p>   \u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0411\u0414 \u043d\u0430 Postgresql + \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f + \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430 + failover(\u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c). \u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0447\u0442\u043e \u0442\u043e \u0438 \u0435\u0441\u0442\u044c, \u043d\u043e \u0432\u0441\u0451 \u043e\u043d\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0435 \u0438\u043b\u0438 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e. \u0411\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0443 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432, \u0440\u0435\u0448\u0438\u0432\u0448\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0438\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439, \u0432\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e \u0432\u0441\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438. <br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c: 5 VM \u0441 debian 8,Postgresql 9.6 + repmgr (\u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c), \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u0438 HA \u043d\u0430 \u0431\u0430\u0437\u0435 HAPROXY (\u041f\u041e \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445) \u0438 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 Pgbouncer, keepalived \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 ip \u0430\u0434\u0440\u0435\u0441\u0430(VIP) \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u0434\u0430\u043c\u0438,5-\u044f witness \u043d\u043e\u0434\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u201csplit brain\u201d \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043c\u0430\u0441\u0442\u0435\u0440 \u043d\u043e\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043a\u0430\u0437\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430. \u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 telegram( \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u043a\u0430\u043a \u0431\u0435\u0437 \u0440\u0443\u043a).<br \/>   \u041f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u043d\u043e\u0434\u044b \/etc\/hosts \u2014 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0444\u0430\u0439\u043b \/etc\/hosts<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">10.1.1.195 - pghost195 10.1.1.196 - pghost196 10.1.1.197 - pghost197 10.1.1.198 - pghost198 10.1.1.205 - pghost205 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  VIP 10.1.1.192 \u2014 \u0437\u0430\u043f\u0438\u0441\u044c, 10.1.1.202 \u2014 roundrobin(\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430\/\u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u0435\u043d\u0438\u0435).<\/p>\n<h1><b>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Postgresql 9.6 pgbouncer haproxy repmgr<\/b><\/h1>\n<p>  \u0421\u0442\u0430\u0432\u0438\u043c \u043d\u0430 \u0432\u0441\u0435 \u043d\u043e\u0434\u044b  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Postgresql-9.6 \u0438 repmgr debian 8<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">touch \/etc\/apt\/sources.list.d\/pgdg.list echo \u201cdeb http:\/\/apt.postgresql.org\/pub\/repos\/apt\/ jessie-pgdg main\u201d &gt; \/etc\/apt\/sources.list.d\/pgdg.list wget --quiet -O - https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc |  apt-key add - apt-get update wget http:\/\/ftp.ru.debian.org\/debian\/pool\/main\/p\/pkg-config\/pkg-config_0.28-1_amd64.deb dpkg -i pkg-config_0.28-1_amd64.deb apt-get install postgresql-9.6-repmgr libevent-dev -y <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a Postgresql \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2014 \u0432\u0441\u0435\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c postgres. \u0422\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u0432\u0435 \u043c\u0430\u0441\u0442\u0435\u0440-\u043d\u043e\u0434\u044b, \u043f\u043e\u0441\u043b\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0430\u043a \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">nano \/etc\/postgresql\/9.1\/main\/start.conf  \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c auto \u043d\u0430 manual <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 ssh \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0430\u0440\u043e\u043b\u044f \u2014 \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 \u043d\u043e\u0434\u0430\u043c\u0438(\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445)<\/b><br \/>  \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f postgres(\u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f postgres \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 repmgr). <br \/>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b(\u0441\u0440\u0430\u0437\u0443 \u0441\u0442\u0430\u0432\u0438\u043c)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0442\u0430\u0432\u0438\u043c ssh \u0438 rsync<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">apt-get install openssh-server rsync -y <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u043c\u0443 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f postgres (\u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">passwd postgres  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0432\u0435\u0434\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c.<br \/>  \u041e\u043a.<br \/>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c ssh \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres cd ~ ssh-keygen <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447 \u2014 \u0431\u0435\u0437 \u043f\u0430\u0440\u043e\u043b\u044f.<br \/>  \u0421\u0442\u0430\u0432\u0438\u043c \u043a\u043b\u044e\u0447 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u043e\u0434\u044b  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">ssh-copy-id -i ~\/.ssh\/id_rsa.pub postgres@pghost195 ssh-copy-id -i ~\/.ssh\/id_rsa.pub postgres@pghost196 ssh-copy-id -i ~\/.ssh\/id_rsa.pub postgres@pghost197 ssh-copy-id -i ~\/.ssh\/id_rsa.pub postgres@pghost198 ssh-copy-id -i ~\/.ssh\/id_rsa.pub postgres@pghost205 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b ssh \u043d\u0435 \u0441\u043f\u0430\u0440\u0448\u0438\u0432\u0430\u043b\u0430 \u0434\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u0445\u043e\u0441\u0442\u0443 \u0438 \u043d\u0435 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">nano \/etc\/ssh\/ssh_config    StrictHostKeyChecking no    UserKnownHostsFile=\/dev\/null <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c ssh.<br \/>  \u0414\u0430\u043d\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0435\u0441\u044c \u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. <br \/>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0430 \u043d\u043e\u0434\u0443 2,3,4 \u0438 \u0432\u0441\u0451 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0443\u043b\u044f\u0442\u044c \u0431\u0435\u0437 \u043f\u0430\u0440\u043e\u043b\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u0434\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f(\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 standby).<br \/>  <b>\u0421\u0442\u0430\u0432\u0438\u043c pgbouncer \u0438\u0437 git<\/b><br \/>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">apt-get install libpq-dev checkinstall  build-essential libpam0g-dev  libssl-dev  libpcre++-dev libtool automake  checkinstall gcc+ git -y  cd \/tmp  git clone https:\/\/github.com\/pgbouncer\/pgbouncer.git  cd pgbouncer git submodule init git submodule update .\/autogen.sh wget https:\/\/github.com\/libevent\/libevent\/releases\/download\/release-2.0.22-stable\/libevent-2.0.22-stable.tar.gz tar -xvf libevent-2.0.22-stable.tar.gz cd libevent* .\/configure checkinstall cd .. <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 postgresql \u0441 PAM \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u2014 \u0442\u043e \u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u0434\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043f\u0440\u0438 configure \u0441\u0442\u0430\u0432\u0438\u043c &#8212;with-pam  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> .\/configure --prefix=\/usr\/local --with-libevent=libevent-prefix --with-pam  make -j4 mkdir -p \/usr\/local\/share\/doc; mkdir -p \/usr\/local\/share\/man; checkinstall <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u0430\u0432\u0438\u043c \u0432\u0435\u0440\u0441\u0438\u044e \u2014 1.7.2 (\u043d\u0430 \u043d\u043e\u044f\u0431\u0440\u044c 2016 \u0433\u043e\u0434\u0430).<br \/>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0412\u0438\u0434\u0438\u043c   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> Done. The new package has been installed and saved to  \/tmp\/pgbouncer\/pgbouncer_1.7.2-1_amd64.deb  You can remove it from your system anytime using:  dpkg -r pgbouncer_1.7.2-1_amd64.deb  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e PATH=\/usr\/lib\/postgresql\/9.6\/bin:$PATH(\u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0434\u0435).<br \/>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b ~\/.bashrc  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres cd ~ nano .bashrc <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043e\u0434  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">PATH=$PATH:\/usr\/lib\/postgresql\/9.6\/bin export PATH export PGDATA=&quot;$HOME\/9.6\/main&quot; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c\u0441\u044f. <br \/>  \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u043d\u0430 .bashrc \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u043e\u0434\u044b  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres cd ~ scp .bashrc postgres@pghost195:\/var\/lib\/postgresql scp .bashrc postgres@pghost196:\/var\/lib\/postgresql scp .bashrc postgres@pghost197:\/var\/lib\/postgresql scp .bashrc postgres@pghost198:\/var\/lib\/postgresql scp .bashrc postgres@pghost205:\/var\/lib\/postgresql <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>   <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0430\u0441\u0442\u0435\u0440\u0430(pghost195)<\/h2>\n<p>  \u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \/etc\/postgresql\/9.6\/main\/postgresql.conf \u2014 \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a \u0432\u0438\u0434\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u043f\u0446\u0438\u0438(\u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">listen_addresses='*' wal_level = 'hot_standby' archive_mode = on wal_log_hints = on archive_command = 'cd .' max_wal_senders = 10 max_replication_slots = 1 # \u0422\u0430\u043a\u043e\u0439 \u0436\u0435 \u0432 \/etc\/repmgr.conf !!must be!! hot_standby = on shared_preload_libraries = 'repmgr_funcs, pg_stat_statements' ####\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 repmgr \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 postgres max_connections = 800 max_wal_senders = 10 wal_keep_segments = 3000  # \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u0435\u043c \u0434\u043b\u0438\u043d\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0436\u0443\u0440\u043d\u0430\u043b  \u0442\u0435\u043c \u043f\u0440\u043e\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 standby \u043d\u043e\u0434\u0435 \u0434\u043e\u0433\u043d\u0430\u0442\u044c master\u2019a. max_replication_slots = 8 port = 5433 pg_stat_statements.max = 10000 pg_stat_statements.track = all <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u2014 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c postgresql \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 5433 \u2014 \u043f\u043e\u0442\u043e\u043c\u0443-\u0447\u0442\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u2014 \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438, \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 failover\u2019a. \u0412\u044b \u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u0440\u0442, \u043a\u0430\u043a \u0432\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0444\u0430\u0439\u043b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/p>\n<p>  nano \/etc\/postgresql\/9.6\/main\/pg_hba.conf<\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043a \u0432\u0438\u0434\u0443  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># IPv6 local connections: host    all             all             ::1\/128                 md5  local   all             postgres                                peer local   all             all                                     peer host    all             all             127.0.0.1\/32            md5  #######################################\u0422\u0443\u0442 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043d\u043e\u0434 (MASTER, STAND BY). local   replication   repmgr                              trust host    replication   repmgr      127.0.0.1\/32            trust host    replication   repmgr      10.1.1.0\/24          trust local   repmgr        repmgr                              trust host    repmgr        repmgr      127.0.0.1\/32            trust host    repmgr        repmgr      10.1.1.0\/24          trust ###################################### host    all         all  0.0.0.0\/32     md5  #######\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e ##################################### <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043f\u0440\u0430\u0432\u0430 \u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c, \u0438\u043d\u0430\u0447\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 pg_hba.conf  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">chown -R -v postgres \/etc\/postgresql <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c postgres(\u043e\u0442 postgres user).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">pg_ctl -D \/etc\/postgresql\/9.6\/main --log=\/var\/log\/postgresql\/postgres_screen.log  start <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0431\u0430\u0437\u044b \u043d\u0430 Master-\u0441\u0435\u0440\u0432\u0435\u0440\u0435(pghost195).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres  cd ~ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f repmgr.   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">psql # create role repmgr with superuser noinherit; # ALTER ROLE repmgr WITH LOGIN; # create database repmgr; # GRANT ALL PRIVILEGES on DATABASE repmgr to repmgr; # ALTER USER repmgr SET search_path TO repmgr_test, &quot;$user&quot;, public; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f test_user \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c 1234  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">create user test_user; ALTER USER test_user WITH PASSWORD '1234'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c repmgr \u043d\u0430 master  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">nano \/etc\/repmgr.conf <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">cluster=etagi_test node=1 node_name=node1 use_replication_slots=1 conninfo='host=pghost195 port=5433  user=repmgr dbname=repmgr' pg_bindir=\/usr\/lib\/postgresql\/9.6\/bin <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u0441\u044f.<br \/>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043a\u0430\u043a \u043c\u0430\u0441\u0442\u0435\u0440.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf master register <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u0448 \u0441\u0442\u0430\u0442\u0443\u0441  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr -f \/etc\/repmgr.conf cluster show <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">Role      | Name  | Upstream | Connection String ----------+-------|----------|-------------------------------------------------- * master  | node1 |          | host=pghost195 port=5433  user=repmgr dbname=repmgr <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.   <\/p>\n<h2><b>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u043b\u0435\u0439\u0432\u043e\u0432(standby) \u2014 pghost196,pghost197,pghost198<\/b><\/h2>\n<p>  \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c repmgr \u043d\u0430 slave1(pghost197)<br \/>  nano \/etc\/repmgr.conf \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433<br \/>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">cluster=etagi_test node=2 node_name=node2 use_replication_slots=1 conninfo='host=pghost196 port=5433  user=repmgr dbname=repmgr' pg_bindir=\/usr\/lib\/postgresql\/9.6\/bin <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u0441\u044f.<br \/>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043a\u0430\u043a standby  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres cd ~\/9.6\/ rm -rf main\/* repmgr -h pghost1  -p 5433 -U repmgr -d repmgr -D main -f \/etc\/repmgr.conf --copy-external-config-files=pgdata --verbose standby clone pg_ctl -D \/var\/lib\/postgresql\/9.6\/main --log=\/var\/log\/postgresql\/postgres_screen.log  start <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0411\u0443\u0434\u0443\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 master \u0438 standby \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432.<br \/>  \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0430\u043f\u043a\u0438 \/var\/lib\/postgresql\/9.6\/main \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">PG_VERSION backup_label pg_hba.conf  pg_ident.conf  postgresql.auto.conf  postgresql.conf  recovery.conf <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf standby register; repmgr -f \/etc\/repmgr.conf cluster show \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 repmgr -f \/etc\/repmgr.conf cluster show \u0412\u0438\u0434\u0438\u043c &lt;spoiler title=&quot;&quot;&gt; &lt;source lang=&quot;bash&quot;&gt; Role      | Name  | Upstream | Connection String ----------+-------|----------|-------------------------------------------------- * master  | node195 |          | host=pghost195 port=5433  user=repmgr dbname=repmgr   standby | node196 | node1    | host=pghost196 port=5433  user=repmgr dbname=repmgr  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432\u0442\u043e\u0440\u043e\u0433\u043e stand-by \u2014 pghost197<\/b><br \/>  \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c repmgr \u043d\u0430 pghost197<br \/>  nano \/etc\/repmgr.conf \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433<br \/>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">cluster=etagi_test node=3 node_name=node3 use_replication_slots=1 conninfo='host=pghost197 port=5433  user=repmgr dbname=repmgr' pg_bindir=\/usr\/lib\/postgresql\/9.6\/bin <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u0441\u044f.<br \/>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043a\u0430\u043a standby  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres cd ~\/9.6\/ rm -rf main\/* repmgr -h pghost195 -p 5433 -U repmgr -d repmgr -D main -f \/etc\/repmgr.conf --copy-external-config-files=pgdata --verbose standby clone <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0438\u043b\u0438  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr -D \/var\/lib\/postgresql\/9.6\/main  -f \/etc\/repmgr.conf -d repmgr -p 5433 -U repmgr -R postgres --verbose --force --rsync-only  --copy-external-config-files=pgdata  standby clone -h pghost195 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 -r\/&#8212;rsync-only \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u043a\u0430\u0437\u0430\u0432\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0443\u0437\u043b\u043e\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<br \/>  \u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 master \u0438 standby \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432.<br \/>  \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0430\u043f\u043a\u0438 \/var\/lib\/postgresql\/9.6\/main \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">PG_VERSION backup_label pg_hba.conf  pg_ident.conf  postgresql.auto.conf  postgresql.conf  recovery.conf <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c postgres(\u043e\u0442 postgres)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">pg_ctl -D \/var\/lib\/postgresql\/9.6\/main --log=\/var\/log\/postgresql\/postgres_screen.log  start <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf standby register <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr -f \/etc\/repmgr.conf cluster show <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">Role      | Name  | Upstream | Connection String ----------+-------|----------|-------------------------------------------------- * master  | node1 |          | host=pghost1 port=5433  user=repmgr dbname=repmgr   standby | node2 | node1    | host=pghost2 port=5433  user=repmgr dbname=repmgr   standby | node3 | node1    | host=pghost2 port=5433  user=repmgr dbname=re <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h2><b>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<\/b><\/h2>\n<p>  \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u0443\u044e \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440.<br \/>  \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c repmgr \u043d\u0430 pghost198 \u043e\u0442 pghost197<br \/>  nano \/etc\/repmgr.conf \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433<br \/>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">cluster=etagi_test node=4 node_name=node4 use_replication_slots=1 conninfo='host=pghost198 port=5433  user=repmgr dbname=repmgr' pg_bindir=\/usr\/lib\/postgresql\/9.6\/bin upstream_node=3 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u0441\u044f. \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432 upstream_node \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 node3, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f pghost197.<br \/>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043a\u0430\u043a standby \u043e\u0442 standby  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres cd ~\/9.6\/ rm -rf main\/* repmgr -h pghost197  -p 5433 -U repmgr -d repmgr -D main -f \/etc\/repmgr.conf --copy-external-config-files=pgdata --verbose standby clone <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c postgres(\u043e\u0442 postgres)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">pg_ctl -D \/var\/lib\/postgresql\/9.6\/main --log=\/var\/log\/postgresql\/postgres_screen.log  start <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf standby register <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr -f \/etc\/repmgr.conf cluster show <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">Role      | Name  | Upstream | Connection String ----------+-------|----------|-------------------------------------------------- * master  | node1 |          | host=pghost195 port=5433  user=repmgr dbname=repmgr   standby | node2 | node1    | host=pghost196 port=5433  user=repmgr dbname=repmgr   standby | node3 | node1    | host=pghost197 port=5433  user=repmgr dbname=repmgr   standby | node4 | node3    | host=pghost198 port=5433  user=repmgr dbname=repmgr <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h2><b>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e Faiover&#8217;\u0430.<\/b><\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d2f\/f3f\/f7d\/d2ff3ff7de0f43fb8b8b19bcfaf73474.png\" alt=\"image\"\/><br \/>  \u0418\u0442\u0430\u043a \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0430\u0432\u0442\u043e\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u2014 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0438\u0437 stand-by \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 \u0432 \u0444\u0430\u0439\u043b \/etc\/repmgr.conf \u043d\u0430 stand-by \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445. \u041d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e!!! <br \/>  !!! \u041a\u043e\u043d\u0444\u0438\u0433\u0438 \u043d\u0430 standby(slave\u2019s) \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u2014 \u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435. \u0412\u044b\u0441\u0442\u0430\u0432\u0438\u043c \u0440\u0430\u0437\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f(master_responce_timeout)!!! <br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 pghost196 \u0432 \/etc\/repmgr.conf  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#######\u0410\u0412\u0422\u041e\u041c\u0410\u0422\u0418\u0427\u0415\u0421\u041a\u0418\u0419 FAILOVER#######\u0422\u041e\u041b\u042c\u041a\u041e \u041d\u0410 STAND BY################## master_response_timeout=20 reconnect_attempts=5 reconnect_interval=5 failover=automatic promote_command='sh \/etc\/postgresql\/failover_promote.sh' follow_command='sh \/etc\/postgresql\/failover_follow.sh' #loglevel=NOTICE #logfacility=STDERR #logfile='\/var\/log\/postgresql\/repmgr-9.6.log' priority=90 # a value of zero or less prevents the node being promoted to master <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 pghost197 \u0432 \/etc\/repmgr.conf  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#######\u0410\u0412\u0422\u041e\u041c\u0410\u0422\u0418\u0427\u0415\u0421\u041a\u0418\u0419 FAILOVER#######\u0422\u041e\u041b\u042c\u041a\u041e \u041d\u0410 STAND BY################## master_response_timeout=20 reconnect_attempts=5 reconnect_interval=5 failover=automatic promote_command='sh \/etc\/postgresql\/failover_promote.sh' follow_command='sh \/etc\/postgresql\/failover_follow.sh' #loglevel=NOTICE #logfacility=STDERR #logfile='\/var\/log\/postgresql\/repmgr-9.6.log' priority=70 # a value of zero or less prevents the node being promoted to master <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 pghost198 \u0432 \/etc\/repmgr.conf  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#######\u0410\u0412\u0422\u041e\u041c\u0410\u0422\u0418\u0427\u0415\u0421\u041a\u0418\u0419 FAILOVER#######\u0422\u041e\u041b\u042c\u041a\u041e \u041d\u0410 STAND BY################## master_response_timeout=20 reconnect_attempts=5 reconnect_interval=5 failover=automatic promote_command='sh \/etc\/postgresql\/failover_promote.sh' follow_command='sh \/etc\/postgresql\/failover_follow.sh' #loglevel=NOTICE #logfacility=STDERR #logfile='\/var\/log\/postgresql\/repmgr-9.6.log' priority=50 # a value of zero or less prevents the node being promoted to master <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0430\u0432\u0442\u043e\u0444\u0435\u0439\u043e\u043b\u0432\u0435\u0440\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 priority. \u0415\u0441\u043b\u0438 0, \u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 Standby \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 Master. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f failover\u2019a, \u0442.\u0435. \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0431\u043e\u043b\u044c\u0448\u0435\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0435, \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043a\u0430\u0437\u0430 master \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u043e\u0437\u044c\u043c\u0435\u0442 pghost197.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b \/etc\/postgresql\/9.6\/main\/postgresql.conf (\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 stand-by \u0441\u0435\u0440\u0432\u0435\u0440\u0430!!!!!!)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">shared_preload_libraries = 'repmgr_funcs' <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u043c\u043e\u043d\u0430 \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgrd -f \/etc\/repmgr.conf -p \/var\/run\/postgresql\/repmgrd.pid  -m -d -v &gt;&gt; \/var\/log\/postgresql\/repmgr.log 2&gt;&1 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0441\u0441 repmgrd \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043a\u0430\u043a \u0434\u0435\u043c\u043e\u043d. \u0421\u043c\u043e\u0442\u0440\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">ps aux | grep repmgrd <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">postgres   2921  0.0  0.0  59760  5000 ?        S    16:54   0:00 \/usr\/lib\/postgresql\/9.6\/bin\/repmgrd -f \/etc\/repmgr.conf -p \/var\/run\/postgresql\/repmgrd.pid -m -d -v postgres   3059  0.0  0.0  12752  2044 pts\/1    S+   16:54   0:00 grep repmgrd <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0441\u0451 \u043e\u043a. \u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435. <\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0430\u0432\u0442\u043e\u0444\u0435\u0439\u043b\u043e\u0432\u0435\u0440\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres psql repmgr repmgr # SELECT * FROM repmgr_etagi_test.repl_nodes ORDER BY id;    id |  type   | upstream_node_id |  cluster   | name  |                     conninfo                      |   slot_name   | priority | active  ----+---------+------------------+------------+-------+---------------------------------------------------+---------------+----------+--------   1 | master  |                  | etagi_test | node1 | host=pghost195 port=5433  user=repmgr dbname=repmgr | repmgr_slot_1 |      100 | t   2 | standby |                1 | etagi_test | node2 | host=pghost196 port=5433  user=repmgr dbname=repmgr | repmgr_slot_2 |      100 | t   3 | standby |                1 | etagi_test | node3 | host=pghost197 port=5433  user=repmgr dbname=repmgr | repmgr_slot_3 |      100 | t <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u043a\u0430 \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0442\u0435\u0441\u0442. \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043c\u0430\u0441\u0442\u0435\u0440 \u2014 pghost195  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres pg_ctl -D \/etc\/postgresql\/9.6\/main  -m immediate stop <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u043b\u043e\u0433\u0430\u0445 \u043d\u0430 pghost196  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">tail -f \/var\/log\/postgresql\/* <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">[2016-10-21 16:58:34] [NOTICE] promoting standby [2016-10-21 16:58:34] [NOTICE] promoting server using '\/usr\/lib\/postgresql\/9.6\/bin\/pg_ctl -D \/var\/lib\/postgresql\/9.6\/main promote' [2016-10-21 16:58:36] [NOTICE] STANDBY PROMOTE successful <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u043b\u043e\u0433\u0430\u0445 \u043d\u0430 pghost197  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">tail -f \/var\/log\/postgresql\/* <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">2016-10-21 16:58:39] [NOTICE] node 2 is the best candidate for new master, attempting to follow... [2016-10-21 16:58:40] [ERROR] connection to database failed: could not connect to server: Connection refused \tIs the server running on host &quot;pghost195&quot; (10.1.1.195) and accepting \tTCP\/IP connections on port 5433?   [2016-10-21 16:58:40] [NOTICE] restarting server using '\/usr\/lib\/postgresql\/9.6\/bin\/pg_ctl  -w -D \/var\/lib\/postgresql\/9.6\/main -m fast restart' [2016-10-21 16:58:42] [NOTICE] node 3 now following new upstream node 2 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0423 \u043d\u0430\u0441 \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0442\u0435\u0440 \u2014 pghost196, pghost197,pghost198 \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043b\u0443\u0448\u0430\u0435\u0442 stream \u043e\u0442 pghost2.<\/p>\n<h2><b>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0443\u043f\u0430\u0432\u0448\u0435\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0432 \u0441\u0442\u0440\u043e\u0439!!!<\/b><\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9e1\/462\/b34\/9e1462b341eb4b478d04681399263e36.png\" alt=\"image\"\/><br \/>  \u041d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u0437\u044f\u0442\u044c \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0443\u043f\u0430\u0432\u0448\u0438\u0439 \u043c\u0430\u0441\u0442\u0435\u0440 \u0432 \u0441\u0442\u0440\u043e\u0439. \u041d\u043e \u043e\u043d \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0435\u0439\u0432\u0430.<br \/>  Postges \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f.<br \/>  \u041d\u0430 \u043d\u043e\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442, \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0440\u0442\u0435 \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c, \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0443 \u2014 \u0435\u0441\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d \u0444\u0430\u0439\u043b \/etc\/postgresql\/disabled, \u0442\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442. \u0422\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b \/etc\/postgresql\/current_master.list \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u2014 \u0438\u043c\u0435\u043d\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e master.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/postgresql\/current_master.list<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">pghost196 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u00abregister.sh\u00bb \u0438 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/etc\/postgresql<br \/>  \u0421\u043a\u0440\u0438\u043f\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0434\u044b \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 standby  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/postgresql\/register.sh.<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> trigger=&quot;\/etc\/postgresql\/disabled&quot; TEXT=&quot;'`hostname -f`_postgresql_disabled_and_don't_be_started.You_must_delete_file_\/etc\/postgresql\/disabled'&quot; TEXT if [ -f &quot;$trigger&quot; ] then \techo &quot;Current server is disabled&quot; \tsh \/etc\/postgresql\/telegram.sh $TEXT else  pkill repmgrd pg_ctl stop rm -rf  \/var\/lib\/postgresql\/9.6\/main\/*; mkdir \/var\/run\/postgresql\/9.6-main.pg_stat_tmp; repmgr -D \/var\/lib\/postgresql\/9.6\/main  -f \/etc\/repmgr.conf -d repmgr -p 5433 -U repmgr -R postgres --verbose --force --rsync-only  --copy-external-config-files=pgdata  standby clone -h $(cat \/etc\/postgresql\/current_master.list); \/usr\/lib\/postgresql\/9.6\/bin\/pg_ctl -D \/var\/lib\/postgresql\/9.6\/main --log=\/var\/log\/postgresql\/postgres_screen.log start; \/bin\/sleep 5; repmgr -f \/etc\/repmgr.conf  --force standby register; echo &quot;\u0412\u044b\u0432\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430&quot;; repmgr -f \/etc\/repmgr.conf  cluster show; sh \/etc\/postgresql\/telegram.sh $TEXT sh \/etc\/postgresql\/repmgrd.sh; ps aux | grep repmgrd; fi <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0443 \u043d\u0430\u0441 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0444\u0430\u0439\u043b repmgrd.sh \u0438 telegram.sh. \u041e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/etc\/postgresql.   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/postgresql\/repmgrd.sh<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/bash pkill repmgrd rm \/var\/run\/postgresql\/repmgrd.pid; repmgrd -f \/etc\/repmgr.conf -p \/var\/run\/postgresql\/repmgrd.pid  -m -d -v &gt;&gt; \/var\/log\/postgresql\/repmgr.log 2&gt;&1; ps aux | grep repmgrd; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> USERID=&quot;\u042e\u0437\u0435\u0440_\u0438\u0434_\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439_\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c_\u0447\u0435\u0440\u0435\u0437_\u043f\u0440\u043e\u0431\u0435\u043b&quot; CLUSTERNAME=&quot;PGCLUSTER_RIES&quot; KEY=&quot;\u041a\u043b\u044e\u0447_\u0431\u043e\u0442\u0430_\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c&quot; TIMEOUT=&quot;10&quot; EXEPT_USER=&quot;root&quot; URL=&quot;https:\/\/api.telegram.org\/bot$KEY\/sendMessage&quot; DATE_EXEC=&quot;$(date &quot;+%d %b %Y %H:%M&quot;)&quot; TMPFILE='\/etc\/postgresql\/ipinfo-$DATE_EXEC.txt'         IP=$(echo $SSH_CLIENT | awk '{print $1}')         PORT=$(echo $SSH_CLIENT | awk '{print $3}')         HOSTNAME=$(hostname -f)         IPADDR=$(hostname -I | awk '{print $1}')         curl http:\/\/ipinfo.io\/$IP -s -o $TMPFILE         #ORG=$(cat $TMPFILE | jq '.org' | sed 's\/&quot;\/\/g')         TEXT=$1         for IDTELEGRAM in $USERID         do         curl -s --max-time $TIMEOUT -d &quot;chat_id=$IDTELEGRAM&disable_web_page_preview=1&text=$TEXT&quot; $URL &gt; \/dev\/null         done         rm $TMPFILE  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 repmgr \u043d\u0430 \u0443\u043f\u0430\u0432\u0448\u0435\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/repmgr.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">cluster=etagi_cluster1 node=1 node_name=node195 use_replication_slots=8 conninfo='host=pghost195 port=5433  user=repmgr dbname=repmgr' pg_bindir=\/usr\/lib\/postgresql\/9.6\/bin #######\u0410\u0412\u0422\u041e\u041c\u0410\u0422\u0418\u0427\u0415\u0421\u041a\u0418\u0419 FAILOVER#######\u0422\u041e\u041b\u042c\u041a\u041e \u041d\u0410 STAND BY##################  master_response_timeout=20 reconnect_attempts=5 reconnect_interval=5 failover=automatic promote_command='sh \/etc\/postgresql\/failover_promote.sh' follow_command='sh \/etc\/postgresql\/failover_follow.sh' #loglevel=NOTICE #logfacility=STDERR #logfile='\/var\/log\/postgresql\/repmgr-9.6.log' priority=95 # a value of zero or less prevents the node being promoted to master <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c\u0441\u044f. <br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442, \u043d\u0430 \u043e\u0442\u043a\u0430\u0437\u0430\u0432\u0448\u0435\u0439 \u043d\u043e\u0434\u0435. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e \u043f\u0440\u0430\u0432\u0430(postgres) \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432.<br \/>  sh \/etc\/postgresq\/register.sh<br \/>  \u0423\u0432\u0438\u0434\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">[2016-10-31 15:19:53] [NOTICE] notifying master about backup completion... \u0417\u0410\u041c\u0415\u0427\u0410\u041d\u0418\u0415:  \u043a\u043e\u043c\u0430\u043d\u0434\u0430 pg_stop_backup \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430, \u0432\u0441\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u044b WAL \u0437\u0430\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u044b [2016-10-31 15:19:54] [NOTICE] standby clone (using rsync) complete [2016-10-31 15:19:54] [NOTICE] you can now start your PostgreSQL server [2016-10-31 15:19:54] [HINT] for example : pg_ctl -D \/var\/lib\/postgresql\/9.6\/main start [2016-10-31 15:19:54] [HINT] After starting the server, you need to register this standby with &quot;repmgr standby register&quot; \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f [2016-10-31 15:19:59] [NOTICE] standby node correctly registered for cluster etagi_cluster1 with id 2 (conninfo: host=pghost196 port=5433  user=repmgr dbname=repmgr) \u0412\u044b\u0432\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Role      | Name    | Upstream | Connection String ----------+---------|----------|---------------------------------------------------- * standby  | node195 |          | host=pghost195 port=5433  user=repmgr dbname=repmgr   master | node196 | node195  | host=pghost197 port=5433 user=repmgr dbname=repmgr   standby | node197 | node195  | host=pghost198 port=5433  user=repmgr dbname=repmgr   standby | node198 | node195  | host=pghost196 port=5433  user=repmgr dbname=repmgr postgres  11317  0.0  0.0   4336   716 pts\/0    S+   15:19   0:00 sh \/etc\/postgresql\/repmgrd.sh postgres  11322  0.0  0.0  59548  3632 ?        R    15:19   0:00 \/usr\/lib\/postgresql\/9.6\/bin\/repmgrd -f \/etc\/repmgr.conf -p \/var\/run\/postgresql\/repmgrd.pid -m -d -v postgres  11324  0.0  0.0  12752  2140 pts\/0    S+   15:19   0:00 grep repmgrd postgres  11322  0.0  0.0  59548  4860 ?        S    15:19   0:00 \/usr\/lib\/postgresql\/9.6\/bin\/repmgrd -f \/etc\/repmgr.conf -p \/var\/run\/postgresql\/repmgrd.pid -m -d -v postgres  11327  0.0  0.0  12752  2084 pts\/0    S+   15:19   0:00 grep repmgrd <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.  <\/p>\n<h2><b>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b Switchover(\u0441\u043c\u0435\u043d\u044b \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0432\u0440\u0443\u0447\u043d\u0443\u044e).<\/b><\/h2>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u043c\u0430\u0441\u0442\u0435\u0440 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 standby.<br \/>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c pghost195 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u0432\u0448\u0435\u0433\u043e \u043f\u043e \u0444\u0435\u0439\u043b\u043e\u0432\u0435\u0440\u0443 pghost196, \u043f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0435\u0439\u0432\u0430. \u041d\u0430\u0448\u0438 \u0448\u0430\u0433\u0438. <br \/>  \u041d\u0430 pghost195  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf standby switchover  \u0412\u0438\u0434\u0438\u043c [2016-10-26 15:29:42] [NOTICE] replication slot &quot;repmgr_slot_1&quot; deleted on former master [2016-10-26 15:29:42] [NOTICE] switchover was successful <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c, \u043a\u0440\u043e\u043c\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0434\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0442\u0435\u0440<br \/>  \u041d\u0430 pghost197  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf standby follow repmgr -f \/etc\/repmgr.conf cluster show; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u043c\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0437\u0430 \u043d\u043e\u0432\u044b\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<br \/>  \u041d\u0430 pghost198 \u2014 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf standby follow repmgr -f \/etc\/repmgr.conf cluster show; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u043c\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0437\u0430 \u043d\u043e\u0432\u044b\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<br \/>  \u041d\u0430 pghost196 \u2014 \u043e\u043d \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres repmgr -f \/etc\/repmgr.conf standby follow <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">[2016-10-26 15:35:51] [ERROR] Slot 'repmgr_slot_2' already exists as an active slot <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  C\u0442\u043e\u043f\u0430\u0435\u043c pghost196  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">pg_ctl stop <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0435\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043c \u043d\u0430 phgost195(\u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0442\u0435\u0440)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres psql repmgr #select pg_drop_replication_slot('repmgr_slot_2'); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> pg_drop_replication_slot  -------------------------- (1 row) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0418\u0434\u0435\u043c \u043d\u0430 pghost196, \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u043f\u0443\u043d\u043a\u0442\u043e\u043c.<\/p>\n<h2><b>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 witness \u043d\u043e\u0434\u044b<\/b><\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/981\/b52\/b7b\/981b52b7beff496cbb92c915f0f4909a.png\" alt=\"image\"\/><br \/>  Witness \u043d\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0435\u0440\u0430 \u0438 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u0430\u0440\u0431\u0438\u0442\u0440\u043e\u043c, \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0442\u0435\u043c \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u043b\u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043d\u044b\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430. \u041e\u043d\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043d\u043e\u0434\u043e\u0439 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a standby \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0442\u043e\u0439 \u0436\u0435 \u043d\u043e\u0434\u0435 \u0447\u0442\u043e \u0438 postgres \u0438\u043b\u0438 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u043e\u0434\u0435.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u043d\u043e\u0434\u0443 pghost205 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c( \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0441\u043b\u0435\u0439\u0432\u0430), \u0442\u043e\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0441\u043f\u043e\u0441\u043e\u0431 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr -h pghost195 -p 5433 -U repmgr -d repmgr -D main -f \/etc\/repmgr.conf --force --copy-external-config-files=pgdata --verbose witness create; \u0438\u043b\u0438 repmgr -D \/var\/lib\/postgresql\/9.6\/main  -f \/etc\/repmgr.conf -d repmgr -p 5433 -U repmgr -R postgres --verbose --force --rsync-only  --copy-external-config-files=pgdata  witness create -h pghost195; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0423\u0432\u0438\u0434\u0438\u043c \u0432\u044b\u0432\u043e\u0434  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">2016-10-26 17:27:06] [WARNING] --copy-external-config-files can only be used when executing STANDBY CLONE [2016-10-26 17:27:06] [NOTICE] using configuration file &quot;\/etc\/repmgr.conf&quot; \u0424\u0430\u0439\u043b\u044b, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0435\u0441\u044f \u043a \u044d\u0442\u043e\u0439 \u0421\u0423\u0411\u0414, \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e &quot;postgres&quot;. \u041e\u0442 \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041a\u043b\u0430\u0441\u0442\u0435\u0440 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u044e &quot;ru_RU.UTF-8&quot;. \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u0411\u0414 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438: &quot;UTF8&quot;. \u0412\u044b\u0431\u0440\u0430\u043d\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e &quot;russian&quot;.   \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d.   \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432 \u0434\u043b\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 main... \u043e\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432... \u043e\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 max_connections... 100 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 shared_buffers... 128MB \u0432\u044b\u0431\u043e\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 ... posix \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432... \u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 ... \u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f ... \u043e\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435... \u043e\u043a   \u041f\u0420\u0415\u0414\u0423\u041f\u0420\u0415\u0416\u0414\u0415\u041d\u0418\u0415: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e\u0441\u0442\u0438 &quot;trust&quot; \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439. \u0414\u0440\u0443\u0433\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0432 pg_hba.conf \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u044e\u0447\u0438 -A, --auth-local \u0438\u043b\u0438 --auth-host \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 initdb.   \u0413\u043e\u0442\u043e\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445:       \/usr\/lib\/postgresql\/9.6\/bin\/pg_ctl -D main -l logfile start   \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430....\u0421\u041e\u041e\u0411\u0429\u0415\u041d\u0418\u0415:  \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0411\u0414 \u0431\u044b\u043b\u0430 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0430: 2016-10-26 17:27:07 YEKT \u0421\u041e\u041e\u0411\u0429\u0415\u041d\u0418\u0415:  \u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0443\u043b\u044c\u0442\u0438\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0421\u041e\u041e\u0411\u0429\u0415\u041d\u0418\u0415:  \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0411\u0414 \u0433\u043e\u0442\u043e\u0432\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0421\u041e\u041e\u0411\u0429\u0415\u041d\u0418\u0415:  \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u0432\u0442\u043e\u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u043d  \u0433\u043e\u0442\u043e\u0432\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d Warning: Permanently added 'pghost1,10.1.9.1' (ECDSA) to the list of known hosts. receiving incremental file list pg_hba.conf           1,174 100%    1.12MB\/s    0:00:00 (xfr#1, to-chk=0\/1) \u0421\u041e\u041e\u0411\u0429\u0415\u041d\u0418\u0415:  \u043f\u043e\u043b\u0443\u0447\u0435\u043d SIGHUP, \u0444\u0430\u0439\u043b\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u043b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0441\u0435\u0440\u0432\u0435\u0440\u0443 [2016-10-26 17:27:10] [NOTICE] configuration has been successfully copied to the witness  \/usr\/lib\/postgresql\/9.6\/bin\/pg_ctl -D \/var\/lib\/postgresql\/9.6\/main -l logfile start <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u0435\u0435. \u041f\u0440\u0430\u0432\u0438\u043c \u0444\u0430\u0439\u043b repmgr.conf \u0434\u043b\u044f witness \u043d\u043e\u0434\u044b<br \/>  \u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u0435\u0440 \u043d\u0430 \u043d\u043e\u0434\u0435 witness  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/etc\/repmgr.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">cluster=etagi_test node=5 node_name=node5 use_replication_slots=1 conninfo='host=pghost205 port=5499  user=repmgr dbname=repmgr' pg_bindir=\/usr\/lib\/postgresql\/9.6\/bin  #######FAILOVER#######\u0422\u041e\u041b\u042c\u041a\u041e \u041d\u0410 WITNESS NODE####### master_response_timeout=50 reconnect_attempts=3 reconnect_interval=5 failover=manual promote_command='repmgr standby promote -f \/etc\/repmgr.conf' follow_command='repmgr standby follow -f \/etc\/repmgr.conf' <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430 witness \u043d\u043e\u0434\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0440\u0442 \u043d\u0430 5499 \u0432 conninfo.<\/p>\n<p>  \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e (\u043f\u0435\u0440\u0435)\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c repmgrd \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445, \u043a\u0440\u043e\u043c\u0435 \u043c\u0430\u0441\u0442\u0435\u0440\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres pkill repmgr repmgrd -f \/etc\/repmgr.conf -p \/var\/run\/postgresql\/repmgrd.pid  -m -d -v &gt;&gt; \/var\/log\/postgresql\/repmgr.log 2&gt;&1 ps aux | grep repmgr <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h2><b>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 Pgbouncer \u0438 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 Haproxy. \u041e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Keepalived.<\/b><\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/62b\/ea1\/e49\/62bea1e49275499bb90100f7935c0b1d.png\" alt=\"image\"\/>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Pgbouncer<\/h3>\n<p>  Pgbouncer \u043c\u044b \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435. \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d \u043d\u0443\u0436\u0435\u043d\u2026  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u0447\u0435\u043c Pgbouncer<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> \u041c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0435\u043a\u0441\u043e\u0440\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u041e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 Postgres, \u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u043d \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432 \u0440\u0430\u0437\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0418\u0437 \u0442\u044b\u0441\u044f\u0447 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0445 \u043a PgBouncer \u0434\u043e \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0439\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432.  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435.<br \/>  \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 pgbouncer \u0432 \u043f\u0430\u043f\u043a\u0443 \/etc\/(\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">cp -r \/usr\/local\/share\/doc\/pgbouncer \/etc cd \/etc\/pgbouncer <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043a \u0432\u0438\u0434\u0443 \u0444\u0430\u0439\u043b \u0432   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano  \/etc\/pgbouncer\/pgbouncer.ini<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">[databases] ################################\u041f\u041e\u0414\u041a\u041b \u041a \u0411\u0410\u0417\u0415########### web1 = host = localhost port=5433 dbname=web1 web2 = host = localhost port=5433 dbname=web2 ####################################################### [pgbouncer] logfile = \/var\/log\/postgresql\/pgbouncer.log pidfile = \/var\/run\/postgresql\/pgbouncer.pid listen_addr = * listen_port = 6432 auth_type = trust auth_file = \/etc\/pgbouncer\/userlist.txt  ;;; Pooler personality questions  ; When server connection is released back to pool: ;   session      - after client disconnects ;   transaction  - after transaction finishes ;   statement    - after statement finishes pool_mode = session server_reset_query = DISCARD ALL max_client_conn = 500 default_pool_size = 30 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/pgbouncer\/userlist.txt<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">&quot;test_user&quot; &quot;passworduser&quot; &quot;postgres&quot; &quot;passwordpostgres&quot; &quot;pgbouncer&quot; &quot;fake&quot; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043f\u0440\u0430\u0432\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">chown -R postgres \/etc\/pgbouncer <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u043a\u0430\u043a \u0434\u0435\u043c\u043e\u043d (-d)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043f\u0443\u0441\u043a pgbouncer<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres pkill pgbouncer pgbouncer  -d --verbose \/etc\/pgbouncer\/pgbouncer.ini  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0440\u0442  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> netstat -4ln | grep 6432 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043b\u043e\u0433  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">tail -f \/var\/log\/postgresql\/pgbouncer.log <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f. \u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u0442\u043e\u0436\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445.<\/p>\n<h2><b>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Haproxy.<\/b><\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b5f\/562\/caa\/b5f562caa1a14965a7eea3f3c9c3bfab.png\" alt=\"image\"\/><br \/>  \u0421\u0442\u0430\u0432\u0438\u043c Xinetd \u0438 Haproxy   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">apt-get install xinetd haproxy -y <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">nano \/etc\/services pgsqlchk        23267\/tcp               # pgsqlchk <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f postgres \u2014 pgsqlcheck  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/opt\/pgsqlchk<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/bash # \/opt\/pgsqlchk  # This script checks if a postgres server is healthy running on localhost. It will # return: # # &quot;HTTP\/1.x 200 OK\\r&quot; (if postgres is running smoothly) # # - OR - # # &quot;HTTP\/1.x 500 Internal Server Error\\r&quot; (else) # # The purpose of this script is make haproxy capable of monitoring postgres properly # # # It is recommended that a low-privileged postgres  user is created to be used by # this script. # For eg. create  user pgsqlchkusr login password 'pg321'; #   PGSQL_HOST=&quot;localhost&quot; PGSQL_PORT=&quot;5433&quot; PGSQL_DATABASE=&quot;template1&quot; PGSQL_USERNAME=&quot;pgsqlchkusr&quot; export PGPASSWORD=&quot;pg321&quot;    TMP_FILE=&quot;\/tmp\/pgsqlchk.out&quot; ERR_FILE=&quot;\/tmp\/pgsqlchk.err&quot;      # # We perform a simple query that should return a few results :-p # psql -h $PGSQL_HOST -p $PGSQL_PORT -U $PGSQL_USERNAME \\      $PGSQL_DATABASE -c &quot;show port;&quot; &gt; $TMP_FILE 2&gt; $ERR_FILE    # # Check the output. If it is not empty then everything is fine and we return # something. Else, we just do not return anything. # if [ &quot;$(\/bin\/cat $TMP_FILE)&quot; != &quot;&quot; ] then     # Postgres is fine, return http 200     \/bin\/echo -e &quot;HTTP\/1.1 200 OK\\r\\n&quot;     \/bin\/echo -e &quot;Content-Type: Content-Type: text\/plain\\r\\n&quot;     \/bin\/echo -e &quot;\\r\\n&quot;     \/bin\/echo -e &quot;Postgres is running.\\r\\n&quot;     \/bin\/echo -e &quot;\\r\\n&quot; else     # Postgres is down, return http 503     \/bin\/echo -e &quot;HTTP\/1.1 503 Service Unavailable\\r\\n&quot;     \/bin\/echo -e &quot;Content-Type: Content-Type: text\/plain\\r\\n&quot;     \/bin\/echo -e &quot;\\r\\n&quot;     \/bin\/echo -e &quot;Postgres is *down*.\\r\\n&quot;     \/bin\/echo -e &quot;\\r\\n&quot; fi <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f pgsqlchkusr \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f postgres  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">plsq #create user pgsqlchkusr; #ALTER ROLE pgsqlchkusr WITH LOGIN; #ALTER USER pgsqlchkusr WITH PASSWORD 'pg321'; #\\q <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u0435\u043b\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0438 \u0434\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u043c \u2014 \u0438\u043d\u0430\u0447\u0435 check \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">chmod +x  \/opt\/pgsqlchk;touch \/tmp\/pgsqlchk.out; touch \/tmp\/pgsqlchk.err; chmod 777  \/tmp\/pgsqlchk.out;  chmod 777 \/tmp\/pgsqlchk.err; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0444\u0430\u0439\u043b xinetd \u0434\u043b\u044f pgsqlchk  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/etc\/xinetd.d\/pgsqlchk<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> # \/etc\/xinetd.d\/pgsqlchk # # default: on # # description: pqsqlchk service pgsqlchk {         flags           = REUSE         socket_type     = stream         port            = 23267         wait            = no         user            = nobody         server          = \/opt\/pgsqlchk         log_on_failure  += USERID         disable         = no         only_from       = 0.0.0.0\/0         per_source      = UNLIMITED  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u0441\u044f.<br \/>  <b>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c haproxy.<\/b><br \/>  \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u2014 \u0443\u0434\u0430\u043b\u0438\u043c \u0441\u0442\u0430\u0440\u044b\u0439 \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435. \u042d\u0442\u043e\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u043d\u043e\u0434\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u043c\u0430\u0441\u0442\u0435\u0440, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u043e pghost195. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0432 \u043f\u0443\u043b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439-\u0436\u0435 \u0445\u043e\u0441\u0442, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u043f\u043e\u0440\u0442\u0435 6432(\u0447\u0435\u0440\u0435\u0437 pgbouncer).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/etc\/haproxy\/haproxy.cfg<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #chroot \/usr\/share\/haproxy chroot      \/var\/lib\/haproxy pidfile     \/var\/run\/haproxy.pid  user postgres group postgres daemon maxconn 20000 defaults log global mode http option tcplog option dontlognull retries 3 option redispatch timeout connect 30000ms timeout client 30000ms timeout server 30000ms  frontend stats-front bind *:8080 mode http default_backend stats-back  frontend pxc-onenode-front bind *:5432 mode tcp default_backend pxc-onenode-back  backend stats-back mode http stats uri \/ stats auth admin:adminpassword  backend pxc-onenode-back     mode tcp     balance leastconn     option  httpchk     default-server port 6432 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxqueue 128 weight 100     server pghost195 10.1.1.195:6432 check port 23267  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0430\u043c \u043f\u043e\u0440\u0442 haproxy \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0440\u0442\u0435 5432. \u0410\u0434\u043c\u0438\u043d\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0430 \u043f\u043e\u0440\u0442\u0435 8080. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c admin \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c adminpassword.<br \/>  \u0420\u0435\u0441\u0442\u0430\u0440\u0442\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u044b   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">\/etc\/init.d\/xinetd restart; \/etc\/init.d\/haproxy restart; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0449\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445.<br \/>  \u041d\u0430 \u0442\u043e\u0439 \u043d\u043e\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 pghost198(\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043d\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0434\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435) \u043a\u043e\u043d\u0444\u0438\u0433 haproxy \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443.   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/etc\/haproxy\/haproxy.cfg<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #chroot \/usr\/share\/haproxy chroot      \/var\/lib\/haproxy pidfile     \/var\/run\/haproxy.pid user postgres group postgres daemon maxconn 20000 defaults log global mode http option tcplog option dontlognull retries 3 option redispatch timeout connect 30000ms timeout client 30000ms timeout server 30000ms  frontend stats-front bind *:8080 mode http default_backend stats-back  frontend pxc-onenode-front bind *:5432 mode tcp default_backend pxc-onenode-back  backend stats-back mode http stats uri \/ stats auth admin:adminpassword  backend pxc-onenode-back     mode tcp     balance roundrobin     option  httpchk     default-server port 6432 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxqueue 128 weight 100     server pghost196 10.1.1.196:6432 check port 23267     server pghost197 10.1.1.196:6432 check port 23267     server pghost198 10.1.1.196:6432 check port 23267 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0441\u043c\u043e\u0442\u0440\u0438 \u043d\u0430 <a href=\"http:\/\/hostip\">hostip<\/a>:8080<\/p>\n<h2><b>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 keepalived.<\/b><\/h2>\n<p>  Keepalived \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 ip \u0430\u0434\u0440\u0435\u0441 (VIP) \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0445\u043e\u0434\u044b \u0438\u0437 \u0441\u0442\u0440\u043e\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u043e\u0434(\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435) ip \u0430\u0434\u0440\u0435\u0441 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u043d\u043e\u0434\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 VIP 10.1.1.192 \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u0434\u043e\u0439 pghost195,pghost196,pghost197. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0438\u0442\u0430\u043d\u0438\u0438 \u043d\u0430 \u043d\u043e\u0434\u0435 pghost195 \u043d\u043e\u0434\u0430 pghost196 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442 \u0441\u0435\u0431\u0435 ip addr 10.1.1.192 \u0438 \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u0432 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0435 \u043d\u0430 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043a \u0440\u043e\u043b\u0438 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0441\u0442\u0430\u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u043b\u0438 haproxy \u0438\u043b\u0438 pgbouncer \u2014 \u0442\u0443\u0442 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u2014 \u044d\u0442\u043e Haproxy.<br \/>  \u0421\u0442\u0430\u0432\u0438\u043c keepalived  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">apt-get install keepalived -y <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c keepalived. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a \u0432\u0438\u0434\u0443. \u041d\u0410 1-\u043e\u0439 \u043d\u043e\u0434\u0435(pghost195)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/etc\/keepalived\/keepalived.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">  ! this is who emails will go to on alerts    notification_email {     admin@domain.com      ! add a few more email addresses here if you would like    }    notification_email_from servers@domain.com    ! I use the local machine to relay mail    smtp_server smt.local.domain    smtp_connect_timeout 30    ! each load balancer should have a different ID    ! this will be used in SMTP alerts, so you should make    ! each router easily identifiable    lvs_id LVS_HAPROXY-pghost195 }  } vrrp_instance haproxy-pghost195 {         interface eth0         state MASTER         virtual_router_id 192         priority 150   ! send an alert when this instance changes state from MASTER to BACKUP         smtp_alert         authentication {             auth_type PASS             auth_pass passwordforcluster         }         track_script {             chk_http_port         }         virtual_ipaddress {                 10.1.1.192\/32 dev eth0         }         notify_master &quot;sh \/etc\/postgresql\/telegram.sh 'MASTER pghost195.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;          notify_backup &quot;sh \/etc\/postgresql\/telegram.sh 'BACKUP pghost195.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;         notify_fault &quot;sh \/etc\/postgresql\/telegram.sh 'FAULT pghost195.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0441\u0442\u0430\u0440\u0442\u0438\u043c <br \/>  \/etc\/init.d\/keepalived restart<\/p>\n<p>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c keepalived \u043d\u0430 2-\u043e\u0439 \u043d\u043e\u0434\u0435(pghost196)<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/etc\/keepalived\/keepalived.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">  ! this is who emails will go to on alerts    notification_email {     admin@domain.com      ! add a few more email addresses here if you would like    }    notification_email_from servers@domain.com    ! I use the local machine to relay mail    smtp_server smt.local.domain    smtp_connect_timeout 30    ! each load balancer should have a different ID    ! this will be used in SMTP alerts, so you should make    ! each router easily identifiable    lvs_id LVS_HAPROXY-pghost196 }  } vrrp_instance haproxy-pghost196 {         interface eth0         state MASTER         virtual_router_id 192         priority 80   ! send an alert when this instance changes state from MASTER to BACKUP         smtp_alert         authentication {             auth_type PASS             auth_pass passwordforcluster         }         track_script {             chk_http_port         }         virtual_ipaddress {                 10.1.1.192\/32 dev eth0         }         notify_master &quot;sh \/etc\/postgresql\/telegram.sh 'MASTER pghost196.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;          notify_backup &quot;sh \/etc\/postgresql\/telegram.sh 'BACKUP pghost196.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;         notify_fault &quot;sh \/etc\/postgresql\/telegram.sh 'FAULT pghost196.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c keepalived \u043d\u0430 3-\u043e\u0439 \u043d\u043e\u0434\u0435(pghost197)<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nano \/etc\/keepalived\/keepalived.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">  ! this is who emails will go to on alerts    notification_email {     admin@domain.com      ! add a few more email addresses here if you would like    }    notification_email_from servers@domain.com    ! I use the local machine to relay mail    smtp_server smt.local.domain    smtp_connect_timeout 30    ! each load balancer should have a different ID    ! this will be used in SMTP alerts, so you should make    ! each router easily identifiable    lvs_id LVS_HAPROXY-pghost197 }  } vrrp_instance haproxy-pghost197 {         interface eth0         state MASTER         virtual_router_id 192         priority 50   ! send an alert when this instance changes state from MASTER to BACKUP         smtp_alert         authentication {             auth_type PASS             auth_pass passwordforcluster         }         track_script {             chk_http_port         }         virtual_ipaddress {                 10.1.1.192\/32 dev eth0         }         notify_master &quot;sh \/etc\/postgresql\/telegram.sh 'MASTER pghost197.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;          notify_backup &quot;sh \/etc\/postgresql\/telegram.sh 'BACKUP pghost197.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;         notify_fault &quot;sh \/etc\/postgresql\/telegram.sh 'FAULT pghost197.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0441\u0442\u0430\u0440\u0442\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">\/etc\/init.d\/keepalived restart <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">        notify_master &quot;sh \/etc\/postgresql\/telegram.sh 'MASTER pghost195.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;          notify_backup &quot;sh \/etc\/postgresql\/telegram.sh 'BACKUP pghost195.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot;         notify_fault &quot;sh \/etc\/postgresql\/telegram.sh 'FAULT pghost195.etagi.com \u043f\u043e\u043b\u0443\u0447\u0438\u043b VIP'&quot; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 VIP \u043d\u0430 10.1.8.111 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0442\u044c \u043d\u0430 eth0. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0434\u044b pghost195 \u043e\u043d \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u0442 \u043d\u0430 pghost196, \u0442.\u0435. \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u044b \u0442\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 IP 10.1.1.192. \u0442\u0430\u043a \u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0430 pghost197, \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c vrrp_instance \u0438 lvs_id LVS_.<br \/>  \u041d\u0430 \u043d\u043e\u0434\u0430\u0445 pghost196,pghost197 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043c keepalived. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b failover promote, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435. \u041c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">promote_command='sh \/etc\/postgresql\/failover_promote.sh' follow_command='sh \/etc\/postgresql\/failover_follow.sh' <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0432 \u0444\u0430\u0439\u043b\u0435 \/etc\/repmgr.conf (\u0441\u043c. \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u0445 \u0432\u044b\u0448\u0435).<br \/>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 failover \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 -\u043e\u0442\u043a\u0430\u0437\u0435 \u043c\u0430\u0441\u0442\u0435\u0440\u0430. <br \/>  promote_command=&#8217;sh \/etc\/postgresql\/failover_promote.sh \u2014 \u0432\u044b\u043f\u043e\u043d\u044f\u0435\u0442 \u043d\u043e\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 master host,<br \/>  follow_command=&#8217;sh \/etc\/postgresql\/failover_follow.sh&#8217; \u2014 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043d\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0437\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<br \/>  \u041a\u043e\u043d\u0444\u0438\u0433\u0438  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">promote_command=&#39;sh \/etc\/postgresql\/failover_promote.sh&#39;<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/bash CLHOSTS=&quot;pghost195 pghost196 pghost197  pghost198  pghost205  &quot; repmgr standby promote -f \/etc\/repmgr.conf; echo &quot;\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0439&quot;; sh \/etc\/postgresql\/failover_notify_master.sh; echo &quot;\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432 \u0432 \u0444\u0430\u0439\u043b&quot; repmgr -f \/etc\/repmgr.conf  cluster show | grep node | awk ' {print $7} ' | sed &quot;s\/host=\/\/g&quot; | sed '\/port\/d'  &gt; \/etc\/postgresql\/cluster_hosts.list repmgr -f \/etc\/repmgr.conf  cluster show | grep FAILED | awk ' {print $6} ' | sed &quot;s\/host=\/\/g&quot; | sed &quot;s\/&gt;\/\/g&quot; &gt; \/etc\/postgresql\/failed_host.list repmgr -f \/etc\/repmgr.conf  cluster show | grep master | awk ' {print $7} ' | sed &quot;s\/host=\/\/g&quot; | sed &quot;s\/&gt;\/\/g&quot; &gt; \/etc\/postgresql\/current_master.list repmgr -f \/etc\/repmgr.conf  cluster show | grep standby | awk ' {print $7} ' | sed &quot;s\/host=\/\/g&quot; | sed '\/port\/d' &gt; \/etc\/postgresql\/standby_host.list  ####\u041a\u041e\u041f\u0418\u0420\u0423\u042e \u0418\u041d\u0424\u041e \u0424\u0410\u0419\u041b\u042b \u0418 \u0424\u0410\u0419\u041b\u042b-\u0422\u0420\u0418\u0413\u0413\u0415\u0420\u042b \u041d\u0410 \u0414\u0420\u0423\u0413\u0418\u0415 \u041d\u041e\u0414\u042b \u041a\u041b\u0410\u0421\u0422\u0415\u0420\u0410##################### for CLHOST in $CLHOSTS do rsync -arvzSH  --include &quot;*.list&quot; --exclude &quot;*&quot; \/etc\/\\postgresql\/ postgres@$CLHOST:\/etc\/postgresql\/ done  echo &quot;\u041d\u0430\u0447\u0438\u043d\u0430\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u043f\u0430\u0432\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430,\u0435\u0441\u043b\u0438 \u043d\u0435 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430 \/etc\/postgresql\/disabled&quot;  for FH in $(cat \/etc\/postgresql\/failed_host.list) do ssh postgres@$FH &lt;&lt;OFF sh \/etc\/postgresql\/register.sh; echo &quot;\u0420\u0435\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c repmgrd \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u043e\u0434\u0430\u0445&quot; sh \/etc\/postgresql\/repmgrd.sh; sh \/etc\/postgresql\/failover_notify_restoring_ended.sh; OFF done   echo &quot;\u0421\u0442\u043e\u043f\u0430\u0435\u043c repmgrd \u043d\u0430 \u043d\u043e\u0434\u0435, \u0441\u0442\u0430\u0432\u0448\u0435\u0439 \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c&quot; pkill repmgrd  echo &quot;\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 Keepalived&quot;  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">follow_command=&#39;sh \/etc\/postgresql\/failover_follow.sh&#39;<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr standby follow -f \/etc\/repmgr.conf; echo &quot;\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0439&quot;; sh \/etc\/postgresql\/failover_notify_standby.sh; pkill repmgrd; repmgrd -f \/etc\/repmgr.conf -p \/var\/run\/postgresql\/repmgrd.pid  -m -d -v &gt;&gt; \/var\/log\/postgresql\/repmgr.log 2&gt;&1; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0430\u0441\u0442\u0440\u0435\u0440\u0430 \u2014 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e failover, \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u00ab\u043f\u0435\u0440\u0435\u0432\u044b\u0431\u043e\u0440\u043e\u0432\u00bb \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">follow_command=&#39;sh \/etc\/postgresql\/stop_master.sh&#39;<\/b><\/p>\n<div class=\"spoiler_text\">#!\/bin\/bash<br \/>  repmgr -f \/etc\/repmgr.conf cluster show | grep master | awk &#8216; {print $7} &#8216; | sed \u00abs\/host=\/\/g\u00bb | sed \u00abs\/&gt;\/\/g\u00bb &gt; \/etc\/postgresql\/current_master.list<br \/>  for CURMASTER in $(cat \/etc\/postgresql\/current_master.list)<br \/>  do<br \/>  ssh postgres@$CURMASTER &lt;&lt;OFF<br \/>  cd ~\/9.6;<br \/>  \/usr\/lib\/postgresql\/9.6\/bin\/pg_ctl -D \/etc\/postgresql\/9.6\/main -m immediate stop;<br \/>  touch \/etc\/postgresql\/disabled;<br \/>  OFF<br \/>  sh \/etc\/postgresql\/telegram.sh \u00ab\u0422\u0415\u041a\u0423\u0429\u0418\u0419 \u041c\u0410\u0421\u0422\u0415\u0420 \u041e\u0421\u0422\u0410\u041d\u041e\u0412\u041b\u0415\u041d\u00bb<br \/>  done  <\/div>\n<\/div>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e\u0434 \u0441\u0435\u0431\u044f. \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0438\u0437 \u043a\u043e\u0434\u0430, \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a root \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f postgres. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u2014 \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u044e\u0447\u0438.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u0441\u0442\u0443\u043f \u043a root \u043e\u0442 postgres<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres ssh-copy-id -i ~\/.ssh\/id_rsa.pub root@pghost195 ssh-copy-id -i ~\/.ssh\/id_rsa.pub root@pghost196 ssh-copy-id -i ~\/.ssh\/id_rsa.pub root@pghost197 ssh-copy-id -i ~\/.ssh\/id_rsa.pub root@pghost198 ssh-copy-id -i ~\/.ssh\/id_rsa.pub root@pghost205 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445.<br \/>  \u0414\u043b\u044f \u043e\u0441\u043e\u0431\u044b\u0445 \u043f\u0430\u0440\u0430\u043d\u043e\u0438\u043a\u043e\u0432, \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0440\u043e\u043d \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437 \u0432 2 \u043c\u0438\u043d\u0443\u0442\u044b. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> repmgr -f \/etc\/repmgr.conf  cluster show | grep node | awk ' {print $7} ' | sed &quot;s\/host=\/\/g&quot; | sed '\/port\/d'  &gt; \/etc\/postgresql\/cluster_hosts.list repmgr -f \/etc\/repmgr.conf  cluster show | grep FAILED | awk ' {print $6} ' | sed &quot;s\/host=\/\/g&quot; | sed &quot;s\/&gt;\/\/g&quot; &gt; \/etc\/postgresql\/failed_host.list repmgr -f \/etc\/repmgr.conf  cluster show | grep master | awk ' {print $7} ' | sed &quot;s\/host=\/\/g&quot; | sed &quot;s\/&gt;\/\/g&quot; &gt; \/etc\/postgresql\/current_master.list repmgr -f \/etc\/repmgr.conf  cluster show | grep standby | awk ' {print $7} ' | sed &quot;s\/host=\/\/g&quot; | sed '\/port\/d' &gt; \/etc\/postgresql\/standby_host.list <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h1><b>\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e\u0441\u0442\u0435\u0439.<\/b><\/h1>\n<p>  <\/p>\n<h3><b>\u0421\u0431\u043e\u0440 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0431\u0430\u0437\u0443<\/b><\/h3>\n<p>  \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 pg_stat_statements( \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0441\u0442\u0430\u0440\u0442)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres cd ~ pg_ctl restart; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># CREATE EXTENSION pg_stat_statements; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># SELECT query, calls, total_time, rows, 100.0 * shared_blks_hit \/                nullif(shared_blks_hit + shared_blks_read, 0) AS hit_percent           FROM pg_stat_statements ORDER BY total_time DESC LIMIT 10; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0441\u0431\u0440\u043e\u0441\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0430 pg_stat_statements_reset:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># SELECT pg_stat_statements_reset(); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h3><b>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0434\u044b \u0438\u0437 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u2018FAILED\u2019<\/b><\/h3>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">DELETE FROM repmgr_etagi_test.repl_nodes WHERE name = 'node1'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0433\u0434\u0435 \u2014 etagi_test \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430;<br \/>  node1 \u2014 \u0438\u043c\u044f \u043d\u043e\u0434\u044b \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435<\/p>\n<h3><b>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/b><\/h3>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">plsq #SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT;   00:00:31.445829 (1 \u0441\u0442\u0440\u043e\u043a\u0430) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u0432\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e Insert\u2019\u043e\u0432 \u2014 \u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f. \u041d\u0430 hiload \u0431\u0430\u0437\u0430\u0445 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0443\u043b\u044e.<\/p>\n<h3><b>\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 Slot &#8216;repmgr_slot_\u043d\u043e\u043c\u0435\u0440 \u0441\u043b\u043e\u0442\u0430&#8217; already exists as an active slot<\/b><\/h3>\n<p>  \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c postgresql \u043d\u0430 \u0442\u043e\u0439 \u043d\u043e\u0434\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres pg_ctl stop; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430 \u043d\u043e\u0434\u0435 master&#8217;e  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres  psql repmgr #select pg_drop_replication_slot('repmgr_slot_4'); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h3><b>\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 <\/b>INSERT \u0438\u043b\u0438 UPDATE \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u00abrepl_nodes\u00bb \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u041e\u0428\u0418\u0411\u041a\u0410: INSERT \u0438\u043b\u0438 UPDATE \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u00abrepl_nodes\u00bb \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u00abrepl_nodes_upstream_node_id_fkey\u00bb <br \/>  DETAIL: \u041a\u043b\u044e\u0447 (upstream_node_id)=(-1) \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u00abrepl_nodes\u00bb.<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0434\u0430\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u0432\u0435\u0441\u0442\u0438 \u0443\u043f\u0430\u0432\u0448\u0443\u044e \u043d\u043e\u0434\u0443 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 switchover \u043b\u044e\u0431\u043e\u0439 \u043d\u043e\u0434\u044b \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435(standby)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr -f \/etc\/repmgr.conf standby switchover <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  Standby \u0441\u0442\u0430\u043d\u0435\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c<br \/>  \u041d\u0430 \u201c\u0421\u0442\u0430\u0440\u043e\u043c \u041c\u0430\u0441\u0442\u0435\u0440\u0435\u201d \u0441\u0442\u0430\u0432\u0448\u0435\u043c standby   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">repmgr -f \/etc\/repmgr.conf standby follow <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h3><b>\u041e\u0448\u0438\u0431\u043a\u0430 \u0412\u0410\u0416\u041d\u041e: \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 &quot;\/var\/run\/postgresql\/9.6-main.pg_stat_tmp&quot;:<\/b><\/h3>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">su postgres mkdir -p \/var\/run\/postgresql\/9.6-main.pg_stat_tmp <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h3><b>\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 no password supplied.<\/b><\/h3>\n<p>  \u041f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043c\u044b \u0441\u043b\u0438\u043b\u0438 \u0441 \u043d\u043e\u0434\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 <br \/>  \u201cno password supplied\u201d<br \/>  \u041d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0441 \u043d\u0435\u0439 \u0434\u043e\u043b\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430, \u0432\u0438\u0434\u0438\u043c\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0435 \u0441\u043c\u043e\u0433 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f. <\/p>\n<h3><b>Backup \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430<\/b><\/h3>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0411\u044d\u043a\u0430\u043f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">pg_dumpall dbname &gt; gzip &gt; filename.gz <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h3><b>\u0421\u043a\u0440\u0438\u043f\u0442 \u0431\u044d\u043a\u0430\u043f\u0430 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 Postgres<\/b><\/h3>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">backup_pg.sh<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/bash DBNAMES=&quot;db1 db2 db3&quot;   DATE_Y=`\/bin\/date '+%y'` DATE_M=`\/bin\/date '+%m'` DATE_D=`\/bin\/date '+%d'` SERVICE=&quot;pgdump&quot; #DB_NAME=&quot;repmgr&quot;;  #`psql -l | awk '{print $1}' ` for DB_NAME in $DBNAMES do \techo &quot;CREATING DIR \/Backup\/20${DATE_Y}\/${DATE_M}\/${DATE_D}\/${DB_NAME} &quot; \tBACKUP_DIR=&quot;\/Backup\/20${DATE_Y}\/${DATE_M}\/${DATE_D}\/${DB_NAME}&quot; \tmkdir -p $BACKUP_DIR; \t\tpg_dump  -Fc --verbose  ${DB_NAME} | gzip &gt;  $BACKUP_DIR\/${DB_NAME}.gz \t\t# \u0414\u0435\u043b\u0430\u0435\u043c dump \u0431\u0430\u0437\u044b \u0431\u0435\u0437 \u0434\u0430\u0442\u044b, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0445 \u043d\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \t\tpg_dump  -Fc -s -f $BACKUP_DIR\/${DB_NAME}_only_shema ${DB_NAME}  \t\t\/bin\/sleep 2; \t\t# \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f \t\tpg_restore -l $BACKUP_DIR\/${DB_NAME}_only_shema | grep FUNCTION &gt; $BACKUP_DIR\/function_list \t\tdone    ##\u041a\u0430\u043a \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438  ######################### #pg_restore -h localhost -U username -d \u0438\u043c\u044f_\u0431\u0430\u0437\u044b -L function_list db_dump ########################   ### \u041a\u0410\u041a \u0412\u041e\u0421\u0421\u0422\u0410\u041d\u041e\u0412\u0418\u0422\u042c \u041e\u0414\u041d\u0423 \u0422\u0410\u0411\u041b\u0418\u0426\u0423 \u0418\u0417 \u0411\u042d\u041a\u0410\u041f\u0410, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 payment. #pg_restore --dbname db1 --table=table1 \u0438\u043c\u044f\u0434\u0430\u043c\u043f\u0430\u0411\u0414 ####\u0415\u0421\u041b\u0418 \u0416\u0415 \u0412\u042b \u0425\u041e\u0422\u0418\u0422\u0415 \u0421\u041b\u0418\u0422\u042c \u0422\u0410\u0411\u041b\u0418\u0426\u0423 \u0412 \u041f\u0423\u0421\u0422\u0423\u042e \u0411\u0410\u0417\u0423, \u0422\u041e \u041d\u0415\u041e\u0411\u0425\u041e\u0414\u0418\u041c\u041e \u0412\u041e\u0421\u0421\u041e\u0417\u0414\u0410\u0422\u042c \u0421\u0422\u0420\u0423\u041a\u0422\u0423\u0420\u0423 \u0411\u0414 ###pg_restore --dbname ldb1  \u0438\u043c\u044f\u0434\u0430\u043c\u043f\u0430\u0411\u0414_only_shema <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h1><b>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/b><\/h1>\n<p>  \u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u0438\u0442\u043e\u0433\u0435:<br \/>  -\u043a\u043b\u0430\u0441\u0442\u0435\u0440 master-standby \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u043d\u043e\u0434;<br \/>  -\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 failover \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u043a\u0430\u0437\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0430(\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e repmgr\u2019a);<br \/>  -\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438(\u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435) \u0447\u0435\u0440\u0435\u0437 haproxy \u0438 pgbouncer(\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0441\u0435\u0430\u043d\u0441\u043e\u0432);<br \/>  -\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0442\u043a\u0430\u0437\u0430 \u2014 keepalived \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442 ip \u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u043d\u043e\u0434\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u201c\u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0430\u201d \u0434\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u043a\u0430\u0437\u0430;<br \/>   \u2014 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f(\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043a\u0430\u0437\u0430\u0432\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440) \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e\u0439 \u2014 \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f);<br \/>   \u2014 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2014 repmgr \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e bash \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432;<br \/>   \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u201c\u043f\u043e\u0434 \u0441\u0435\u0431\u044f\u201d.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439, \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0436\u0435, \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0441\u0442\u043e\u0438\u0442 \u0441\u043e \u0432\u0441\u0435\u043c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c HA \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0431\u0430\u0437\u0435 Postgresql \u0438 \u0441\u0430\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 Faiover.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/314000\/\"> https:\/\/habrahabr.ru\/post\/314000\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a17\/d60\/054\/a17d600549ef46759aa32c7c22b4a2fc.png\" alt=\"image\"\/><br \/>   \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <b>\u00abfailover\u00bb <\/b> \u0432 Postgresql \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445. \u0414\u043b\u044f \u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u0435\u0440\u0430 \u2014 \u044d\u0442\u043e \u0437\u0430\u043b\u043e\u0433 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443. \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445 \u2014 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f, \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u043a\u0430\u0437\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0434\u0440\u0443\u0433\u0430\u044f \u043d\u043e\u0434\u0430(standby) \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u00ab\u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c\u00bb, \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u043e\u0434\u044b standby \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u043d\u043e\u0432\u044b\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<br \/>  \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c repmgr \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e Failover \u2014 autofailover, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0442\u0440\u043e\u044f \u043d\u043e\u0434\u044b-\u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0431\u0435\u0437 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430, \u0447\u0442\u043e \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f UPTIME. \u0414\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c telegram.<\/p>\n<p>   \u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0411\u0414 \u043d\u0430 Postgresql + \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f + \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430 + failover(\u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c). \u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0447\u0442\u043e \u0442\u043e \u0438 \u0435\u0441\u0442\u044c, \u043d\u043e \u0432\u0441\u0451 \u043e\u043d\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0435 \u0438\u043b\u0438 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e. \u0411\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0443 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432, \u0440\u0435\u0448\u0438\u0432\u0448\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0438\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439, \u0432\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e \u0432\u0441\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438.   <\/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-280252","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/280252","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=280252"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/280252\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}