{"id":54616,"date":"2019-12-30T00:00:00","date_gmt":"2019-12-29T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/postroenie-klastera-postgresql-vysokoj-dostupnosti-s-ispolzovaniem-patroni-etcd-haproxy"},"modified":"2020-02-18T14:02:39","modified_gmt":"2020-02-18T11:02:39","slug":"postroenie-klastera-postgresql-vysokoj-dostupnosti-s-ispolzovaniem-patroni-etcd-haproxy","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postroenie-klastera-postgresql-vysokoj-dostupnosti-s-ispolzovaniem-patroni-etcd-haproxy","title":{"rendered":"Nd\u00ebrtimi i nj\u00eb klasteri PostgreSQL me disponibilitet t\u00eb lart\u00eb duke p\u00ebrdorur Patroni, etcd, HAProxy","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>\u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c.<\/p>\n<p><\/p>\n<p>\u041d\u0435 \u0437\u043d\u0430\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043a\u0430\u043a \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 enviroment \u043a\u0430\u043a \u0443 \u0430\u0432\u0442\u043e\u0440\u0430, \u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u044e, \u0432 \u0447\u0435\u043c \u0442\u0443\u0442 \u0434\u0435\u043b\u043e, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437, \u044f \u0440\u0435\u0448\u0438\u043b \u2014 \u0430 \u043d\u0430\u043f\u0438\u0448\u0443-\u043a\u0430 \u044f \u0441\u0432\u043e\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0422\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h2 id=\"gaydy-v-internete\">\u0413\u0430\u0439\u0434\u044b \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435<\/h2>\n<p><\/p>\n<p>\u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043d\u0435 \u0441\u0442\u0440\u0430\u0434\u0430\u0435\u0442 \u043e\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0433\u0430\u0439\u0434\u043e\u0432, \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432, step-by-step \u0438 \u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439. \u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u0431\u044b\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL, \u0433\u043b\u0430\u0432\u043d\u044b\u043c\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441 Master-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0432\u0441\u0435 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u0432\u043e\u0434 \u0440\u0435\u0437\u0435\u0440\u0432\u0430 \u043f\u0440\u0438 \u043e\u0442\u043a\u0430\u0437\u0435 Master-\u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p><\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0431\u044b\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0441\u0442\u0435\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439:<\/p>\n<p><\/p>\n<ul>\n<li>PostgreSQL \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0421\u0423\u0411\u0414<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/zalando\/patroni\" rel=\"nofollow\">Patroni<\/a><\/noindex> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/li>\n<li>etcd \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u043b\u044f Patroni<\/li>\n<li>HAproxy \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0431\u0430\u0437\u0443<\/li>\n<\/ul>\n<p><\/p>\n<h2 id=\"ustanovka\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<p><\/p>\n<p>\u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u2014 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Patroni, etcd, HAProxy.<\/p>\n<p><\/p>\n<p>\u0412\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u041e\u0421 Debian 10.<\/p>\n<p><\/p>\n<h3 id=\"etcd\">etcd<\/h3>\n<p><\/p>\n<p>\u041d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c etcd \u043d\u0430 \u0442\u0435\u0445 \u0436\u0435 \u043c\u0430\u0448\u0438\u043d\u0430\u0445, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f patroni \u0438 postgresql, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f etcd \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a\u0438. \u041d\u043e \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043c\u044b \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a.<br \/>\n\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c etcd.<\/p>\n<p><\/p>\n<pre><code class=\"bash\">#!\/bin\/bash\napt-get update\napt-get install etcd<\/code><\/pre>\n<p>\n<b class=\"spoiler_title\">\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432 \u0444\u0430\u0439\u043b \/etc\/default\/etcd<\/b><\/p>\n<h1 id=\"member\">[member]<\/h1>\n<p><\/p>\n<p>ETCD_NAME=datanode1 # hostname \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b<br \/>\nETCD_DATA_DIR=&#187;\/var\/lib\/etcd\/default.etcd&#187;<\/p>\n<p><\/p>\n<h1 id=\"all-ip-adresses-should-be-valid-lister-peer-client-etc-should-be-set-to-ip-address-of-host\">ALL IP ADRESSES SHOULD BE VALID. LISTER PEER, CLIENT etc SHOULD BE SET TO IP ADDRESS OF HOST<\/h1>\n<p><\/p>\n<p>ETCD_LISTEN_PEER_URLS=&#187;<noindex><a rel=\"nofollow\" href=\"http:\/\/192.168.0.143:2380\" rel=\"nofollow\">http:\/\/192.168.0.143:2380<\/a><\/noindex>&#187; # \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b<br \/>\nETCD_LISTEN_CLIENT_URLS=&#187;<noindex><a rel=\"nofollow\" href=\"http:\/\/192.168.0.143:2379,http:\/\/127.0.0.1:2379\" rel=\"nofollow\">http:\/\/192.168.0.143:2379,http:\/\/127.0.0.1:2379<\/a><\/noindex>&#187; # \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b<\/p>\n<p><\/p>\n<h1 id=\"cluster\">[cluster]<\/h1>\n<p><\/p>\n<p>ETCD_INITIAL_ADVERTISE_PEER_URLS=&#187;<noindex><a rel=\"nofollow\" href=\"http:\/\/192.168.0.143:2380\" rel=\"nofollow\">http:\/\/192.168.0.143:2380<\/a><\/noindex>&#187; # \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b<br \/>\nETCD_INITIAL_CLUSTER=&#187;datanode1=<noindex><a rel=\"nofollow\" href=\"http:\/\/192.168.0.143:2380,datanode2=http:\/\/192.168.0.144:2380,datanode3=http:\/\/192.168.0.145:2380\" rel=\"nofollow\">http:\/\/192.168.0.143:2380,datanode2=http:\/\/192.168.0.144:2380,datanode3=http:\/\/192.168.0.145:2380<\/a><\/noindex>&#187; # \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0441\u0435\u0445 \u043c\u0430\u0448\u0438\u043d \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 etcd<br \/>\nETCD_INITIAL_CLUSTER_STATE=&#187;new&#187;<br \/>\nETCD_INITIAL_CLUSTER_TOKEN=&#187;etcd-cluster-1&#8243;<br \/>\nETCD_ADVERTISE_CLIENT_URLS=&#187;<noindex><a rel=\"nofollow\" href=\"http:\/\/192.168.0.143:2379\" rel=\"nofollow\">http:\/\/192.168.0.143:2379<\/a><\/noindex>&#187; # \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b<\/p>\n<p><\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<p><\/p>\n<pre><code class=\"bash\">systemctl restart etcd<\/code><\/pre>\n<p><\/p>\n<h3 id=\"postgresql-96--patroni\">PostgreSQL 9.6 + patroni<\/h3>\n<p><\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0440\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u041f\u041e. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0430\u0448\u0438\u043d, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0435 \u043c\u043e\u0435\u043c\u0443 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0443, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 (\u043f\u043e\u0447\u0442\u0438) \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430 \u0432\u0430\u0441. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0438\u0437-\u043f\u043e\u0434 root.<\/p>\n<p><\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044e PostgreSQL 9.6, \u044d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 PostgreSQL.<\/p>\n<p><\/p>\n<pre><code class=\"bash\">#!\/bin\/bash\napt-get install gnupg -y\necho \"deb http:\/\/apt.postgresql.org\/pub\/repos\/apt\/ buster-pgdg main\" &gt;&gt; \/etc\/apt\/sources.list\nwget --quiet -O - https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc | apt-key add -\napt-get update\napt-get install postgresql-9.6 python3-pip python3-dev libpq-dev -y\nsystemctl stop postgresql\npip3 install --upgrade pip\npip install psycopg2\npip install patroni[etcd]\necho \"\n[Unit]\nDescription=Runners to orchestrate a high-availability PostgreSQL\nAfter=syslog.target network.target\n\n[Service]\nType=simple\n\nUser=postgres\nGroup=postgres\n\nExecStart=\/usr\/local\/bin\/patroni \/etc\/patroni.yml\n\nKillMode=process\n\nTimeoutSec=30\n\nRestart=no\n\n[Install]\nWantedBy=multi-user.targ\n\" &gt; \/etc\/systemd\/system\/patroni.service\nmkdir -p \/data\/patroni\nchown postgres:postgres \/data\/patroni\nchmod 700 \/data\/patroni\u043f\u043e\ntouch \/etc\/patroni.yml<\/code><\/pre>\n<p><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0444\u0430\u0439\u043b \/etc\/patroni.yml \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0432 ip-\u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u043d\u0430 \u0430\u0434\u0440\u0435\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0432\u044b.<br \/>\n\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c yaml. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0430 \u0441\u0432\u043e\u0438, \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. <\/p>\n<p>\n<b class=\"spoiler_title\">\/etc\/patroni.yml<\/b><\/p>\n<pre><code class=\"plaintext\">scope: pgsql # \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445\nnamespace: \/cluster\/ # \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445\nname: postgres1 # \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445\n\nrestapi:\n    listen: 192.168.0.143:8008 # \u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u0439 \u043d\u043e\u0434\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\n    connect_address: 192.168.0.143:8008 # \u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u0439 \u043d\u043e\u0434\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\n\netcd:\n    hosts: 192.168.0.143:2379,192.168.0.144:2379,192.168.0.145:2379 # \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u0435 \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0432\u0430\u0448\u0438 \u043d\u043e\u0434\u044b, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0435 etcd \u043d\u0430 \u043d\u0438\u0445 \u0436\u0435\n\n# this section (bootstrap) will be written into Etcd:\/&lt;namespace&gt;\/&lt;scope&gt;\/config after initializing new cluster\n# and all other cluster members will use it as a `global configuration`\nbootstrap:\n    dcs:\n        ttl: 100\n        loop_wait: 10\n        retry_timeout: 10\n        maximum_lag_on_failover: 1048576\n        postgresql:\n            use_pg_rewind: true\n            use_slots: true\n            parameters:\n                    wal_level: replica\n                    hot_standby: \"on\"\n                    wal_keep_segments: 5120\n                    max_wal_senders: 5\n                    max_replication_slots: 5\n                    checkpoint_timeout: 30\n\n    initdb:\n    - encoding: UTF8\n    - data-checksums\n    - locale: en_US.UTF8\n    # init pg_hba.conf \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430 \u0412\u0421\u0415\u0425 \u043c\u0430\u0448\u0438\u043d, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435\n    pg_hba:\n    - host replication postgres ::1\/128 md5\n    - host replication postgres 127.0.0.1\/8 md5\n    - host replication postgres 192.168.0.143\/24 md5\n    - host replication postgres 192.168.0.144\/24 md5\n    - host replication postgres 192.168.0.145\/24 md5\n    - host all all 0.0.0.0\/0 md5\n\n    users:\n        admin:\n            password: admin\n            options:\n                - createrole\n                - createdb\n\npostgresql:\n    listen: 192.168.0.143:5432 # \u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u0439 \u043d\u043e\u0434\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\n    connect_address: 192.168.0.143:5432 # \u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u0439 \u043d\u043e\u0434\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\n    data_dir: \/data\/patroni # \u044d\u0442\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u043a\u0440\u0438\u043f\u0442, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430\n    bin_dir:  \/usr\/lib\/postgresql\/9.6\/bin # \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u043f\u0443\u0442\u044c \u0434\u043e \u0432\u0430\u0448\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 postgresql\n    pgpass: \/tmp\/pgpass\n    authentication:\n        replication:\n            username: postgres\n            password: postgres\n        superuser:\n            username: postgres\n            password: postgres\n    create_replica_methods:\n        basebackup:\n            checkpoint: 'fast'\n    parameters:\n        unix_socket_directories: '.'\n\ntags:\n    nofailover: false\n    noloadbalance: false\n    clonefrom: false\n    nosync: false<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0432 \u0444\u0430\u0439\u043b \/etc\/patroni.yml \u043d\u0430 \u0432\u0441\u0435\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445.<\/p>\n<p><\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445<\/p>\n<p><\/p>\n<pre><code class=\"bash\">systemctl start patroni\nsystemctl start postgresql<\/code><\/pre>\n<p><\/p>\n<p>\u041f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435 \u043e\u043a\u043e\u043b\u043e 30 \u0441\u0435\u043a\u0443\u043d\u0434, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u044d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<p><\/p>\n<h3 id=\"haproxy\">HAproxy<\/h3>\n<p><\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0447\u0443\u0434\u0435\u0441\u043d\u044b\u0439 HAproxy \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430. Master-\u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \u043c\u0430\u0448\u0438\u043d\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442 HAproxy.<\/p>\n<p><\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u0448\u0438\u043d\u0443 \u0441 HAproxy \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043e\u0442\u043a\u0430\u0437\u0430, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 Docker, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 K8&#8217;s \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u043c.<\/p>\n<p><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0433\u0434\u0435 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u2014 Dockerfile \u0438 haproxy.cfg. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043d\u0435\u0435.<\/p>\n<p>\n<b class=\"spoiler_title\">Dockerfile<\/b><\/p>\n<pre><code class=\"plaintext\">FROM ubuntu:latest\n\nRUN apt-get update \n    &amp;&amp; apt-get install -y haproxy rsyslog \n    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*\n\nRUN mkdir \/run\/haproxy\n\nCOPY haproxy.cfg \/etc\/haproxy\/haproxy.cfg\n\nCMD haproxy -f \/etc\/haproxy\/haproxy.cfg &amp;&amp; tail -F \/var\/log\/haproxy.log<\/code><\/pre>\n<p><\/p>\n<p>\u0411\u0443\u0434\u044c\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u0432 \u0442\u0440\u0435\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0444\u0430\u0439\u043b\u0430 haproxy.cfg \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0430\u0448\u0438\u0445 \u043c\u0430\u0448\u0438\u043d. HAproxy \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a Patroni, \u0432 HTTP-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 master-\u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c 200, \u0430 replica \u2014 503.<\/p>\n<p>\n<b class=\"spoiler_title\">haproxy.cfg<\/b><\/p>\n<pre><code class=\"plaintext\">global\n    maxconn 100\n\ndefaults\n    log global\n    mode tcp\n    retries 2\n    timeout client 30m\n    timeout connect 4s\n    timeout server 30m\n    timeout check 5s\n\nlisten stats\n    mode http\n    bind *:7000\n    stats enable\n    stats uri \/\n\nlisten postgres\n    bind *:5000\n    option httpchk\n    http-check expect status 200\n    default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions\n    server postgresql1 192.168.0.143:5432 maxconn 100 check port 8008\n    server postgresql2 192.168.0.144:5432 maxconn 100 check port 8008\n    server postgresql3 192.168.0.145:5432 maxconn 100 check port 8008\n<\/code><\/pre>\n<p><\/p>\n<p>\u041d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 &#171;\u043b\u0435\u0436\u0430\u0442&#187; \u043e\u0431\u0430 \u043d\u0430\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0441 \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043e\u0440\u0442\u043e\u0432:<\/p>\n<p><\/p>\n<pre><code class=\"bash\">docker build -t my-haproxy .\ndocker run -d -p5000:5000 -p7000:7000 my-haproxy <\/code><\/pre>\n<p><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u0442\u043a\u0440\u044b\u0432 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0441 HAproxy \u0438 \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u043e\u0440\u0442 7000, \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443.<\/p>\n<p><\/p>\n<p>\u0412 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 UP \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c, \u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 DOWN. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 503 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 HAproxy. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442.<\/p>\n<p><\/p>\n<h3 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p><\/p>\n<p>\u0412\u044b \u0432\u043e\u0441\u0445\u0438\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b! \u0412\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0437\u0430 30 \u043c\u0438\u043d\u0443\u0442 \u0432\u044b \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0432\u0432\u043e\u0434\u043e\u043c \u0440\u0435\u0437\u0435\u0440\u0432\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c <noindex><a rel=\"nofollow\" href=\"https:\/\/patroni.readthedocs.io\/en\/latest\/\" rel=\"nofollow\">\u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 Patroni<\/a><\/noindex>, \u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 \u0435\u0435 \u0447\u0430\u0441\u0442\u044c\u044e, \u043a\u0430\u0441\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u044b patronictl, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0432\u0430\u0448\u0438\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<\/p>\n<p><\/p>\n<p>\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e!<\/p>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/482314\/\">habr.com<\/a><\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c. \u041d\u0435 \u0437\u043d\u0430\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043a\u0430\u043a \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 enviroment \u043a\u0430\u043a [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-54616","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c. \u041d\u0435 \u0437\u043d\u0430\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043a\u0430\u043a \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 enviroment \u043a\u0430\u043a\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postroenie-klastera-postgresql-vysokoj-dostupnosti-s-ispolzovaniem-patroni-etcd-haproxy\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"sq_AL\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Patroni, etcd, HAProxy | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c. \u041d\u0435 \u0437\u043d\u0430\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043a\u0430\u043a \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 enviroment \u043a\u0430\u043a\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postroenie-klastera-postgresql-vysokoj-dostupnosti-s-ispolzovaniem-patroni-etcd-haproxy\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-12-29T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:02:39+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Patroni, etcd, HAProxy | ProHoster","description":"\u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c. \u041d\u0435 \u0437\u043d\u0430\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043a\u0430\u043a \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 enviroment \u043a\u0430\u043a","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postroenie-klastera-postgresql-vysokoj-dostupnosti-s-ispolzovaniem-patroni-etcd-haproxy","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"sq_AL","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Patroni, etcd, HAProxy | ProHoster","og:description":"\u0422\u0430\u043a \u0443\u0436 \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c. \u041d\u0435 \u0437\u043d\u0430\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043a\u0430\u043a \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 enviroment \u043a\u0430\u043a","og:url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postroenie-klastera-postgresql-vysokoj-dostupnosti-s-ispolzovaniem-patroni-etcd-haproxy","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-12-29T21:00:00+00:00","article:modified_time":"2020-02-18T11:02:39+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"54616","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-24 12:06:19","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 10:43:41","updated":"2026-01-24 12:06:19"},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/54616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/comments?post=54616"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/54616\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=54616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=54616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=54616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}