{"id":213409,"date":"2014-02-21T12:34:03","date_gmt":"2014-02-21T08:34:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=213409"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=213409","title":{"rendered":"<span class=\"post_title\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 pgpool-II + PostreSQL + Streaming replication + Hot standby \u0432 \u0441\u0440\u0435\u0434\u0435 AWS<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<br \/>  \u0420\u0435\u0448\u0438\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0433\u043e (HA) \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0411\u0414 PostgreSQL \u0432 IaaS \u0441\u0440\u0435\u0434\u0435 \u043e\u0442 Amazon \u2014 AWS.<\/p>\n<p>  \u041f\u0440\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u0438 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u0432\u0435\u0442 9\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0441\u0430\u043c\u043e\u0433\u043e PostgreSQL \u0438 pgpool \u043d\u0435 \u0431\u0443\u0434\u0443, \u0442\u0443\u0442 \u0432\u0441\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 \u043d\u0435\u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b \u043a \u0431\u0435\u0437\u0434\u0443\u043c\u043d\u043e\u043c\u0443 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0443, \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0438 \u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u041d\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u043e\u0449\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0430.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>\u0422\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044f:<\/h5>\n<p>  Streaming replication \u2014 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u043e\u0434\u044b \u043f\u043e\u0441\u0442\u0433\u0440\u0435\u0441\u0430 \u0431\u0443\u0434\u0443\u0442 \u0441\u0430\u043c\u0438 \u0442\u044f\u043d\u0443\u0442\u044c \u0430\u043f\u0434\u0435\u0439\u0442\u044b \u0441 \u043c\u0430\u0441\u0442\u0435\u0440\u0430. \u041d\u0435 \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0430\u0440\u0445\u0438\u0432\u0430.<br \/>  Hot standby \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 slave \u043d\u043e\u0434\u0430\u043c \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c READ \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 warm standby, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c slave \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u0435 \u0441 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 (sync or async).<br \/>  \u0412 \u043c\u043e\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0411\u0414 master-slave \u0432 \u043d\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043d\u0435\u043b\u044c\u0437\u044f, \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u043c\u0430\u0441\u0442\u0435\u0440, \u043d\u0435 \u0441\u0443\u043c\u0435\u0432 \u043e\u0442\u043e\u0441\u043b\u0430\u0442\u044c \u0440\u0435\u043f\u043b\u0438\u043a\u0443 \u0441\u043b\u0435\u0439\u0432\u0443, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0441\u0435\u0442\u044c \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438 \u0441\u043b\u0435\u0439\u0432\u0430 \u0438 \u0432\u0435\u0441\u044c \u0441\u043c\u044b\u0441\u043b \u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f.<\/p>\n<h5>\u0412\u0432\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/h5>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043b\u0438\u0448\u0435\u043d\u0430 \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0442\u043a\u0430\u0437\u0430. \u041d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 pgpool \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0440\u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b watchdog, \u0447\u0442\u043e\u0431 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u043e\u0434 \u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u044c IP \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 postgresql \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c streaming replication + hot standby. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0435\u0433\u043e \u0440\u043e\u043b\u044c \u043d\u0430 \u0441\u0435\u0431\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0432\u043e\u0437\u044c\u043c\u0435\u0442 slave, slave&#8217;\u0430 \u0432 master&#8217;\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442 pgpool \u043f\u0443\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0440\u0438\u0433\u0433\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u0432 $PGDATA. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0439\u0432\u0430 \u2014 \u0431\u0443\u0434\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0433\u043e \u043a \u0436\u0438\u0437\u043d\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0442.\u043a. \u043b\u044e\u0431\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0434\u043e\u0431\u0440\u0430 \u043d\u0435 \u0434\u043e\u0432\u043e\u0434\u044f\u0442 \u0438 \u043d\u0435\u0448\u0442\u0430\u0442\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0434\u044b \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u0412\u043e \u0432\u0441\u0435\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u044f.<\/p>\n<p>  \u0412 \u043e\u0431\u043b\u0430\u043a\u0435 AWS (Amazon Web Services) \u0441\u043e\u0437\u0434\u0430\u043d\u044b 4 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b: pgpool-1 (IP:10.0.3.11), pgpool-2(IP:10.0.3.12), db-1(IP:10.0.3.21), db-2(IP:10.0.3.22). \u041c\u0430\u0448\u0438\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u0432 VPC, \u0447\u0442\u043e\u0431 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u043e\u043d\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b\u0438\u0441\u044c \u0431\u044b \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0431\u0443\u0442\u0430\u043c\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u043c\u043d\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043e\u0431\u0440\u0430\u0437 ami-8e987ef9 c Ubuntu. \u041d\u043e \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043e\u0431\u0440\u0430\u0437 \u2014 \u0431\u0435\u0440\u0438\u0442\u0435 Amazon Linux, \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u0442\u0430\u043a \u0434\u0443\u043c\u0430\u044e \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u0443.<\/p>\n<h5>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f:<\/h5>\n<p>  1. <b>db-1<\/b> \u2014 \u043c\u0430\u0441\u0442\u0435\u0440 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0432\u044f\u0437\u043a\u0438  <\/p>\n<blockquote><p>\u2026<br \/>  wal_level = hot_standby<br \/>  <i>#\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 master \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u043d\u043e \u0432\u0432\u0438\u0434\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e master \u0438 slave \u043c\u043e\u0433\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 master&#8217;a<\/i><br \/>  hot_standby = on<br \/>  \u2026  <\/p><\/blockquote>\n<p>  \u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043d\u0443\u0436\u0434\u0430\u043c\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f <br \/>  checkpoint_segments, max_wal_senders, wal_keep_segments<br \/>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0434\u0442\u044e\u043d\u0438\u0442\u044c, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0432 <a href=\"https:\/\/wiki.postgresql.org\/wiki\/Tuning_Your_PostgreSQL_Server\">wiki.postgresql.org\/wiki\/Tuning_Your_PostgreSQL_Server<\/a><\/p>\n<p>  \u0412 pg_hba.conf \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c, \u0442.\u043a. \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 VPC \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u0438 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438\u0437 \u0432\u043d\u0435, \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b trust:  <\/p>\n<blockquote><p>host replication postgres 10.0.3.0\/24 trust<\/p><\/blockquote>\n<p>  2. <b>db-2<\/b> \u2014 \u0441\u043b\u0435\u0439\u0432 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0432\u044f\u0437\u043a\u0438  <\/p>\n<blockquote><p>\u2026<br \/>  wal_level = hot_standby<br \/>  hot_standby = on<br \/>  &#8230;<\/p><\/blockquote>\n<p>  \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c standby \u0434\u043b\u044f \u0441\u043b\u0435\u0439\u0432\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b\u0438\u043a recovery.conf, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 $PGDATA.<br \/>  \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u044b\u043b\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \/var\/lib\/postgresql\/9.3\/main<br \/>  recovery.conf:  <\/p>\n<blockquote><p>standby_mode = &#8216;on&#8217;<br \/>  primary_conninfo = &#8216;host=10.0.3.21 port=5432 user=postgres&#8217;<br \/>  trigger_file = &#8216;\/var\/lib\/postgresql\/9.3\/main\/postgresql.trigger&#8217;<\/p><\/blockquote>\n<p>  \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 pg_hba.conf<\/p>\n<p>  3. <b>pgpool-1<\/b>:  <\/p>\n<blockquote><p>backend_hostname0 = &#8216;10.0.3.21&#8217;<br \/>  backend_port0 = 5432<br \/>  backend_weight0 = 1<br \/>  backend_data_directory0 = &#8216;\/var\/lib\/postgresql\/9.3\/main&#8217;<br \/>  backend_flag0 = &#8216;ALLOW_TO_FAILOVER&#8217;<\/p>\n<p>  backend_hostname1 = &#8216;10.0.3.22&#8217;<br \/>  backend_port1 = 5432<br \/>  backend_weight1 = 1<br \/>  backend_data_directory1 = &#8216;\/var\/lib\/postgresql\/9.3\/main&#8217;<br \/>  backend_flag1 = &#8216;ALLOW_TO_FAILOVER&#8217;<\/p>\n<p>  <i>#\u0422.\u043a. \u0443 \u043d\u0430\u0441 Hot Standby:<\/i><br \/>  load_balance_mode = on<br \/>  <i>#\u0423 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Streaming replication<\/i><br \/>  master_slave_mode = on<br \/>  master_slave_sub_mode = &#8216;stream&#8217;<br \/>  sr_check_period = 10<br \/>  sr_check_user = &#8216;postgres&#8217;<br \/>  sr_check_password = &#187;<br \/>  delay_threshold = 100<br \/>  <i>#\u0418\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043a\u043e\u0433\u0434\u0430 \u0441\u043b\u0435\u0439\u0432\u043e\u0432 &gt; 1<\/i><br \/>  follow_master_command = &#187;<br \/>  <i>#\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043f\u0430\u0434\u0435\u0442 \u043d\u043e\u0434\u0430:<\/i><br \/>  failover_command = &#8216;\/etc\/pgpool2\/failover.sh %d %P %H %R&#8217;<br \/>  <i>#\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043f\u0430\u0432\u0448\u0430\u044f \u043d\u043e\u0434\u0430 \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f:<\/i><br \/>  failback_command = &#187;<br \/>  <i>#\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c failover \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u043c<\/i><br \/>  fail_over_on_backend_error = on<br \/>  search_primary_node_timeout = 10<br \/>  <i>#\u041f\u043e\u0434 \u043a\u0430\u043a\u0438\u043c \u044e\u0437\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c online recovery<\/i><br \/>  recovery_user = &#8216;postgres&#8217;<br \/>  recovery_password = &#187;<br \/>  <i>#\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 pgpool \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u044b \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0442.<br \/>  #\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043b\u0435\u0436\u0430\u0442\u044c \u0432 $PGDATA<\/i><br \/>  recovery_1st_stage_command = &#8216;basebackup.sh&#8217;<br \/>  recovery_2nd_stage_command = &#187;<br \/>  <i>#\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 \u0436\u0434\u0435\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0434\u044b<\/i><br \/>  recovery_timeout = 90<br \/>  <i>#\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c watchdog \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f pgpool<\/i><br \/>  use_watchdog = on<br \/>  wd_hostname = &#8216;pgpool-1&#8217;<br \/>  wd_port = 9000<br \/>  wd_authkey = &#187;<br \/>  <i>#\u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0438\u0442\u044c\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/i><br \/>  delegate_IP = &#8216;10.0.3.10&#8217;<br \/>  <i>#\u0413\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438:<\/i><br \/>  ifconfig_path = &#8216;\/opt\/AWS&#8217;<br \/>  <i>#\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0447\u0442\u043e\u0431 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u043e\u0434\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 IP<\/i><br \/>  if_up_cmd = &#8216;if.sh up $_IP_$&#8217;<br \/>  <i>#\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0447\u0442\u043e\u0431 \u0443\u0431\u0440\u0430\u0442\u044c \u0443 \u043d\u043e\u0434\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 IP<\/i><br \/>  if_down_cmd = &#8216;if.sh down $_IP_$&#8217;<br \/>  <i>#Pgpool \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 arping \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u0438 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0434\u043b\u044f \u0441\u043a\u043e\u0440\u0435\u0439\u0448\u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f ARP \u043a\u0435\u0448\u0430<\/i><br \/>  arping_cmd = &#187;<br \/>  <i>#\u041a\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0436\u0438\u0432\u043e\u0441\u0442\u044c \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 \u043d\u043e\u0434\u044b pgpool:<br \/>  #heartbeat \u0438\u043b\u0438 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0430\u0437\u0435<\/i><br \/>  wd_lifecheck_method = &#8216;heartbeat&#8217;<br \/>  #\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438:<br \/>  wd_interval = 4<br \/>  <i>#\u041d\u0430 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0440\u0442 \u0448\u043b\u0435\u043c:<\/i><br \/>  wd_heartbeat_port = 9694<br \/>  <i>#\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u0440\u0430\u0432\u043a\u0430\u043c\u0438 keepalive \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/i><br \/>  wd_heartbeat_keepalive = 2<br \/>  <i>#\u0412\u0440\u0435\u043c\u044f \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043c\u043e\u043b\u0447\u0430\u0449\u0443\u044e \u043d\u043e\u0434\u0443 \u043e\u0442\u043f\u0430\u0432\u0448\u0435\u0439:<\/i><br \/>  wd_heartbeat_deadtime = 15<br \/>  <i>#\u0410\u0434\u0440\u0435\u0441 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 \u043d\u043e\u0434\u044b:<\/i><br \/>  heartbeat_destination0 = &#8216;pgpool-2&#8217;<br \/>  heartbeat_destination_port0 = 9694 <br \/>  <i>#\u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c heartbeat&#8217;\u0443<\/i><br \/>  heartbeat_device0 = &#187;<br \/>  <i>#\u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u043e\u0434\u044b:<\/i><br \/>  other_pgpool_hostname0 = &#8216;pgpool-2&#8217;<br \/>  other_pgpool_port0 = 9999<br \/>  other_wd_port0 = 9000<\/p><\/blockquote>\n<p>  4. <b>pgpool-2<\/b><br \/>  \u041a\u043e\u043d\u0444\u0438\u0433 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d pgpool-1, \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 \u043d\u043e\u0434\u044b \u0441 pgpool-2 \u043d\u0430 pgpool-1<\/p>\n<p>  \u0412 \/etc\/hosts \u043d\u0430 \u043e\u0431\u043e\u0438\u0445 \u043d\u043e\u0434\u0430\u0445 \u0437\u0430\u0434\u0430\u0435\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0438\u043c\u0435\u043d\u0438 \u043a ip:  <\/p>\n<blockquote><p>10.0.3.11 pgpool-1<br \/>  10.0.3.12 pgpool-2<br \/>  10.0.3.21 db-1<br \/>  10.0.3.22 db-2<\/p><\/blockquote>\n<p>  5. \u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f pgpool \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0431\u0430\u0437\u0430\u043c\u0438<br \/>  \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b pgpool-1 \u0438 pgpool-2 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 failover_command, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u0440\u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u0438 \u043d\u043e\u0434\u044b (\u0443 \u043c\u0435\u043d\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u0438 master \u043d\u043e\u0434\u044b). \u0412\u0441\u0435 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043c\u0430\u0441\u0442\u0435\u0440 \u0443\u043f\u0430\u0432\u0448\u0430\u044f \u043d\u043e\u0434\u0430 \u0438\u043b\u0438 \u043d\u0435\u0442 \u0438 \u0435\u0441\u043b\u0438 \u043c\u0430\u0441\u0442\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0430 \u0441\u043b\u0435\u0439\u0432\u0435 \u0442\u0440\u0438\u0433\u0433\u0435\u0440-\u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0439\u0432\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c READ-WRITE, \u0442.\u0435. \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c:   <\/p>\n<pre><code class=\"bash\">#!\/bin\/bash -x  FALLING_NODE=$1         # %d  OLDPRIMARY_NODE=$2      # %P  NEW_PRIMARY=$3          # %H  PGDATA=$4               # %R  KEY_PATH=&quot;\/var\/lib\/postgresql\/.ssh\/id_rsa&quot;   if [ $FALLING_NODE = $OLDPRIMARY_NODE ]; then      if [ $UID -eq 0 ]      then          sudo -u postgres ssh -T -i $KEY_PATH postgres@$NEW_PRIMARY &quot;touch $PGDATA\/postgresql.trigger&quot;         exit 0;      fi      ssh -T -i $KEY_PATH postgres@$NEW_PRIMARY &quot;touch $PGDATA\/postgresql.trigger&quot;  fi;   exit 0; <\/code><\/pre>\n<p>  \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b db-1 \u0438 db-2 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0445\u0435\u043c\u0443 pgpool \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b:  <\/p>\n<pre><code class=\"bash\">sudo -u postgres psql -f \/usr\/share\/postgresql\/9.3\/extension\/pgpool-recovery.sql template1 <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 $PGDATA \u0441\u043a\u0440\u0438\u043f\u0442 pgpool_remote_start, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c postgresql \u043d\u0430 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 \u043d\u043e\u0434\u0435 [\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u0430\u043c\u0438 postgresql \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0432\u0442\u043e\u0440\u043e\u0439, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 pgpool&#8217;\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 $PGDATA \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0434\u043b\u044f \u043d\u043e\u0434\u044b]:  <\/p>\n<pre><code class=\"bash\">#! \/bin\/sh  DEST=$1 PGCTL=\/usr\/bin\/pg_ctlcluster KEY_PATH=&quot;\/var\/lib\/postgresql\/.ssh\/id_rsa&quot;  ssh -T -i $KEY_PATH postgres@$DEST &quot;$PGCTL 9.3 main stop --force;$PGCTL 9.3 main restart&quot; <\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a\u0436\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 recovery_1st_stage_command \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c \u043d\u043e\u0432\u044b\u0445 \u0441\u043b\u0435\u0439\u0432\u043e\u0432 (\u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u0436\u0438\u0442 \u0432 $PGDATA \u0440\u044f\u0434\u043e\u043c \u0441 pgpool_remote_start):  <\/p>\n<pre><code class=\"bash\">#! \/bin\/sh datadir=$1 desthost=$2 destdir=$3 KEY_PATH=&quot;\/var\/lib\/postgresql\/.ssh\/id_rsa&quot; PGCTL=&quot;\/usr\/bin\/pg_ctlcluster&quot;  ssh -T -i $KEY_PATH postgres@$desthost &quot;$PGCTL 9.3 main stop --force&quot;  psql -c &quot;SELECT pg_start_backup('Streaming Replication', true)&quot; postgres  rsync -C -a -c --delete -e ssh --exclude postgresql.conf --exclude postmaster.pid \\ --exclude postmaster.opts --exclude pg_log \\ --exclude recovery.conf --exclude recovery.done \\ --exclude pg_xlog $datadir\/ $desthost:$destdir\/  ssh -T -i $KEY_PATH postgres@$desthost &quot;cp $destdir\/..\/recovery.done $destdir\/recovery.conf;rm $destdir\/postgresql.trigger&quot;  psql -c &quot;SELECT pg_stop_backup()&quot; postgres <\/code><\/pre>\n<p>  5. \u0414\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0445\u043e\u0441\u0442\u0430\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0435\u0437\u043f\u0430\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430:  <\/p>\n<blockquote><p>pgpool-1 -&gt; db-1, db-2<br \/>  pgpool-2 -&gt; db-1,db-2<br \/>  db-1 -&gt; db-2<br \/>  db-2 -&gt; db-1  <\/p><\/blockquote>\n<p>\u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ssh host-based, \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c ssh \u043a\u043b\u044e\u0447\u0438 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0438\u0445 \u0432 authorized_keys.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b pgpool, \u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e postgres:<br \/>  \u0421 \u0445\u043e\u0441\u0442\u0430 pgpool-1 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">sudo -u postgres ssh -i \/path_to_key -T postgres@db-1 id <\/code><\/pre>\n<p>  \u0418 \u0442\u0430\u043a \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u0438\u043a known_hosts \u0434\u043b\u044f ssh.<\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0441\u0432\u044f\u0437\u043a\u0443 4\u0445 \u043d\u043e\u0434 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435 \u0432 \u0441\u0440\u0435\u0434\u0435 AWS.  <\/p>\n<ul>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u043e\u0441\u0442 (db-1)<\/li>\n<li>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441 \u043d\u0438\u043c \u0441\u043b\u0435\u0439\u0432 (postgresql \u043d\u0430 \u043d\u0435\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d), \u043d\u0430\u0434 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0435\u0439 $PGDATA \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c:<br \/> \n<pre><code class=\"bash\">mv main main.bak && sudo -u postgres pg_basebackup -h 10.0.3.21 -D \/var\/lib\/postgresql\/9.3\/main -U postgres -v -P && cp recovery.done main\/recovery.conf && chown postgres:postgres main\/recovery.conf <\/code><\/pre>\n<p>(recovery.done \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d recovery.conf \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 IP \u043c\u0430\u0441\u0442\u0435\u0440\u0430)<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c postgresql \u043d\u0430 \u0441\u043b\u0435\u0439\u0432\u0435:<br \/> \n<pre><code class=\"bash\">sudo service postgresql restart <\/code><\/pre>\n<\/li>\n<li>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u00abselect * from pg_stat_replication\u00bb, \u0432\u0438\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<br \/> <br \/>\n<blockquote><p>application_name | walreceiver<br \/>  client_addr | 10.0.3.22<br \/>  state | streaming<br \/>  sent_location | 1\/2A000848<br \/>  write_location | 1\/2A000848<br \/>  flush_location | 1\/2A000848<br \/>  replay_location | 1\/2A000848<br \/>  sync_priority | 0<br \/>  sync_state | async<\/p><\/blockquote>\n<p>\u043b\u0438\u0431\u043e \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 wal sender\/receiver \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0430 \u0445\u043e\u0441\u0442\u0430\u0445 db-1 \u0438 db-2.<\/li>\n<\/ul>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432\u0448\u0438\u0439\u0441\u044f pgpool \u043f\u0435\u0440\u0435\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0441\u0435\u0431\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 delegate_IP, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 if_up_cmd (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0442\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e ifconfig).<br \/>  \u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u043b\u043e\u0433\u0430\u0445:  <\/p>\n<blockquote><p>wd_escalation: escalated to master pgpool successfully<\/p><\/blockquote>\n<p>\u0427\u0435\u0440\u0435\u0437 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0432\u0442\u043e\u0440\u043e\u0439 pgpool \u0432 \u043b\u043e\u0433\u0430\u0445 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u044f\u044f pgpool \u043d\u043e\u0434\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u043f\u043e\u0437\u043d\u0430\u043d\u0430 \u0438 \u0441\u0432\u044f\u0437\u043a\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430:  <\/p>\n<blockquote><p>find_primary_node: primary node id is 0<\/p><\/blockquote>\n<p>\u0421\u0442\u0430\u0442\u0443\u0441 \u043f\u0443\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 pcp_* \u043a\u043e\u043c\u0430\u043d\u0434 \u2014 pcp_pool_status,pcp_node_info \u043b\u0438\u0431\u043e \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 pgpool \u043d\u043e\u0434\u044b \u00abshow pool_nodes;\u00bb, \u00abshow pool_pools;\u00bb<br \/>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u044b \u043d\u043e\u0434 \u0432 \u043f\u0443\u043b\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a pgpool \u2014 <a href=\"http:\/\/www.pgpool.net\/docs\/pgpool-II-3.3.2\/doc\/pgpool-en.html\">www.pgpool.net\/docs\/pgpool-II-3.3.2\/doc\/pgpool-en.html<\/a><\/p>\n<p>  \u041f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e pgpool&#8217;\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0435\u0442\u044f\u043d\u0443\u043b \u0431\u044b \u043d\u0430 \u0441\u0435\u0431\u044f delegate_ip \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 if_up_cmd.<br \/>  \u041f\u0440\u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u0438 \u0431\u0435\u043a\u0435\u043d\u0434\u0430 db-1 \u0438\u043b\u0438 db-2 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 failover_command.<br \/>  \u0414\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0431\u0435\u043a\u0435\u043d\u0434\u0430 \u0432 pool \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b pcp_attach_node \u0438 pcp_recovery_node <\/p>\n<h5>AWS Staff:<\/h5>\n<p>  \u0410 \u0447\u0442\u043e \u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0440\u0435\u0434\u0435 AWS? \u0412\u0441\u0435 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e IP \u0430\u0434\u0440\u0435\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0441\u0435\u0442\u0435\u0432\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u00abAssign a secondary private address\u00bb \u0432 \u043c\u0435\u043d\u044e Network Intefaces. \u0414\u043b\u044f Amazon Linux \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u043f\u0438\u0441\u0430\u043b \u0440\u0430\u043d\u0435\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 \u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u0437\u0430\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 pgpool-1 \u0438 pgpool-2 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u042f \u043b\u0438\u0447\u043d\u043e amazon linux \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b, \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043b\u0430\u0434\u043a\u043e \u0442\u0430\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442). \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435 \u043d\u0435\u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434 AWS \u043e\u0431\u0440\u0430\u0437\u0430 \u043c\u043d\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 <b>ec2-api-tools<\/b>.<br \/>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e api-tools \u043b\u0443\u0447\u0448\u0435 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0441 <a href=\"http:\/\/aws.amazon.com\/developertools\/351\">amazon<\/a>.<br \/>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b ec2-api-tools \u043d\u0443\u0436\u043d\u0430 \u044f\u0432\u0430, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u2014 apt-get install default-jre<br \/>  \u0412 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0430\u0440\u0445\u0438\u0432\u0435 api-tools \u0432 aws\/bin \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f aws \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<br \/>  \u041d\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 amazon api \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>  \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u043d\u0430 amazon \u0442\u0443\u0442 \u2014 <a href=\"http:\/\/docs.aws.amazon.com\/IAM\/latest\/UserGuide\/ManagingCredentials.html\">docs.aws.amazon.com\/IAM\/latest\/UserGuide\/ManagingCredentials.html<\/a> \u0438 \u0442\u0443\u0442 <a href=\"http:\/\/docs.aws.amazon.com\/IAM\/latest\/UserGuide\/ManagingUserCerts.html\">docs.aws.amazon.com\/IAM\/latest\/UserGuide\/ManagingUserCerts.html<\/a><br \/>  \u041f\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u043d\u044e IAM ( <a href=\"https:\/\/console.aws.amazon.com\/iam\/home?#users\">console.aws.amazon.com\/iam\/home?#users<\/a> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u044e\u0447 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0443 \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0435\u0441\u043b\u0438 \u0432\u044b \u0435\u0433\u043e \u043d\u0435 \u0443\u0441\u043f\u0435\u0435\u0442\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u2014 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 ). Amazon \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u044e\u0447 \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043c\u0435\u043d\u044e IAM \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439, \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u043f\u043e\u0434 \u0443\u0447\u0435\u0442\u043a\u043e\u0439 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 AWS.<br \/>  \u041f\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u0441\u0435 \u0432 \u0442\u043e\u043c \u0436\u0435 IAM \u043c\u0435\u043d\u044e AWS:  <\/p>\n<blockquote><p>openssl genrsa 1024 &gt; private-key.pem<br \/>  openssl pkcs8 -topk8 -nocrypt -inform PEM -in private-key.pem -out private-key-in-PCKS8-format.pem<br \/>  openssl req -new -x509 -nodes -sha1 -days 3650 -key private-key.pem -outform PEM &gt; certificate.pem<\/p><\/blockquote>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 certificate.pem \u0437\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430 AWS \u0432 IAM. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u043d\u044e \u00abSecurity Credentials\u00bb IAM:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/3fa\/6a8\/89d\/3fa6a889d04633b4afc6ee570bd26633.jpg\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c:<br \/>  certificate.pem \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 EC2_CERT<br \/>  private-key-in-PCKS8-format.pem \u0434\u043b\u044f EC2_PRIVATE_KEY, AWS_ACCESS_KEY \u0438 AWS_SECRET_KEY.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f ec2-api-tools.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u0441\u043a\u0440\u0438\u043f\u0442 if.sh, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c delegate_IP \u0434\u043b\u044f pgpool&#8217;\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u043c\u0438. \u0421\u043a\u0440\u0438\u043f\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c (up\/down) \u0438 \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 ip \u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0414\u0430\u043b\u0435\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e IP (\u0443 \u043c\u0435\u043d\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \/24 \u0438 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0440\u0435\u0437\u0430\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043e\u043a\u0442\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043a\u043e\u0433\u043e \u043c\u0430\u0441\u043a\u0430 \u043d\u0435 \/24, \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u0438\u043b\u0438\u0442\u044c). \u042f \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0442.\u043a. \u043d\u0430 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u043c\u0435\u043d\u0442, \u0447\u0442\u043e\u0431 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0448\u0430\u0442\u044c secondary ip.<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh  if test $# -eq 0     then     echo &quot;This scripts adds and removes ip to subinterfaces and to AWS VPC configuration.&quot;     echo &quot;Don't forget to set variables inside this script.&quot;     echo     echo Usage: $0' [up|down] IP_ADDRESS'     echo     exit 1 fi  #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #CORRECT VALUES MUST BE SET PRIOR TO RUN THIS SCRIPT #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  #Proxy if used: export EC2_JVM_ARGS='-Dhttp.proxySet=true -Dhttps.proxySet=true -Dhttp.proxyHost=x.x.x.x -Dhttp.proxyPort=3128 -Dhttps.proxyHost=x.x.x.x -Dhttps.proxyPort=3128' #Path to unpacked ec2-api from http:\/\/s3.amazonaws.com\/ec2-downloads\/ec2-api-tools.zip export EC2_HOME=\/opt #Path to java export JAVA_HOME=\/usr #Path to generated private key & cert (READ http:\/\/docs.aws.amazon.com\/IAM\/latest\/UserGuide\/ManagingUserCerts.html) export EC2_PRIVATE_KEY=\/opt\/private-key-in-PCKS8-format.pem export EC2_CERT=\/opt\/certificate.pem #User access & secret key (READ http:\/\/docs.aws.amazon.com\/IAM\/latest\/UserGuide\/ManagingCredentials.html) export AWS_ACCESS_KEY=YOUR_ACCESS_KEY export AWS_SECRET_KEY=YOUR_SECRET_KEY REGION=YOUR_REGION  #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #Region for this EC2 instance AWS_PATH=$EC2_HOME VIP=$2  subnet () { SUB=`echo $VIP | awk '{ split($0,a,&quot;.&quot;); print a[1]&quot;.&quot;a[2]&quot;.&quot;a[3]&quot;.&quot;; }'` SUBNET=`$AWS_PATH\/bin\/ec2-describe-subnets --region $REGION | grep -F $SUB | awk '{print $2}'` echo Subnet-id: $SUBNET  if [ -z &quot;$SUBNET&quot; ]; then echo &quot;Wrong subnet!&quot; exit 1; fi Instance_ID=`\/usr\/bin\/curl --silent http:\/\/169.254.169.254\/latest\/meta-data\/instance-id` echo Instance_ID=$Instance_ID ENI_ID=`$AWS_PATH\/bin\/ec2-describe-instances $Instance_ID --region $REGION | cut -f 2,3 | grep $SUBNET | awk '{print $1}'` echo ENI_ID=$ENI_ID }  if_up () { subnet \/usr\/bin\/sudo \/sbin\/ifconfig eth1:0 inet $VIP netmask 255.255.255.255 $AWS_PATH\/bin\/ec2-assign-private-ip-addresses -n $ENI_ID --secondary-private-ip-address $VIP --allow-reassignment --region $REGION }  if_down (){ subnet \/usr\/bin\/sudo \/sbin\/ifconfig eth1:0 down $AWS_PATH\/bin\/ec2-unassign-private-ip-addresses -n $ENI_ID --secondary-private-ip-address $VIP --region $REGION }  case $1 in               [uU][pP])                        if_up                        break                        ;;               [dD][oO][wW][nN])                         if_down                        break                        ;;               *) echo &quot;Up\/Down command missed!&quot;                  exit 1 esac  \/usr\/sbin\/service networking restart &gt; \/dev\/null 2&gt;&1 <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c elastic IP \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ec2-associate-address \u0438 ec2-unassign-private-ip-addresses.<\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0442\u0435\u043b\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c pgpool, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043d\u0435 \u043d\u0430 Amazon Linux \u0438\u043d\u0441\u0442\u0430\u043d\u0441, c AWS. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/213409\/\"> http:\/\/habrahabr.ru\/post\/213409\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<br \/>  \u0420\u0435\u0448\u0438\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0433\u043e (HA) \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0411\u0414 PostgreSQL \u0432 IaaS \u0441\u0440\u0435\u0434\u0435 \u043e\u0442 Amazon \u2014 AWS.<\/p>\n<p>  \u041f\u0440\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u0438 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u0432\u0435\u0442 9\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0441\u0430\u043c\u043e\u0433\u043e PostgreSQL \u0438 pgpool \u043d\u0435 \u0431\u0443\u0434\u0443, \u0442\u0443\u0442 \u0432\u0441\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 \u043d\u0435\u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b \u043a \u0431\u0435\u0437\u0434\u0443\u043c\u043d\u043e\u043c\u0443 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0443, \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0438 \u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u041d\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u043e\u0449\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-213409","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/213409","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=213409"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/213409\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}