{"id":401983,"date":"2024-06-29T16:12:58","date_gmt":"2024-06-29T16:12:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=401983"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T16:12:58","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=401983","title":{"rendered":"<span>\u041e\u043f\u044b\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL \u043d\u0430 \u0431\u0430\u0437\u0435 Patroni<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u043e\u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u0438\u043b\u043e\u0441\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c Patroni \u043d\u0430 \u043d\u043e\u0432\u043e\u0435 \u0436\u0435\u043b\u0435\u0437\u043e. \u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u2014 \u044f \u0438 \u043d\u0435 \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/71f\/d64\/491\/71fd6449110f3199219161664c278ecb.png\" width=\"780\" height=\"450\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/71f\/d64\/491\/71fd6449110f3199219161664c278ecb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438 \u043d\u0430 \u043c\u044b\u0441\u043b\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u044b\u0442\u043e\u043c. \u0412 \u044d\u0442\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0448\u0430\u0433\u0438 \u0438 \u043d\u044e\u0430\u043d\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u041f\u041e: PostgreSQL 11.13, Patroni 2.1.1, etcd 3.2.17 (API version 2).<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p><a href=\"https:\/\/github.com\/zalando\/patroni\"><strong><u>Patroni<\/u><\/strong><\/a> \u2014 \u044d\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 Open Source-\u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043b\u044f \u0421\u0423\u0411\u0414 PostgreSQL \u043e\u0442 Zalando, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Python \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438. \u041f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 Patroni \u0441\u0442\u043e\u0438\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (streaming replication), \u0440\u0430\u0431\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 WAL (Write-Ahead Log). \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u043d\u043e\u0441\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0440\u0432\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 WAL. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 WAL \u0421\u0423\u0411\u0414 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>fsync<\/code>, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0434\u0438\u0441\u043a. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0421\u0423\u0411\u0414 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 WAL \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u041f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f<\/strong> \u2014 \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 WAL \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u043a \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a \u0441 \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0442\u0430\u043a \u0438 \u0441 \u0440\u0435\u043f\u043b\u0438\u043a (\u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e). \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0441 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 <code>hot_standby<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0421\u0423\u0411\u0414 \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e. \u041f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f<\/strong> \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440-\u0443\u0437\u043b\u0435 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437 WAL \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p><strong>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f<\/strong> \u2014 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 WAL \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0438 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 PostgreSQL.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Patroni \u0437\u043d\u0430\u043b\u0438 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430, \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Distributed Configuration Store (DCS) \u2014 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 DCS \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0442\u0438\u043f\u0430 key-value, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: Consul, etcd (v3), ZooKeeper. \u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 etcd.<\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438. \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u043e\u0434 \u043a\u043b\u044e\u0447, \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439: \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u0441\u0442\u043e, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u0426\u041e\u0414\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0438\u0441\u043a. \u041a\u0430\u043a \u0431\u044b\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438? \u041e\u0442\u0432\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u2014 \u043c\u0438\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u0421\u0423\u0411\u0414 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043a\u0430\u0437\u0430\u043d\u043e 3 \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0445 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0430.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<ol>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL \u043d\u0430 \u0431\u0430\u0437\u0435 Patroni, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd (\u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f Patroni), \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 (\u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Patroni);<\/p>\n<\/li>\n<li>\n<p>\u0441\u0435\u0440\u0430\u044f \u0441\u0435\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u0441 PostgreSQL \u0441 \u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u0435\u0439 192.168.0.0\/24;<\/p>\n<\/li>\n<li>\n<p>load balancer, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430 master-\u0443\u0437\u0435\u043b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PgSQL.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043d\u0438\u0436\u0435 \u044f \u0431\u0443\u0434\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0443\u0437\u043a\u0438\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0441\u0442\u0435\u043d\u0434\u0435. \u0423\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0438\u0436\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/edf\/6fd\/2b8\/edf6fd2b863828110f642fdcf7f8ec74.png\" width=\"766\" height=\"601\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/edf\/6fd\/2b8\/edf6fd2b863828110f642fdcf7f8ec74.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 \u0443\u0437\u043b\u0430\u043c\u0438 \u0438 load balancer\u2019\u043e\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0445\u043e\u0441\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e IP.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0443\u0437\u043b\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b <code>\/etc\/hosts<\/code>:<\/p>\n<pre><code class=\"bash\"># etcd 192.168.0.16    server-1 etcd1 192.168.0.9     server-2 etcd2 192.168.0.12    server-3 etcd3<\/code><\/pre>\n<p>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Patroni:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f9e\/95b\/6e5\/f9e95b6e53438969a5c2c06c21b684a0.png\" width=\"517\" height=\"111\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f9e\/95b\/6e5\/f9e95b6e53438969a5c2c06c21b684a0.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/patroni.yaml<\/code> \u043d\u0430 \u0443\u0437\u043b\u0435 <code>server-1<\/code>:<\/p>\n<pre><code class=\"yaml\">scope: patroni_cluster name: server-1 namespace: \/patroni\/  restapi:   listen: 192.168.0.16:8008 # IP-\u0430\u0434\u0440\u0435\u0441 \u0443\u0437\u043b\u0430 \u0438 \u043f\u043e\u0440\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Patroni API   connect_address: 192.168.0.16:8008    authentication:     username: patroni     password: 'mysuperpassword'  etcd:   hosts: etcd1:2379,etcd2:2379,etcd3:2379  bootstrap:   dcs:     ttl: 30     loop_wait: 10     retry_timeout: 10     maximum_lag_on_failover: 1048576     synchronous_mode: false     postgresql:       use_pg_rewind: true       use_slots: true       parameters:         wal_level: hot_standby         synchronous_commit: off         hot_standby: \"on\"    initdb:   - encoding: UTF8   - data-checksums    pg_hba:   - local all postgres trust   - host postgres all 127.0.0.1\/32 md5   - host replication replicator 0.0.0.0\/0 md5   - host replication all 192.168.0.16\/32 trust # server-1   - host replication all 192.168.0.9\/32 trust  # server-2   - host replication all 192.168.0.12\/32 trust # server-3   - host all all 0.0.0.0\/0 md5    users:     admin:       password: 'mysuperpassword2'       options:         - createrole         - createdb  postgresql:   listen: 192.168.0.16:5432 # IP-\u0430\u0434\u0440\u0435\u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043f\u043e\u0440\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c  postgresql   connect_address: 192.168.0.16:5432    data_dir: \/data\/patroni   bin_dir: \/usr\/lib\/postgresql\/11\/bin   config_dir: \/data\/patroni   pgpass: \/tmp\/pgpass0   authentication:     replication:       username: replicator       password: 'mysuperpassword3'     superuser:       username: postgres       password: 'mysuperpassword4'     rewind:       username: rewind_user       password: 'mysuperpassword5'   parameters:     unix_socket_directories: '\/tmp'  tags:     nofailover: false     noloadbalance: false     clonefrom: false     nosync: false<\/code><\/pre>\n<p>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 etcd:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/82b\/46a\/42b\/82b46a42bc898afd2212e0b18418e164.png\" width=\"844\" height=\"52\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/82b\/46a\/42b\/82b46a42bc898afd2212e0b18418e164.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/default\/etcd<\/code> \u043d\u0430 \u0443\u0437\u043b\u0435 <code>server-1<\/code>:<\/p>\n<pre><code class=\"bash\">ETCD_LISTEN_PEER_URLS=\"http:\/\/127.0.0.1:2380,http:\/\/192.168.0.16:2380\" ETCD_LISTEN_CLIENT_URLS=\"http:\/\/127.0.0.1:2379,http:\/\/192.168.0.16:2379\" ETCD_INITIAL_CLUSTER=\"etcd1=http:\/\/etcd1:2380\" ETCD_INITIAL_CLUSTER_STATE=\"new-cluster\" ETCD_INITIAL_CLUSTER_TOKEN=\"myclustertoken\" ETCD_DATA_DIR=\"\/var\/lib\/etcd\" ETCD_ELECTION_TIMEOUT=\"5000\" ETCD_HEARTBEAT_INTERVAL=\"1000\" ETCD_NAME=\"etcd1\" ETCD_ADVERTISE_CLIENT_URLS=\"http:\/\/192.168.0.16:2379\" ETCD_INITIAL_ADVERTISE_PEER_URLS=\"http:\/\/192.168.0.16:2380\"<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/default\/etcd<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 etcd, \u0442. \u0435. \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0451\u043c, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430) \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 etcd. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <code>ETCD_DATA_DIR<\/code>.<\/p>\n<p><strong>\u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 #1, 2 \u0438 3 \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/strong>. \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL \u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd, \u043d\u0430\u0434\u0435\u043b\u044f\u044f \u043d\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0442\u043b\u0438\u0447\u0438\u044f\u043c\u0438 \u043e\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 PgSQL:<\/p>\n<ol>\n<li>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c endpoint\u2019\u044b \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 load balancer\u2019\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041d\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b PostgreSQL \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 master-\u0443\u0437\u043b\u0430 \u043f\u0440\u0438 failover.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 \u0431\u044b\u043b\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0426\u041e\u0414\u0430 \u0431\u044b\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d VPN \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f L2-\u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438. \u041d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0443, \u0438 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u043f\u043e\u043c\u0435\u0449\u0443 \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0432 \u0441\u0435\u0442\u044c 192.168.0.0\/24, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c \u0441\u0432\u044f\u0437\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 broadcast-\u0434\u043e\u043c\u0435\u043d\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0443\u0437\u043b\u043e\u0432 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/af5\/c7c\/6e4\/af5c7c6e482cdb930d8fd9ce043d3cff.png\" width=\"718\" height=\"844\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/af5\/c7c\/6e4\/af5c7c6e482cdb930d8fd9ce043d3cff.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041f\u043b\u0430\u043d \u043f\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 etcd-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 PostgreSQL-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Patroni;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434 \u0438\u0437 PostgreSQL-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u00ab\u0441\u0442\u0430\u0440\u044b\u0445\u00bb \u0443\u0437\u043b\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434 \u0438\u0437 etcd-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u00ab\u0441\u0442\u0430\u0440\u044b\u0445\u00bb \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c!<\/p>\n<h3>\u0428\u0430\u0433 \u21161. \u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd<\/h3>\n<p><strong><em>\u0412\u0430\u0436\u043d\u043e! <\/em><\/strong><em>\u0422\u0430\u043a \u043a\u0430\u043a etcd (\u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0442\u0438\u043f\u0430 key-value) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 Patroni, \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u0445, \u0438\u043c\u0435\u043b \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b \u043e\u0442 \u0441\u0430\u043c\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0441 Patroni. \u041d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0441\u0442\u0435\u043d\u0434\u0430 \u044f \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043b \u0438 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd \u043d\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445, \u0447\u0442\u043e \u0438 PostgreSQL \u0441 Patroni.<\/em><\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043b\u0438\u0434\u0435\u0440\u0430 \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c (\u0438 \u043d\u043e\u0432\u044b\u043c, \u0438 \u0441\u0442\u0430\u0440\u044b\u043c) \u0431\u044b\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u043e\u0432\u044b\u0439 \u043b\u0438\u0434\u0435\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043d\u0435\u0441\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>\/etc\/hosts<\/code> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0448\u0435\u0441\u0442\u0438 \u0443\u0437\u043b\u043e\u0432 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443 (\u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a):<\/p>\n<pre><code class=\"bash\"># etcd 192.168.0.16    server-1 etcd1 192.168.0.9      server-2 etcd2 192.168.0.12    server-3 etcd3 192.168.0.13    new_server-1 etcd-1# IP-\u0430\u0434\u0440\u0435\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 192.168.0.17    new_server-2 etcd-2# ... \u0432\u0442\u043e\u0440\u043e\u0433\u043e 192.168.0.18    new_server-3 etcd-3# ... \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd. \u041d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 <code>new_server-1<\/code> (192.168.0.13) \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 etcd \u043d\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# systemctl status etcd \u25cf etcd.service - etcd - highly-available key value store    Loaded: loaded (\/lib\/systemd\/system\/etcd.service; disabled; vendor preset: enabled)    Active: inactive (dead)      Docs: https:\/\/github.com\/coreos\/etcd            man:etcd<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u0447\u0438\u0441\u0442\u0438\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>\/var\/lib\/etcd<\/code>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>\/etc\/default\/etcd<\/code>:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# rm -rf \/var\/lib\/etcd\/*<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0444\u0430\u0439\u043b <code>\/etc\/default\/etcd<\/code> \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code class=\"bash\">ETCD_LISTEN_PEER_URLS=\"http:\/\/192.168.0.13:2380,http:\/\/127.0.0.1:2380\" ETCD_LISTEN_CLIENT_URLS=\"http:\/\/192.168.0.13:2379,http:\/\/127.0.0.1:2379\" ETCD_INITIAL_CLUSTER_TOKEN=\"myclustertoken\" ETCD_DATA_DIR=\"\/var\/lib\/etcd\" ETCD_ELECTION_TIMEOUT=\"5000\" ETCD_HEARTBEAT_INTERVAL=\"1000\" ETCD_ADVERTISE_CLIENT_URLS=\"http:\/\/192.168.0.13:2379\" ETCD_INITIAL_ADVERTISE_PEER_URLS=\"http:\/\/192.168.0.13:2380\"<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 etcd-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>server-1<\/code>) \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">root@server-1:~# etcdctl member list 862db4122a92dc3: name=etcd3 peerURLs=http:\/\/etcd3:2379 clientURLs=http:\/\/192.168.0.12:2379 isLeader=false 46d7a702fdb60fff: name=etcd1 peerURLs=http:\/\/etcd1:2380 clientURLs=http:\/\/192.168.0.16:2379 isLeader=true d129ecfd4c627e1f: name=etcd2 peerURLs=http:\/\/etcd2:2379 clientURLs=http:\/\/192.168.0.9:2379 isLeader=false<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">root@server-1:~# etcdctl member add etcd-1 http:\/\/etcd-1:2380 Added member named etcd-1 with ID 6d299012c6ad9595 to cluster  ETCD_NAME=\"etcd-1\" ETCD_INITIAL_CLUSTER=\"etcd1=http:\/\/etcd1:2380,etcd-1=http:\/\/etcd-1:2380,etcd2=http:\/\/etcd2:2380,etcd3=http:\/\/etcd3:2380\" ETCD_INITIAL_CLUSTER_STATE=\"existing\"<\/code><\/pre>\n<p>Etcd \u0441\u043e\u043e\u0431\u0449\u0438\u043b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u043e\u0432\u043e\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 <code>\/etc\/default\/etcd<\/code> \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 <code>etcd-1<\/code> (<code>new_server-1<\/code>). \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 (\u043a \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u0442\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438):<\/p>\n<pre><code class=\"bash\">ETCD_LISTEN_PEER_URLS=\"http:\/\/192.168.0.13:2380,http:\/\/127.0.0.1:2380\" ETCD_LISTEN_CLIENT_URLS=\"http:\/\/192.168.0.13:2379,http:\/\/127.0.0.1:2379\" ETCD_INITIAL_CLUSTER_TOKEN=\"myclustertoken\" ETCD_DATA_DIR=\"\/var\/lib\/etcd\" ETCD_ELECTION_TIMEOUT=\"5000\" ETCD_HEARTBEAT_INTERVAL=\"1000\" ETCD_ADVERTISE_CLIENT_URLS=\"http:\/\/192.168.0.13:2379\" ETCD_INITIAL_ADVERTISE_PEER_URLS=\"http:\/\/192.168.0.13:2380\" ETCD_NAME=\"etcd-1\" ETCD_INITIAL_CLUSTER=\"etcd1=http:\/\/etcd1:2380,etcd-1=http:\/\/etcd-1:2380,etcd2=http:\/\/etcd2:2380,etcd3=http:\/\/etcd3:2380\" ETCD_INITIAL_CLUSTER_STATE=\"existing\"<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 etcd:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# etcdctl member list 46d7a702fdb60fff: name=etcd1 peerURLs=http:\/\/etcd1:2380 clientURLs=http:\/\/192.168.0.16:2379 isLeader=true 6d299012c6ad9595: name=etcd-1 peerURLs=http:\/\/etcd-1:2380 clientURLs=http:\/\/192.168.0.13:2379 isLeader=false c32185ccfd4b4b41: name=etcd2 peerURLs=http:\/\/etcd2:2380 clientURLs=http:\/\/192.168.0.9:2379 isLeader=false d56f1524a8fe199e: name=etcd3 peerURLs=http:\/\/etcd3:2380 clientURLs=http:\/\/192.168.0.12:2379 isLeader=false<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, <code>etcd-1<\/code> \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440. \u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0432 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 (<code>\/etc\/default\/etcd<\/code>), \u0433\u0434\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<pre><code class=\"bash\">root@new_server-2:~# etcdctl member list 40ebdfb25cac6924: name=etcd-2 peerURLs=http:\/\/etcd-2:2380 clientURLs=http:\/\/192.168.0.17:2379 isLeader=false 46d7a702fdb60fff: name=etcd1 peerURLs=http:\/\/etcd1:2380 clientURLs=http:\/\/192.168.0.16:2379 isLeader=true 6d299012c6ad9595: name=etcd-1 peerURLs=http:\/\/etcd-1:2380 clientURLs=http:\/\/192.168.0.13:2379 isLeader=false c32185ccfd4b4b41: name=etcd2 peerURLs=http:\/\/etcd2:2380 clientURLs=http:\/\/192.168.0.9:2379 isLeader=false d56f1524a8fe199e: name=etcd3 peerURLs=http:\/\/etcd3:2380 clientURLs=http:\/\/192.168.0.12:2379 isLeader=false<\/code><\/pre>\n<p>\u2026 \u0438 \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/default\/etcd<\/code>:<\/p>\n<pre><code class=\"bash\">ETCD_LISTEN_PEER_URLS=\"http:\/\/192.168.0.17:2380,http:\/\/127.0.0.1:2380\" ETCD_LISTEN_CLIENT_URLS=\"http:\/\/192.168.0.17:2379,http:\/\/127.0.0.1:2379\" ETCD_INITIAL_CLUSTER_TOKEN=\"myclustertoken\" ETCD_DATA_DIR=\"\/var\/lib\/etcd\" ETCD_ELECTION_TIMEOUT=\"5000\" ETCD_HEARTBEAT_INTERVAL=\"1000\" ETCD_ADVERTISE_CLIENT_URLS=\"http:\/\/192.168.0.17:2379\" ETCD_INITIAL_ADVERTISE_PEER_URLS=\"http:\/\/192.168.0.17:2380\" ETCD_NAME=\"etcd-2\" ETCD_INITIAL_CLUSTER=\"etcd-2=http:\/\/etcd-2:2380,etcd1=http:\/\/etcd1:2380,etcd-1=http:\/\/etcd-1:2380,etcd2=http:\/\/etcd2:2380,etcd3=http:\/\/etcd3:2380\" ETCD_INITIAL_CLUSTER_STATE=\"existing\"<\/code><\/pre>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0434\u043b\u044f \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"bash\">root@new_server-3:~# etcdctl member list 40ebdfb25cac6924: name=etcd-2 peerURLs=http:\/\/etcd-2:2380 clientURLs=http:\/\/192.168.0.17:2379 isLeader=false 46d7a702fdb60fff: name=etcd1 peerURLs=http:\/\/etcd1:2380 clientURLs=http:\/\/192.168.0.16:2379 isLeader=true 6c2e836d0c3a51c3: name=etcd-3 peerURLs=http:\/\/etcd-3:2380 clientURLs=http:\/\/192.168.0.18:2379 isLeader=false 6d299012c6ad9595: name=etcd-1 peerURLs=http:\/\/etcd-1:2380 clientURLs=http:\/\/192.168.0.13:2379 isLeader=false c32185ccfd4b4b41: name=etcd2 peerURLs=http:\/\/etcd2:2380 clientURLs=http:\/\/192.168.0.9:2379 isLeader=false d56f1524a8fe199e: name=etcd3 peerURLs=http:\/\/etcd3:2380 clientURLs=http:\/\/192.168.0.12:2379 isLeader=false<\/code><\/pre>\n<p>\u0424\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/default\/etcd<\/code>:<\/p>\n<pre><code class=\"bash\">ETCD_LISTEN_PEER_URLS=\"http:\/\/192.168.0.18:2380,http:\/\/127.0.0.1:2380\" ETCD_LISTEN_CLIENT_URLS=\"http:\/\/192.168.0.18:2379,http:\/\/127.0.0.1:2379\" ETCD_INITIAL_CLUSTER_TOKEN=\"myclustertoken\" ETCD_DATA_DIR=\"\/var\/lib\/etcd\" ETCD_ELECTION_TIMEOUT=\"5000\" ETCD_HEARTBEAT_INTERVAL=\"1000\" ETCD_ADVERTISE_CLIENT_URLS=\"http:\/\/192.168.0.18:2379\" ETCD_INITIAL_ADVERTISE_PEER_URLS=\"http:\/\/192.168.0.18:2380\" ETCD_NAME=\"etcd-3\" ETCD_INITIAL_CLUSTER=\"etcd-2=http:\/\/etcd-2:2380,etcd1=http:\/\/etcd1:2380,etcd-3=http:\/\/etcd-3:2380,etcd-1=http:\/\/etcd-1:2380,etcd2=http:\/\/etcd2:2380,etcd3=http:\/\/etcd3:2380\" ETCD_INITIAL_CLUSTER_STATE=\"existing\"<\/code><\/pre>\n<p>\u041c\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043b\u0438 etcd-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0441 \u0442\u0440\u0435\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u0434\u043e \u0448\u0435\u0441\u0442\u0438.<\/p>\n<h3>\u0428\u0430\u0433 \u21162. \u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL<\/h3>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043d\u0430\u0448\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PgSQL. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f Patroni, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/patroni.yaml<\/code> \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"yaml\">scope: patroni_cluster name: new_server-1 namespace: \/patroni\/  restapi:   listen: 192.168.0.13:8008   connect_address: 192.168.0.13:8008   authentication:     username: patroni     password: 'mynewpassword'  etcd:   hosts: etcd-1:2379,etcd-2:2379,etcd-3:2379  bootstrap:   dcs:     ttl: 30     loop_wait: 10     retry_timeout: 10     maximum_lag_on_failover: 1048576     synchronous_mode: false     postgresql:       use_pg_rewind: true       use_slots: true       parameters:         wal_level: hot_standby         synchronous_commit: off         hot_standby: \"on\"    initdb:   - encoding: UTF8   - data-checksums    pg_hba:   - local all postgres trust   - host postgres all 127.0.0.1\/32 md5   - host replication replicator 0.0.0.0\/0 md5   - host replication all 192.168.0.16\/32 trust # server-1   - host replication all 192.168.0.9\/32 trust  # server-2   - host replication all 192.168.0.12\/32 trust # server-3   - host all all 0.0.0.0\/0 md5    users:     admin:       password: 'mynewpassword2'       options:         - createrole         - createdb  postgresql:   listen: 192.168.0.13:5432   connect_address: 192.168.0.13:5432   data_dir: \/data\/patroni   bin_dir: \/usr\/lib\/postgresql\/11\/bin   config_dir: \/data\/patroni   pgpass: \/tmp\/pgpass0   authentication:     replication:       username: replicator       password: 'mynewpassord3'     superuser:       username: postgres       password: 'mynewpassord4'     rewind:       username: rewind_user       password: 'mynewpassword5'   parameters:     unix_socket_directories: '\/tmp'  tags:     nofailover: true     noloadbalance: true     clonefrom: false     nosync: false<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u041c\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 etcd \u0434\u043b\u044f Patroni \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 (\u0441\u043c. \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>hosts<\/code>\u00a0 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <code>etcd<\/code>), \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044f endpoint\u2019\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u043c\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b etcd \u0438\u0437 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0415\u0441\u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043a \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 etcd-1 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0430 \u043b\u0438\u0434\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442, \u0441\u043a\u0430\u0436\u0435\u043c, etcd2 (\u0435\u0433\u043e endpoint \u043c\u044b \u044f\u0432\u043d\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Patroni), \u0442\u043e etcd \u0441\u0430\u043c \u043e\u0442\u0434\u0430\u0441\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 endpoint \u043b\u0438\u0434\u0435\u0440\u0430 \u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 \u0447\u043b\u0435\u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c 2 \u0442\u0435\u0433\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438: <code>nofailover: true<\/code> \u0438 <code>noloadbalance: true<\/code>. \u041f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 target \u0434\u043b\u044f load balancer, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f\u0432\u043d\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u0438\u043c \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0433\u043e\u043d\u043a\u0435 \u0437\u0430 \u043b\u0438\u0434\u0435\u0440\u0441\u0442\u0432\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>data_dir<\/code> \u0438 <code>config_dir<\/code>. \u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u043b\u0438\u0441\u044c \u043e\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>postgresql.base.conf<\/code> \u043a\u0442\u043e-\u0442\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043b \u043f\u0443\u0442\u0438 \u043a \u044d\u0442\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c, \u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0438\u0435\u0434\u0443\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>pg_hba.conf<\/code> \u2014 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0443\u0437\u043b\u0430\u0445 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0445, \u0442\u0430\u043a \u0438 \u0441\u0442\u0430\u0440\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u0414\u0430, \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432 <code>patroni.yaml<\/code>, \u043d\u043e \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u044b\u0439 \u043a\u0442\u043e-\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e, \u0430 Patroni \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0432\u043e\u0435\u043c\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u2026 \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>\/data\/patroni<\/code> \u2014 \u043f\u0443\u0441\u0442\u043e\u0439 \u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e <code>postgres<\/code>. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0442\u043e \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# rm -rf \/data\/patroni\/* root@new_server-1:~# chown -R postgres:postgres \/data\/patroni<\/code><\/pre>\n<p>\u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c Patroni \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# systemctl start patroni root@new_server-1:~# patronictl -c \/etc\/patroni.yml list<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/277\/686\/86a\/27768686aa1880e4a853d3e8bf5f5782.png\" width=\"730\" height=\"193\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/277\/686\/86a\/27768686aa1880e4a853d3e8bf5f5782.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u043e\u0432\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430 \u2014 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 <code>running<\/code>. \u041e\u0442\u043b\u0438\u0447\u043d\u043e!<\/p>\n<p><strong>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435! <\/strong>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 Patroni \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 etcd \u0438, \u0435\u0441\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 (\u0430 \u044d\u0442\u043e \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439!), \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u043e\u0442 \u043b\u0438\u0434\u0435\u0440\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.postgresql.org\/docs\/current\/app-pgbasebackup.html\"><u>pg_basebackup<\/u><\/a>. \u0415\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0431\u0430\u0437\u0430 \u2014 \u0431\u043e\u043b\u044c\u0448\u0430\u044f, <strong>\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/strong> \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u0435\u0439\u0441\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043b \u043d\u0430\u0447\u0430\u043b\u043e \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0431\u044b\u043b\u0430 \u0431\u0430\u0437\u0430 \u043e\u0431\u044a\u0451\u043c\u043e\u043c \u0432 2,8 \u0422\u0411, \u0438 \u0435\u0451 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u0437\u0430\u043d\u0438\u043c\u0430\u043b \u043e\u043a\u043e\u043b\u043e 10 \u0447\u0430\u0441\u043e\u0432 \u043d\u0430 \u0433\u0438\u0433\u0430\u0431\u0438\u0442\u043d\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c <strong>\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/strong>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0411\u0414.<\/p>\n<p>\u0414\u043e\u0436\u0434\u0430\u0432\u0448\u0438\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b4c\/df1\/484\/b4cdf148443dca3998fb4131a9865194.png\" width=\"727\" height=\"285\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b4c\/df1\/484\/b4cdf148443dca3998fb4131a9865194.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u0412\u0430\u0436\u043d\u043e!<\/strong> \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0430\u0441\u0441\u0438\u0432\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u043b\u0438\u0434\u0435\u0440\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0442 \u043d\u0435\u0433\u043e. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0440\u0430\u0437\u0443 3 \u0440\u0435\u043f\u043b\u0438\u043a \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0441\u044b\u0433\u0440\u0430\u0442\u044c \u0437\u043b\u0443\u044e \u0448\u0443\u0442\u043a\u0443. \u042f \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043b\u0438\u0434\u0435\u0440\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 ~500 \u041c\u0431\u0438\u0442\/\u0441\u0435\u043a \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0431\u044b\u043b\u043e \u0442\u0440\u0438 \u0447\u043b\u0435\u043d\u0430. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443, \u043d\u043e \u044f\u0432\u043d\u044b\u0445 \u043f\u0438\u043a\u043e\u0432 \u043d\u0435 \u0431\u044b\u043b\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u044f\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c: \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0437\u043b\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u043e\u0442\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u043e\u0442 \u043b\u0438\u0434\u0435\u0440\u0430 (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>Lag in MB<\/em> \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u043b\u0441\u044f). \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0430: \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 (1 \u0413\u0431\u0438\u0442\/\u0441\u0435\u043a).\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a25\/2b1\/f7c\/a252b1f7c08aebec60b0d1957c844552.png\" width=\"583\" height=\"308\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a25\/2b1\/f7c\/a252b1f7c08aebec60b0d1957c844552.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0432 \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u0443\u044e \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0440\u0435\u043f\u043b\u0438\u043a\u0443 \u043e\u0442 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Patroni \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u043f\u043b\u0438\u043a \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0433 \u2014 <code>clonefrom: true<\/code>, \u0430 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0432 \u0435\u0451 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u0433: <code>replicatefrom: &lt;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0443\u0437\u043b\u0430><\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 production-\u0431\u0430\u0437\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430, \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0442\u0430\u0440\u044b\u0445 (\u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u2014 \u0441\u043c. \u0448\u0430\u0433 \u21164) \u043b\u0438\u0431\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u0422\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435.<\/p>\n<h3>\u041e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0443<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0432 \u0441\u0445\u0435\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f load balancer, \u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u0430\u043c, \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e Patroni, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"yaml\">restapi:   listen: 192.168.0.13:8008   connect_address: 192.168.0.13:8008   authentication:     username: patroni     password: 'mynewpassword'<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u0442\u0443 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Patroni API. \u0427\u0435\u0440\u0435\u0437 API \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u0437\u0435\u043b leader\u2019\u043e\u043c \u0438\u043b\u0438 replica\u2019\u043e\u0439. \u0417\u043d\u0430\u044f \u044d\u0442\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c health check \u0434\u043b\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0435\u0440\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043b\u0438\u0434\u0435\u0440\u0430 \u0431\u0430\u043b\u0430\u043d\u0441\u0435\u0440 \u0437\u043d\u0430\u043b, \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 target \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0443\u0437\u0435\u043b \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c 192.168.0.16 (<code>server-1<\/code>) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0434\u0435\u0440\u043e\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u0443 GET-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c URL:<\/p>\n<pre><code class=\"bash\">root@new_server-2:~# curl -I -X GET server-1:8008\/leader HTTP\/1.0 200 OK Server: BaseHTTP\/0.6 Python\/3.6.9 Date: Sun, 10 Oct 2021 11:40:38 GMT Content-Type: application\/json  root@new_server-2:~# curl -I -X GET server-1:8008\/replica HTTP\/1.0 503 Service Unavailable Server: BaseHTTP\/0.6 Python\/3.6.9 Date: Sun, 10 Oct 2021 11:37:57 GMT Content-Type: application\/json<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u043e\u0434\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 200 \u0438 503 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0435\u0449\u0451 \u043f\u0430\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 API \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 Patroni, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0434\u0435\u0440\u043e\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"bash\">root@new_server-2:~# curl -I -X GET new_server-1:8008\/leader HTTP\/1.0 503 Service Unavailable Server: BaseHTTP\/0.6 Python\/3.6.9 Date: Sun, 10 Oct 2021 11:41:14 GMT Content-Type: application\/json  root@new_server-2:~# curl -I -X GET new_server-1:8008\/replica HTTP\/1.0 503 Service Unavailable Server: BaseHTTP\/0.6 Python\/3.6.9 Date: Sun, 10 Oct 2021 11:41:17 GMT Content-Type: application\/json<\/code><\/pre>\n<p>\u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 503. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u041f\u043e\u0442\u043e\u043c\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0442\u0435\u0433 <code>noloadbalance: true<\/code>. \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0433\u0430 \u043d\u0430 <code>false<\/code> \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0443\u0437\u043b\u0430\u0445 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c Patroni:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0e3\/719\/27c\/0e371927c1d683b775363ae669f9cdd9.png\" width=\"705\" height=\"161\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0e3\/719\/27c\/0e371927c1d683b775363ae669f9cdd9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0449\u0451 \u0440\u0430\u0437:<\/p>\n<pre><code class=\"bash\">root@new_server-2:~# curl -I -X GET new_server-1:8008\/leader HTTP\/1.0 503 Service Unavailable Server: BaseHTTP\/0.6 Python\/3.6.9 Date: Sun, 10 Oct 2021 11:45:40 GMT Content-Type: application\/json  root@new_server-2:~# curl -I -X GET new_server-1:8008\/replica HTTP\/1.0 200 OK Server: BaseHTTP\/0.6 Python\/3.6.9 Date: Sun, 10 Oct 2021 11:45:44 GMT Content-Type: application\/json<\/code><\/pre>\n<p>\u0412\u0441\u0451 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0432 health check \u0434\u043b\u044f load balancer\u2019\u0430 \u0447\u0435\u0440\u0435\u0437 Patroni API, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440-\u0443\u0437\u0435\u043b (\u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c) \u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 (\u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435). \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f load balancer \u043e\u0442 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430, \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u043e\u0441\u043e\u0431\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 (\u043f\u043e\u043c\u0438\u043c\u043e health check) \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c. \u041d\u043e \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c HAproxy \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 TCP. \u0422\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"yaml\">global     maxconn 100  defaults     log global     mode tcp     retries 2     timeout client 30m     timeout connect 4s     timeout server 30m     timeout check 5s  listen stats     mode http     bind *:7000     stats enable     stats uri \/  listen leader     bind *:5000     option httpchk     http-check expect status 200     default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions     server server_1 192.168.0.16:5432 maxconn 100 check port 8008     server server_2 192.168.0.9:5432 maxconn 100 check port 8008     server server_3 192.168.0.12:5432 maxconn 100 check port 8008<\/code><\/pre>\n<h3>\u0428\u0430\u0433 \u21163. \u0414\u043e\u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL<\/h3>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0435 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0432\u0441\u0435\u043c \u0447\u043b\u0435\u043d\u0430\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u0433\u043e\u043d\u043a\u0435 \u0437\u0430 \u043b\u0438\u0434\u0435\u0440\u0441\u0442\u0432\u043e \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 endpoint\u2019\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0432 targets \u0443 load balancer\u2019\u0430. \u041c\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u0430 <code>nofailover<\/code> \u043d\u0430 <code>false<\/code> \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Patroni:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/673\/401\/068\/6734010682f2f3d739ff7b6c2a853592.png\" width=\"549\" height=\"161\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/673\/401\/068\/6734010682f2f3d739ff7b6c2a853592.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a targets \u0434\u043b\u044f load balancer\u2019\u0430 \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043b\u0438\u0434\u0435\u0440\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440 <code>new_server-1<\/code>:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# patronictl -c \/etc\/patroni.yml switchover Master [server-1]: Candidate ['new_server-1', 'new_server-2', 'new_server-3', 'server-2', 'server-3'] []: new_server-1 When should the switchover take place [now]: now Current cluster topology<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3ad\/8ab\/5d2\/3ad8ab5d2509f11fcdb9ed4bdd4417e7.png\" width=\"557\" height=\"163\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3ad\/8ab\/5d2\/3ad8ab5d2509f11fcdb9ed4bdd4417e7.png\"\/><figcaption><\/figcaption><\/figure>\n<pre><code class=\"bash\">Are you sure you want to switchover cluster patroni_cluster, demoting current master server-1? [y\/N]: y Successfully switched over to \"new_server-1\"<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fe1\/665\/53d\/fe166553dfdb3eb47ac793149d460aaf.png\" width=\"552\" height=\"163\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fe1\/665\/53d\/fe166553dfdb3eb47ac793149d460aaf.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0428\u0430\u0433 \u21164. \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0438\u0437 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Patroni<\/h3>\n<p>\u0412\u044b\u0432\u0435\u0434\u0435\u043c <code>server-1<\/code>, <code>server-2<\/code> \u0438 <code>server-3<\/code> \u0438\u0437 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u0443\u0431\u0435\u0440\u0435\u043c \u0438\u0445 \u0438\u0437 targets \u0434\u043b\u044f load balancer\u2019\u0430 \u2014 \u043e\u043d\u0438 \u0441\u0432\u043e\u0451 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438:<\/p>\n<pre><code class=\"bash\">root@server-3:~# systemctl stop patroni root@server-3:~# systemctl disable patroni Removed \/etc\/systemd\/system\/multi-user.target.wants\/patroni.service.  root@server-2:~# systemctl stop patroni root@server-2:~# systemctl disable patroni Removed \/etc\/systemd\/system\/multi-user.target.wants\/patroni.service.  root@server-1:~# systemctl stop patroni root@server-1:~# systemctl disable patroni Removed \/etc\/systemd\/system\/multi-user.target.wants\/patroni.service.<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">root@new_server-1:# patronictl -c \/etc\/patroni.yml list<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9a7\/2cf\/81b\/9a72cf81b8c9066b79f5dd3d2ad2c7f2.png\" width=\"549\" height=\"111\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9a7\/2cf\/81b\/9a72cf81b8c9066b79f5dd3d2ad2c7f2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b. \u041c\u044b \u043f\u043e\u0447\u0442\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438!<\/p>\n<h3>\u0428\u0430\u0433 \u21165. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0432 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u2014 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# etcdctl member list 40ebdfb25cac6924: name=etcd-2 peerURLs=http:\/\/etcd-2:2380 clientURLs=http:\/\/192.168.0.17:2379 isLeader=false 46d7a702fdb60fff: name=etcd1 peerURLs=http:\/\/etcd1:2380 clientURLs=http:\/\/192.168.0.16:2379 isLeader=true 6c2e836d0c3a51c3: name=etcd-3 peerURLs=http:\/\/etcd-3:2380 clientURLs=http:\/\/192.168.0.18:2379 isLeader=false 6d299012c6ad9595: name=etcd-1 peerURLs=http:\/\/etcd-1:2380 clientURLs=http:\/\/192.168.0.13:2379 isLeader=false c32185ccfd4b4b41: name=etcd2 peerURLs=http:\/\/etcd2:2380 clientURLs=http:\/\/192.168.0.9:2379 isLeader=false d56f1524a8fe199e: name=etcd3 peerURLs=http:\/\/etcd3:2380 clientURLs=http:\/\/192.168.0.12:2379 isLeader=false  root@new_server-1:~# etcdctl member remove d56f1524a8fe199e Removed member d56f1524a8fe199e from cluster root@new_server-1:~# etcdctl member remove c32185ccfd4b4b41 Removed member c32185ccfd4b4b41 from cluster root@new_server-1:~# etcdctl member remove 46d7a702fdb60fff Removed member 46d7a702fdb60fff from cluster root@new_server-1:~# etcdctl member list  root@new_server-1:~# etcdctl member list 40ebdfb25cac6924: name=etcd-2 peerURLs=http:\/\/etcd-2:2380 clientURLs=http:\/\/192.168.0.17:2379 isLeader=true 6c2e836d0c3a51c3: name=etcd-3 peerURLs=http:\/\/etcd-3:2380 clientURLs=http:\/\/192.168.0.18:2379 isLeader=false 6d299012c6ad9595: name=etcd-1 peerURLs=http:\/\/etcd-1:2380 clientURLs=http:\/\/192.168.0.13:2379 isLeader=false<\/code><\/pre>\n<p>\u0412\u0441\u0451! \u041f\u0435\u0440\u0435\u0435\u0437\u0434 \u043e\u043a\u043e\u043d\u0447\u0435\u043d! \u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d2a\/8d2\/97c\/d2a8d297c43fbbb316de9a183a0fcb0c.png\" width=\"719\" height=\"608\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d2a\/8d2\/97c\/d2a8d297c43fbbb316de9a183a0fcb0c.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0437\u0442\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL \u043d\u0430 \u0431\u0430\u0437\u0435 Patroni \u043d\u0430 \u043d\u043e\u0432\u043e\u0435 \u0436\u0435\u043b\u0435\u0437\u043e. \u0418 \u0432 \u0446\u0435\u043b\u043e\u043c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u2014 \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u044d\u0442\u043e \u0437\u0430\u0441\u043b\u0443\u0433\u0430 Patroni. \u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u0443\u0437\u043a\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043f\u043e \u0445\u043e\u0434\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043e\u043f\u044b\u0442 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0431\u044b\u043b \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c: \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043e\u043a\u043e\u043b\u043e 8 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u0431\u044b\u043b \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043b\u0438\u0434\u0435\u0440\u0430 health check \u043d\u0430\u0448\u0435\u0433\u043e load balancer\u2019\u0430 \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 (\u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c\u00a0 \u0432 \u0442\u0440\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0438 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u043c \u0432 \u0434\u0432\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u044b) \u0441 \u0446\u0435\u043b\u044c\u044e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e leader \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u0421\u0435\u0440\u0432\u0438\u0441, \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. (\u0410 \u0432\u043e\u043e\u0431\u0449\u0435, \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0430\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043a \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u043e\u043c\u0443 \u0443\u0437\u043b\u0443.)<\/p>\n<h2>P.S.<\/h2>\n<p>\u0427\u0438\u0442\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u043b\u043e\u0433\u0435:<\/p>\n<ul>\n<li>\n<p>\u00ab\u041e\u0431\u0437\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 PostgreSQL \u0434\u043b\u044f Kubernetes\u00bb: <a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/520616\/\">\u0447\u0430\u0441\u0442\u044c 1 (\u043d\u0430\u0448 \u043e\u043f\u044b\u0442 \u0438 \u0432\u044b\u0431\u043e\u0440)<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/527524\/\">\u0447\u0430\u0441\u0442\u044c 2 (\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435)<\/a>;<\/p>\n<\/li>\n<li>\n<p>\u00ab<a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/568924\/\">\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 PostgreSQL. \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430 \u0430\u0443\u0434\u0438\u043e\u0447\u0430\u0442\u0430 Data Egret \u0438 Okmeter<\/a>\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u00ab<a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/479438\/\">Postgres-\u0432\u0442\u043e\u0440\u043d\u0438\u043a \u21165: PostgreSQL \u0438 Kubernetes. CI\/CD. \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/a>\u00bb.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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:\/\/habr.com\/ru\/articles\/583170\/\"> https:\/\/habr.com\/ru\/articles\/583170\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u043e\u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u0438\u043b\u043e\u0441\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PostgreSQL \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c Patroni \u043d\u0430 \u043d\u043e\u0432\u043e\u0435 \u0436\u0435\u043b\u0435\u0437\u043e. \u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u2014 \u044f \u0438 \u043d\u0435 \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438 \u043d\u0430 \u043c\u044b\u0441\u043b\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u044b\u0442\u043e\u043c. \u0412 \u044d\u0442\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0448\u0430\u0433\u0438 \u0438 \u043d\u044e\u0430\u043d\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u041f\u041e: PostgreSQL 11.13, Patroni 2.1.1, etcd 3.2.17 (API version 2).<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p><a href=\"https:\/\/github.com\/zalando\/patroni\"><strong><u>Patroni<\/u><\/strong><\/a> \u2014 \u044d\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 Open Source-\u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043b\u044f \u0421\u0423\u0411\u0414 PostgreSQL \u043e\u0442 Zalando, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Python \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438. \u041f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 Patroni \u0441\u0442\u043e\u0438\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (streaming replication), \u0440\u0430\u0431\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 WAL (Write-Ahead Log). \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u043d\u043e\u0441\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0440\u0432\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 WAL. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 WAL \u0421\u0423\u0411\u0414 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>fsync<\/code>, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0434\u0438\u0441\u043a. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0421\u0423\u0411\u0414 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 WAL \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u041f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f<\/strong> \u2014 \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 WAL \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u043a \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a \u0441 \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0442\u0430\u043a \u0438 \u0441 \u0440\u0435\u043f\u043b\u0438\u043a (\u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e). \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0441 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 <code>hot_standby<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0421\u0423\u0411\u0414 \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e. \u041f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f<\/strong> \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440-\u0443\u0437\u043b\u0435 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437 WAL \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p><strong>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f<\/strong> \u2014 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 WAL \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0438 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 PostgreSQL.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Patroni \u0437\u043d\u0430\u043b\u0438 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430, \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Distributed Configuration Store (DCS) \u2014 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 DCS \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0442\u0438\u043f\u0430 key-value, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: Consul, etcd (v3), ZooKeeper. \u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 etcd.<\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438. \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u043e\u0434 \u043a\u043b\u044e\u0447, \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439: \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u0441\u0442\u043e, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u0426\u041e\u0414\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0438\u0441\u043a. \u041a\u0430\u043a \u0431\u044b\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438? \u041e\u0442\u0432\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u2014 \u043c\u0438\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u0421\u0423\u0411\u0414 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043a\u0430\u0437\u0430\u043d\u043e 3 \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0445 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0430.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<ol>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL \u043d\u0430 \u0431\u0430\u0437\u0435 Patroni, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd (\u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f Patroni), \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 (\u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Patroni);<\/p>\n<\/li>\n<li>\n<p>\u0441\u0435\u0440\u0430\u044f \u0441\u0435\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u0441 PostgreSQL \u0441 \u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u0435\u0439 192.168.0.0\/24;<\/p>\n<\/li>\n<li>\n<p>load balancer, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430 master-\u0443\u0437\u0435\u043b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 PgSQL.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043d\u0438\u0436\u0435 \u044f \u0431\u0443\u0434\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0443\u0437\u043a\u0438\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0441\u0442\u0435\u043d\u0434\u0435. \u0423\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0438\u0436\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 \u0443\u0437\u043b\u0430\u043c\u0438 \u0438 load balancer\u2019\u043e\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0445\u043e\u0441\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e IP.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0443\u0437\u043b\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b <code>\/etc\/hosts<\/code>:<\/p>\n<pre><code class=\"bash\"># etcd 192.168.0.16    server-1 etcd1 192.168.0.9     server-2 etcd2 192.168.0.12    server-3 etcd3<\/code><\/pre>\n<p>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Patroni:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/patroni.yaml<\/code> \u043d\u0430 \u0443\u0437\u043b\u0435 <code>server-1<\/code>:<\/p>\n<pre><code class=\"yaml\">scope: patroni_cluster name: server-1 namespace: \/patroni\/  restapi:   listen: 192.168.0.16:8008 # IP-\u0430\u0434\u0440\u0435\u0441 \u0443\u0437\u043b\u0430 \u0438 \u043f\u043e\u0440\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Patroni API   connect_address: 192.168.0.16:8008    authentication:     username: patroni     password: 'mysuperpassword'  etcd:   hosts: etcd1:2379,etcd2:2379,etcd3:2379  bootstrap:   dcs:     ttl: 30     loop_wait: 10     retry_timeout: 10     maximum_lag_on_failover: 1048576     synchronous_mode: false     postgresql:       use_pg_rewind: true       use_slots: true       parameters:         wal_level: hot_standby         synchronous_commit: off         hot_standby: \"on\"    initdb:   - encoding: UTF8   - data-checksums    pg_hba:   - local all postgres trust   - host postgres all 127.0.0.1\/32 md5   - host replication replicator 0.0.0.0\/0 md5   - host replication all 192.168.0.16\/32 trust # server-1   - host replication all 192.168.0.9\/32 trust  # server-2   - host replication all 192.168.0.12\/32 trust # server-3   - host all all 0.0.0.0\/0 md5    users:     admin:       password: 'mysuperpassword2'       options:         - createrole         - createdb  postgresql:   listen: 192.168.0.16:5432 # IP-\u0430\u0434\u0440\u0435\u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043f\u043e\u0440\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c  postgresql   connect_address: 192.168.0.16:5432    data_dir: \/data\/patroni   bin_dir: \/usr\/lib\/postgresql\/11\/bin   config_dir: \/data\/patroni   pgpass: \/tmp\/pgpass0   authentication:     replication:       username: replicator       password: 'mysuperpassword3'     superuser:       username: postgres       password: 'mysuperpassword4'     rewind:       username: rewind_user       password: 'mysuperpassword5'   parameters:     unix_socket_directories: '\/tmp'  tags:     nofailover: false     noloadbalance: false     clonefrom: false     nosync: false<\/code><\/pre>\n<p>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 etcd:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/default\/etcd<\/code> \u043d\u0430 \u0443\u0437\u043b\u0435 <code>server-1<\/code>:<\/p>\n<pre><code class=\"bash\">ETCD_LISTEN_PEER_URLS=\"http:\/\/127.0.0.1:2380,http:\/\/192.168.0.16:2380\" ETCD_LISTEN_CLIENT_URLS=\"http:\/\/127.0.0.1:2379,http:\/\/192.168.0.16:2379\" ETCD_INITIAL_CLUSTER=\"etcd1=http:\/\/etcd1:2380\" ETCD_INITIAL_CLUSTER_STATE=\"new-cluster\" ETCD_INITIAL_CLUSTER_TOKEN=\"myclustertoken\" ETCD_DATA_DIR=\"\/var\/lib\/etcd\" ETCD_ELECTION_TIMEOUT=\"5000\" ETCD_HEARTBEAT_INTERVAL=\"1000\" ETCD_NAME=\"etcd1\" ETCD_ADVERTISE_CLIENT_URLS=\"http:\/\/192.168.0.16:2379\" ETCD_INITIAL_ADVERTISE_PEER_URLS=\"http:\/\/192.168.0.16:2380\"<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>\/etc\/default\/etcd<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 etcd, \u0442. \u0435. \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0451\u043c, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430) \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 etcd. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <code>ETCD_DATA_DIR<\/code>.<\/p>\n<p><strong>\u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 #1, 2 \u0438 3 \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/strong>. \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL \u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd, \u043d\u0430\u0434\u0435\u043b\u044f\u044f \u043d\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0442\u043b\u0438\u0447\u0438\u044f\u043c\u0438 \u043e\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 PgSQL:<\/p>\n<ol>\n<li>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c endpoint\u2019\u044b \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 load balancer\u2019\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041d\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b PostgreSQL \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 master-\u0443\u0437\u043b\u0430 \u043f\u0440\u0438 failover.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 \u0431\u044b\u043b\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0426\u041e\u0414\u0430 \u0431\u044b\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d VPN \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f L2-\u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438. \u041d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0443, \u0438 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u043f\u043e\u043c\u0435\u0449\u0443 \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0432 \u0441\u0435\u0442\u044c 192.168.0.0\/24, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c \u0441\u0432\u044f\u0437\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 broadcast-\u0434\u043e\u043c\u0435\u043d\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0443\u0437\u043b\u043e\u0432 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041f\u043b\u0430\u043d \u043f\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 etcd-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 PostgreSQL-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Patroni;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434 \u0438\u0437 PostgreSQL-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u00ab\u0441\u0442\u0430\u0440\u044b\u0445\u00bb \u0443\u0437\u043b\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434 \u0438\u0437 etcd-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u00ab\u0441\u0442\u0430\u0440\u044b\u0445\u00bb \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c!<\/p>\n<h3>\u0428\u0430\u0433 \u21161. \u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd<\/h3>\n<p><strong><em>\u0412\u0430\u0436\u043d\u043e! <\/em><\/strong><em>\u0422\u0430\u043a \u043a\u0430\u043a etcd (\u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0442\u0438\u043f\u0430 key-value) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 Patroni, \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u0445, \u0438\u043c\u0435\u043b \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b \u043e\u0442 \u0441\u0430\u043c\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0441 Patroni. \u041d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0441\u0442\u0435\u043d\u0434\u0430 \u044f \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043b \u0438 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd \u043d\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445, \u0447\u0442\u043e \u0438 PostgreSQL \u0441 Patroni.<\/em><\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043b\u0438\u0434\u0435\u0440\u0430 \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c (\u0438 \u043d\u043e\u0432\u044b\u043c, \u0438 \u0441\u0442\u0430\u0440\u044b\u043c) \u0431\u044b\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u043e\u0432\u044b\u0439 \u043b\u0438\u0434\u0435\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043d\u0435\u0441\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>\/etc\/hosts<\/code> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0448\u0435\u0441\u0442\u0438 \u0443\u0437\u043b\u043e\u0432 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443 (\u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a):<\/p>\n<pre><code class=\"bash\"># etcd 192.168.0.16    server-1 etcd1 192.168.0.9      server-2 etcd2 192.168.0.12    server-3 etcd3 192.168.0.13    new_server-1 etcd-1# IP-\u0430\u0434\u0440\u0435\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 192.168.0.17    new_server-2 etcd-2# ... \u0432\u0442\u043e\u0440\u043e\u0433\u043e 192.168.0.18    new_server-3 etcd-3# ... \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 etcd. \u041d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 <code>new_server-1<\/code> (192.168.0.13) \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 etcd \u043d\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# systemctl status etcd \u25cf etcd.service - etcd - highly-available key value store    Loaded: loaded (\/lib\/systemd\/system\/etcd.service; disabled; vendor preset: enabled)    Active: inactive (dead)      Docs: https:\/\/github.com\/coreos\/etcd            man:etcd<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u0447\u0438\u0441\u0442\u0438\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>\/var\/lib\/etcd<\/code>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>\/etc\/default\/etcd<\/code>:<\/p>\n<pre><code class=\"bash\">root@new_server-1:~# rm -rf \/var\/lib\/etcd\/*<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0444\u0430\u0439\u043b <code>\/etc\/default\/etcd<\/code> \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code class=\"bash\">ETCD_LISTEN_PEER_URLS=\"http:\/\/192.168.0.13:2380,http:\/\/127.0.0.1:2380\" ETCD_LISTEN_CLIENT_URLS=\"http:\/\/192.168.0.13:2379,http:\/\/127.0.0.1:2379\" ETCD_INITIAL_CLUSTER_TOKEN=\"myclustertoken\" ETCD_DATA_DIR=\"\/var\/lib\/etcd\" ETCD_ELECTION_TIMEOUT=\"5000\" ETCD_HEARTBEAT_INTERVAL=\"1000\" ETCD_ADVERTISE_CLIENT_URLS=\"http:\/\/192.168.0.13:2379\" ETCD_INITIAL_ADVERTISE_PEER_URLS=\"http:\/\/192.168.0.13:2380\"<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 etcd-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>server-1<\/code>) \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">root@server-1:~# etcdctl member list 862db4122a92dc3: name=etcd3<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-401983","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401983","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=401983"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401983\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}