{"id":42706,"date":"2024-05-30T13:23:50","date_gmt":"2024-05-30T13:23:50","guid":{"rendered":"https:\/\/accuweb.cloud\/resource\/?post_type=faq&#038;p=42706"},"modified":"2026-02-19T04:32:30","modified_gmt":"2026-02-19T04:32:30","slug":"postgresql-replication","status":"publish","type":"faq","link":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication","title":{"rendered":"PostgreSQL Database Replication"},"content":{"rendered":"<h2 class=\"ack-h2\">PostgreSQL Database Replication<\/h2>\n<p><strong>Replication<\/strong> is crucial for any <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/database\" target=\"_blank\" rel=\"noopener\">database server<\/a> because downtime or data loss can severely impact accessibility, productivity, and user confidence. By replicating data from a primary server to one or more standby servers, the risk of data loss is significantly reduced. With PostgreSQL, setting up a database cluster in a <strong>Primary-Secondary<\/strong> configuration (formerly known as master-slave replication) is straightforward, allowing you to include one or more standby servers.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PostgreSQL-Database-Replication.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-42707 size-full\" title=\"PostgreSQL Database Replication\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PostgreSQL-Database-Replication.png\" alt=\"PostgreSQL Database Replication\" width=\"345\" height=\"357\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PostgreSQL-Database-Replication.png 345w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PostgreSQL-Database-Replication-290x300.png 290w\" sizes=\"(max-width: 345px) 100vw, 345px\" \/><\/a><\/p>\n<p>The most efficient replication method in PostgreSQL is using Write-Ahead Logging (WAL), which offers excellent performance through asynchronous replication. In this setup, the primary database server operates in archiving mode, continuously writing WAL files to storage and transferring them to the standby server. The standby server, running in recovery mode, promptly receives these files after they are written.<br \/>\nNow, let\u2019s explore how to install and configure a Primary-Secondary PostgreSQL database cluster.<\/p>\n<h2 class=\"ack-h2\">Creating PostgreSQL Primary-Secondary Cluster<\/h2>\n<p>The platform offers two automated methods for setting up a PostgreSQL cluster:<\/p>\n<ol class=\"ack-ol\">\n<li><a class=\"ack-link-color\" href=\"#marketplace\">Pre-Packaged Marketplace Solution<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#topology-wizard\">Topology Wizard Auto-Clustering<\/a><\/li>\n<\/ol>\n<h3 id=\"marketplace\" class=\"ack-h3\">Pre-Packaged Marketplace Solution<\/h3>\n<p>The quickest and most straightforward way to create a PostgreSQL cluster is to use the pre-packaged solution from the marketplace.<\/p>\n<h4 class=\"ack-h4\">1. Access the Marketplace<\/h4>\n<ul class=\"ack-ul\">\n<li>Click the &#8220;<strong>Marketplace<\/strong>&#8221; button at the top-left of the dashboard.<\/li>\n<li>Search for the &#8220;<strong>PostgreSQL Primary-Secondary Cluster<\/strong>&#8221; package.<\/li>\n<li>Hover over the solution and click &#8220;<strong>Install<\/strong>&#8221; to proceed.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Install-PostgreSQL.png\"><img decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42708 size-full\" title=\"Install PostgreSQL\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Install-PostgreSQL.png\" alt=\"Install PostgreSQL\" width=\"1190\" height=\"648\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Install-PostgreSQL.png 1190w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Install-PostgreSQL-300x163.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Install-PostgreSQL-1024x558.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Install-PostgreSQL-768x418.png 768w\" sizes=\"(max-width: 1190px) 100vw, 1190px\" \/><\/a><\/p>\n<h4 class=\"ack-h4\">2. Configure the Cluster<\/h4>\n<ul class=\"ack-ul\">\n<li>In the opened dialog, select your preferred PostgreSQL version.<\/li>\n<li>Optionally, enable Pgpool-II load balancers.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster.png\"><img decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42709 size-full\" title=\"Configure cluster\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster.png\" alt=\"Configure cluster\" width=\"723\" height=\"579\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster.png 723w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster-300x240.png 300w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/a><\/p>\n<h4 class=\"ack-h4\">3. Wait for Setup<\/h4>\n<ul class=\"ack-ul\">\n<li>Allow a few minutes for the platform to prepare your environment and configure the required replication settings.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42710 size-full\" title=\"Admin credentials\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster-1.png\" alt=\"Admin credentials\" width=\"723\" height=\"579\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster-1.png 723w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Configure-cluster-1-300x240.png 300w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/a><\/p>\n<p>Once the setup is complete, you&#8217;ll receive a notification with the necessary data for accessing the PostgreSQL administration interface. This information will also be sent via email.<\/p>\n<div class=\"article-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"article-space\"><\/div>\n<h3 id=\"topology-wizard\" class=\"ack-h3\">Topology Wizard Auto-Clustering<\/h3>\n<p>The PostgreSQL database cluster can be enabled via the embedded <strong>Auto-Clustering<\/strong> feature on the dashboard. This method provides more customization options compared to the marketplace solution while still automating the configuration process.<\/p>\n<h4 class=\"ack-h4\">1. Initiate Auto-Clustering<\/h4>\n<ul class=\"ack-ul\">\n<li>Open the new environment topology wizard.<\/li>\n<li>Select the <strong>PostgreSQL<\/strong> database software stack.<\/li>\n<li>Toggle the dedicated <strong>Auto-Clustering<\/strong> switch. If desired, enable the Pgpool-II load balancer for your cluster.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Auto-clustering.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42712 size-full\" title=\"Auto clustering\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Auto-clustering.png\" alt=\"Auto clustering\" width=\"979\" height=\"611\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Auto-clustering.png 979w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Auto-clustering-300x187.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Auto-clustering-768x479.png 768w\" sizes=\"(max-width: 979px) 100vw, 979px\" \/><\/a><\/p>\n<p>Next, utilize the customization capabilities of the wizard to adjust the number of nodes per layer, allocate additional resources, and add other software stacks to your environment.<\/p>\n<h4 class=\"ack-h4\">2. Create the Cluster<\/h4>\n<ul class=\"ack-ul\">\n<li>When your configuration is set, click &#8220;<strong>Create<\/strong>.&#8221;<\/li>\n<li>Wait a few minutes for the platform to create your environment and set up the necessary replication configurations.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Running-cluster.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42713 size-full\" title=\"Running cluster\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Running-cluster.png\" alt=\"Running cluster\" width=\"889\" height=\"229\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Running-cluster.png 889w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Running-cluster-300x77.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Running-cluster-768x198.png 768w\" sizes=\"(max-width: 889px) 100vw, 889px\" \/><\/a><\/p>\n<div class=\"article-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"article-space\"><\/div>\n<h2 class=\"ack-h2\">Managing PostgreSQL Cluster<\/h2>\n<p>Below is some helpful information on managing a PostgreSQL cluster:<\/p>\n<ul class=\"ack-ul\">\n<li><a class=\"ack-link-color\" href=\"#entry-point\">Cluster Entry Point<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#admin-panels\">Cluster Admin Panels<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#primary-configuration\">Primary PostgreSQL Configuration<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#standby\">Configuring Standby<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#replication\">Replication Check<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#automatic-failover\">Automatic Failover Scenario<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#manual-failover\">Manual Failover Scenario<\/a><\/li>\n<\/ul>\n<h3 id=\"entry-point\" class=\"ack-h3\">Cluster Entry Point<\/h3>\n<p>If Pgpool-II nodes were not included in the cluster topology, use the Primary node to access the cluster. If the load balancing layer is deployed in front of the database cluster, you can use any of the Pgpool-II nodes as the entry point.<\/p>\n<h3 id=\"admin-panels\" class=\"ack-h3\">Cluster Admin Panels<\/h3>\n<p>In PaaS, the PostgreSQL cluster components can be managed either via CLI or UI.<\/p>\n<h4 class=\"ack-h4\">Database Management<\/h4>\n<ul class=\"ack-ul\">\n<li><strong>phpPgAdmin:<\/strong> Database nodes have a built-in management administration panel called phpPgAdmin. This panel is accessible only on the Primary node.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Admin-panel-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42714 size-full\" title=\"Admin panel\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Admin-panel-1.png\" alt=\"Admin panel\" width=\"1179\" height=\"578\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Admin-panel-1.png 1179w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Admin-panel-1-300x147.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Admin-panel-1-1024x502.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Admin-panel-1-768x377.png 768w\" sizes=\"(max-width: 1179px) 100vw, 1179px\" \/><\/a><\/p>\n<h4 class=\"ack-h4\">Pgpool-II Management<\/h4>\n<p>Pgpool-II nodes can be managed via a user-friendly built-in Administration Panel called pgpoolAdmin. This panel allows you to configure:<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PGgpoolAdmin-Dashboard.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42715 size-full\" title=\"pggpoolAdmin Dashboard\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PGgpoolAdmin-Dashboard.png\" alt=\"pggpoolAdmin Dashboard\" width=\"1463\" height=\"879\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PGgpoolAdmin-Dashboard.png 1463w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PGgpoolAdmin-Dashboard-300x180.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PGgpoolAdmin-Dashboard-1024x615.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/PGgpoolAdmin-Dashboard-768x461.png 768w\" sizes=\"(max-width: 1463px) 100vw, 1463px\" \/><\/a><\/p>\n<ul class=\"ack-ul\">\n<li><strong>Load Balancing and Distribution:<\/strong> Manage how requests to each database should be processed and balanced.<\/li>\n<li><strong>Connection Pools:<\/strong> Optimize database connections for better performance.<\/li>\n<li><strong>Logging:<\/strong> Configure logging settings for monitoring and troubleshooting.<\/li>\n<li><strong>Replication:<\/strong> Set up and manage replication settings.<\/li>\n<li><strong>Debugging:<\/strong> Tools and settings for debugging issues.<\/li>\n<li><strong>Failover and Failback:<\/strong> Configure and manage automatic failover and failback processes for high availability.<\/li>\n<\/ul>\n<div class=\"article-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"article-space\"><\/div>\n<h3 id=\"primary-configuration\" class=\"ack-h3\">Primary PostgreSQL Configuration<\/h3>\n<p>Let\u2019s take a look at the primary node configuration parameters used in auto-clustering.<\/p>\n<p>1. <strong>Locate the Primary Node:<\/strong> In your environments list, find the environment containing the primary database. Click the <strong>Config<\/strong> button next to the PostgreSQL Primary node.<\/p>\n<p>2. <strong>Open Configuration File:<\/strong> Navigate to the <strong>conf<\/strong> directory and open the <strong>postgresql.conf<\/strong> file.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/postgresql.conf_.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42716 size-full\" title=\"postgresql.conf\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/postgresql.conf_.png\" alt=\"postgresql.conf\" width=\"1383\" height=\"477\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/postgresql.conf_.png 1383w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/postgresql.conf_-300x103.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/postgresql.conf_-1024x353.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/postgresql.conf_-768x265.png 768w\" sizes=\"(max-width: 1383px) 100vw, 1383px\" \/><\/a><\/p>\n<p>Modify WAL Settings: The following lines related to the Write-Ahead Logging (WAL) files can be changed if necessary:<\/p>\n<pre><code class=\"language-javascript\">\r\nwal_level = hot_standby\r\nmax_wal_senders = 10\r\narchive_mode = on\r\narchive_command = 'cd .'<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p><strong>Where:<\/strong><\/p>\n<ul class=\"ack-ul\">\n<li><strong>wal_level:<\/strong> This parameter determines the amount of information written to the WAL. There are three possible values:\n<ul class=\"ack-ul\">\n<li><strong>minimal:<\/strong> Only the information necessary to recover from a failure or emergency shutdown.<\/li>\n<li><strong>replica:<\/strong> The default value, which writes enough data to support WAL archiving and replication, including running read-only queries on the standby server. In releases prior to 9.6, the values archive and hot_standby were also allowed and mapped to replica.<\/li>\n<li><strong>logical:<\/strong> Adds the information required to support logical decoding to the replica logging level.<\/li>\n<\/ul>\n<\/li>\n<li><strong>max_wal_senders:<\/strong> Sets the maximum number of simultaneously running WAL transfer processes.<\/li>\n<li><strong>archive_mode:<\/strong> Enables WAL archiving in conjunction with the wal_level parameter (all values except minimal enable archiving).<\/li>\n<li><strong>archive_command:<\/strong> Specifies the local shell command to archive the completed WAL segment. By default, it does nothing (cd .). You can change this to copy WAL archives to a preferred destination directory. For example:<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">\r\narchive_command = 'test ! -f \/var\/lib\/pgsql\/data\/pg_wal\/%f &amp;&amp; cp %p \/tmp\/mydata\/%f'<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Modify-WAL-settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42717 size-full\" title=\"Modify WAL settings\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Modify-WAL-settings.png\" alt=\"Modify WAL settings\" width=\"1440\" height=\"475\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Modify-WAL-settings.png 1440w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Modify-WAL-settings-300x99.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Modify-WAL-settings-1024x338.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Modify-WAL-settings-768x253.png 768w\" sizes=\"(max-width: 1440px) 100vw, 1440px\" \/><\/a><\/p>\n<p>Press the <strong>Save<\/strong> button above the editor.<\/p>\n<p>3. Open the <strong>pg_hba.conf<\/strong> configuration file. The standby database connection is permitted by stating the following parameters:<\/p>\n<pre><code class=\"language-javascript\">\r\nhost replication all {standby_IP_address}\/32 trust<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/pg_hbs.conf_.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42718 size-full\" title=\"pg_hbs.conf\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/pg_hbs.conf_.png\" alt=\"pg_hbs.conf\" width=\"1456\" height=\"475\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/pg_hbs.conf_.png 1456w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/pg_hbs.conf_-300x98.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/pg_hbs.conf_-1024x334.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/pg_hbs.conf_-768x251.png 768w\" sizes=\"(max-width: 1456px) 100vw, 1456px\" \/><\/a><\/p>\n<p>That\u2019s all for primary! Let\u2019s proceed to the standby server\u2019s configuration.<\/p>\n<h3 id=\"standby\" class=\"ack-h3\">Configuring Standby<\/h3>\n<p>1. Open the <strong>postgresql.conf<\/strong> file, find the Standby Servers section. As you can see this server is acting as standby since the <strong>hot_standby<\/strong> parameter is <strong>on<\/strong> unlike the primary node where this parameter is commented out.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Standby-server.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42721 size-full\" title=\"Standby server\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Standby-server.png\" alt=\"Standby server\" width=\"1578\" height=\"474\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Standby-server.png 1578w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Standby-server-300x90.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Standby-server-1024x308.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Standby-server-768x231.png 768w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Standby-server-1536x461.png 1536w\" sizes=\"(max-width: 1578px) 100vw, 1578px\" \/><\/a><\/p>\n<p>2. Scroll down to the end of the config file. There is a <strong>primary_conninfo<\/strong> parameter that specifies the connection string which the standby server will use to connect to the sending server. The connection string must indicate the host name (or address) of the sending server, as well as the port number. The username corresponding to the role with the appropriate privileges on the sending server is also provided. The password must also be specified in the primary_conninfo or in a separate ~\/.pgpass file on the backup server if the sender requires password authentication.<\/p>\n<pre><code class=\"language-javascript\">\r\nprimary_conninfo = 'host=primary_server_ip port=5432 user=replication_user password=your_password'<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p>3. The last option that makes database server as secondary is <strong>standby.signal<\/strong> file availability, which indicates the server should start up as a hot standby. File must be located in the PostgreSQL data directory and it can be empty or contain any information. Once a secondary is promoted to primary this file will be deleted.<\/p>\n<div class=\"ack-formula\">\n<p><strong>Note:<\/strong> Remember that when modifying certain options, the server may need to be restarted. You can do this in two ways:<\/p>\n<ol class=\"ack-ol\">\n<li>From the dashboard, you have the option to restart either one or both nodes.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Restart-node-option.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42722 size-full\" title=\"Restart node option\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Restart-node-option.png\" alt=\"Restart node option\" width=\"870\" height=\"171\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Restart-node-option.png 870w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Restart-node-option-300x59.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Restart-node-option-768x151.png 768w\" sizes=\"(max-width: 870px) 100vw, 870px\" \/><\/a><\/p>\n<ol class=\"ack-ol\" start=\"2\">\n<li>Alternatively, you can use the command line interface via the Web SSH client. To do this, click on the Web SSH button for the desired node, such as the secondary.<\/li>\n<\/ol>\n<div>Then, issue the following command to restart the database server:<\/div>\n<pre><code class=\"language-javascript\">\r\nsudo service postgresql restart<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/CLI-for-restart-server.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42723 size-full\" title=\"CLI for restart server\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/CLI-for-restart-server.png\" alt=\"CLI for restart server\" width=\"1198\" height=\"476\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/CLI-for-restart-server.png 1198w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/CLI-for-restart-server-300x119.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/CLI-for-restart-server-1024x407.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/CLI-for-restart-server-768x305.png 768w\" sizes=\"(max-width: 1198px) 100vw, 1198px\" \/><\/a><\/p>\n<div>This ensures that your changes take effect and the server is properly restarted.<\/div>\n<\/div>\n<div class=\"article-space\"><\/div>\n<h3 id=\"replication\" class=\"ack-h3\">Replication Check<\/h3>\n<p>1. Access the <strong>phpPgAdmin<\/strong> panel for your <strong>primary<\/strong> database by clicking the &#8220;<strong>Open in Browser<\/strong>&#8221; button next to it.<\/p>\n<p>2. Log in using the database credentials you received via email earlier, and proceed to create a new database.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Create-new-DB.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42726 size-full\" title=\"Create new DB\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Create-new-DB.png\" alt=\"Create new DB\" width=\"945\" height=\"479\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Create-new-DB.png 945w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Create-new-DB-300x152.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Create-new-DB-768x389.png 768w\" sizes=\"(max-width: 945px) 100vw, 945px\" \/><\/a><\/p>\n<p>3. Next, open the admin panel of your <strong>standby<\/strong> database server (similarly to how you accessed the primary one) and verify if the new database has been replicated successfully.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Verify-new-DB.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42727 size-full\" title=\"Verify new DB\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Verify-new-DB.png\" alt=\"Verify new DB\" width=\"1185\" height=\"595\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Verify-new-DB.png 1185w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Verify-new-DB-300x151.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Verify-new-DB-1024x514.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Verify-new-DB-768x386.png 768w\" sizes=\"(max-width: 1185px) 100vw, 1185px\" \/><\/a><\/p>\n<h3 id=\"automatic-failover\" class=\"ack-h3\">Automatic Failover Scenario<\/h3>\n<p>Automatic failover in the PostgreSQL cluster relies on the Pgpool-II node and is activated when it detects the primary database&#8217;s failure. This feature is unavailable in topologies lacking Pgpool-II, necessitating manual configuration. Upon identifying a primary database outage, the load balancing node promotes a standby to the primary role. Upon the primary&#8217;s recovery, it automatically rejoins the cluster as a standby, with missing data restored via the pgrewind utility.<\/p>\n<h3 id=\"manual-failover\" class=\"ack-h3\">Manual Failover Scenario<\/h3>\n<p>PostgreSQL lacks native automatic failover capabilities, but third-party solutions offer options for ensuring high availability. Alternatively, users can devise custom failover solutions to address database cluster failures. While numerous failure scenarios exist, we focus on a common workflow for automating failover.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Failover-Scenario.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42728 size-full\" title=\"Failover Scenario\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Failover-Scenario.png\" alt=\"Failover Scenario\" width=\"1600\" height=\"777\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Failover-Scenario.png 1600w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Failover-Scenario-300x146.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Failover-Scenario-1024x497.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Failover-Scenario-768x373.png 768w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Failover-Scenario-1536x746.png 1536w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/a><\/p>\n<p>The default setup comprises two nodes:<\/p>\n<ol class=\"ack-ol\">\n<li>Primary Node<\/li>\n<li>Standby Node<\/li>\n<\/ol>\n<p>In the event of primary node failure, the standby must be promoted to primary status. This can be achieved using the pg_ctl utility, employed for initializing, starting, stopping, or controlling a PostgreSQL server. To execute this, log in to the standby server via Web SSH and issue the following command:<\/p>\n<pre><code class=\"language-javascript\">\r\n\/usr\/pgsql-15.6\/bin\/pg_ctl promote -D \/var\/lib\/pgsql\/data<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p>Where <strong>\/var\/lib\/pgsql\/data<\/strong> represents the database data directory.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Protected-Server.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42730 size-full\" title=\"Protected Server\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Protected-Server.png\" alt=\"Protected Server\" width=\"1157\" height=\"133\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Protected-Server.png 1157w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Protected-Server-300x34.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Protected-Server-1024x118.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Protected-Server-768x88.png 768w\" sizes=\"(max-width: 1157px) 100vw, 1157px\" \/><\/a><\/p>\n<p>Upon promoting the secondary database to primary status, it&#8217;s imperative to update the application connection string to reflect the new hostname or IP address, ensuring seamless cluster entry point transition.<\/p>\n<p>For failover management, the <strong>pg_isready<\/strong> utility is invaluable, performing connection checks on the PostgreSQL database.<\/p>\n<p>A simple script can automate the failover process, periodically checking the primary database server&#8217;s availability and promoting the standby node in case of primary failure. This script, named <strong>failover.sh<\/strong>, can be executed via a crontab on the secondary node at specified intervals. Here&#8217;s an example script implementation:<\/p>\n<pre><code class=\"language-javascript\">\r\n#!\/bin\/bash\r\nprimary=\"10.100.2.214\"\r\nsecondary=\"10.100.2.134\"\r\nstatus=$(\/usr\/pgsql-15.6\/bin\/pg_isready -d postgres -h $primary)\r\nresponse=\"$primary:5432 - no response\"\r\nif [ \"$status\" == \"$response\" ]\r\nthen\r\n\/usr\/pgsql-15.6\/bin\/pg_ctl promote -D \/var\/lib\/pgsql\/data\r\necho \"Secondary promoted to new Primary. Change your app connection string to new Primary address $secondary\"\r\nelse\r\necho \"Primary is alive. Nothing to do.\"\r\nfi<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<h3 class=\"ack-h3\">Cluster Restoration<\/h3>\n<p>With a new primary address you can easily avoid tuning your application connection string by changing the IP addresses of the primary database. To do this, you have to put a load balancer in front of the cluster that will monitor the status of its components and route traffic to the current primary. Below, we will demonstrate how to restore the original cluster topology so that no changes will be required at the frontend.<\/p>\n<p>Another reason the topology should be restored is related to ensuring the scalability of the cluster. Only the original topology can be scaled in\/out horizontally.<\/p>\n<div class=\"article-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"article-space\"><\/div>\n<p>Let\u2019s see how to perform PostgreSQL database cluster restoration after the former primary was dropped off from the cluster and the former secondary was promoted to the primary.<\/p>\n<p>So, the task is: the dropped-off primary should become the actual primary, and the current primary (former secondary) should become the actual secondary.<\/p>\n<p><strong>The initial data are:<\/strong><\/p>\n<p>Database cluster comprises two nodes, primary (IP: 10.100.2.214) and secondary (IP: 10.100.2.134). Primary node went down and the primary database was stopped. Standby database was promoted to the primary role. Now the secondary retains the reads\/writes. Former primary node was fixed and is ready to be reintroduced to the replication as primary. Do the steps as follows to get the cluster back to the initial topology:<\/p>\n<p>1. Enter the former primary node via Web SSH and issue the command:<\/p>\n<pre><code class=\"language-javascript\">\r\nrm -rf \/var\/lib\/pgsql\/data\/*<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-primary-node.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42733 size-full\" title=\"Add primary node\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-primary-node.png\" alt=\"Add primary node\" width=\"925\" height=\"473\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-primary-node.png 925w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-primary-node-300x153.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-primary-node-768x393.png 768w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/a><\/p>\n<p>2. Add the former primary IP address (10.100.2.214) to the <strong>pg_hba.conf<\/strong> file on the current primary node:<\/p>\n<pre><code class=\"language-javascript\">\r\nhost replication replication 10.100.2.214\/32 trust<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-formar-primary-node.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-42734 size-full\" title=\"Add former primary node\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-formar-primary-node.png\" alt=\"Add former primary node\" width=\"1401\" height=\"414\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-formar-primary-node.png 1401w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-formar-primary-node-300x89.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-formar-primary-node-1024x303.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Add-formar-primary-node-768x227.png 768w\" sizes=\"(max-width: 1401px) 100vw, 1401px\" \/><\/a><\/p>\n<p><strong>Restart<\/strong> the current primary database to apply the changes:<\/p>\n<pre><code class=\"language-javascript\">\r\nsudo service postgresql restart<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p>3. Access the former primary node via Web SSH and execute the following command:<\/p>\n<pre><code class=\"language-javascript\">\r\npg_basebackup -U replication -h 10.100.2.214 -D \/var\/lib\/pgsql\/data -Fp -Xs -P -R<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p><strong>Where:<\/strong><\/p>\n<ul class=\"ack-ul\">\n<li>pg_basebackup &#8211; is used to take base backups of a running PostgreSQL database cluster.<\/li>\n<li>10.100.2.214 &#8211; IP address of the current primary node.<\/li>\n<li>\/var\/lib\/pgsql\/data &#8211; PostgreSQL data directory.<\/li>\n<\/ul>\n<p>4. Ensure the IP address in the host parameter described in the second step of <strong>Configuring Standby<\/strong> contains the proper IP address of the former primary.<\/p>\n<p>5. Create the <strong>standby.signal<\/strong> file at the current primary:<\/p>\n<pre><code class=\"language-javascript\">\r\ntouch \/var\/lib\/pgsql\/data\/standby.signal<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p>Restart the node to convert it to a new secondary database:<\/p>\n<pre><code class=\"language-javascript\">\r\nsudo service postgresql restart<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p>Remove the <strong>standby.signal<\/strong> file at the former primary:<\/p>\n<pre><code class=\"language-javascript\">\r\nrm \/var\/lib\/pgsql\/data\/standby.signal<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p>Restart the node to convert it to a new primary database:<\/p>\n<pre><code class=\"language-javascript\">\r\nsudo service postgresql restart<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p>6. Finally, to ensure a consistent recovery state for both primary and standby databases, a final restart is required. Restart the PostgreSQL nodes again.<\/p>\n<p>Once the restart process is completed, the cluster will return to its original topology and can be scaled horizontally.<\/p>\n<div class=\"cta-btn-top-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"cta-btn-mob-space\"><\/div>\n","protected":false},"author":1,"featured_media":52879,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","class_list":["post-42706","faq","type-faq","status-publish","has-post-thumbnail","hentry","faq_topics-auto-clustering-high-availability-cluster","faq_topics-databases","faq_topics-high-availability-cluster","faq_topics-kb","faq_topics-postgre-sql","faq_topics-product-documentation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.10 (Yoast SEO v24.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PostgreSQL Replication and Auto Clustering with AccuWeb.Cloud<\/title>\n<meta name=\"description\" content=\"Discover efficient PostgreSQL database replication methods and step-by-step guides for setting up primary-secondary clusters.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL Database Replication\" \/>\n<meta property=\"og:description\" content=\"Discover efficient PostgreSQL database replication methods and step-by-step guides for setting up primary-secondary clusters.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication\" \/>\n<meta property=\"og:site_name\" content=\"AccuWeb Cloud\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-19T04:32:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#article\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication\"},\"author\":{\"name\":\"Jilesh Patadiya\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\"},\"headline\":\"PostgreSQL Database Replication\",\"datePublished\":\"2024-05-30T13:23:50+00:00\",\"dateModified\":\"2026-02-19T04:32:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication\"},\"wordCount\":1916,\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication\",\"url\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication\",\"name\":\"PostgreSQL Replication and Auto Clustering with AccuWeb.Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"datePublished\":\"2024-05-30T13:23:50+00:00\",\"dateModified\":\"2026-02-19T04:32:30+00:00\",\"description\":\"Discover efficient PostgreSQL database replication methods and step-by-step guides for setting up primary-secondary clusters.\",\"breadcrumb\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/accuweb.cloud\/resource\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Database Replication\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"name\":\"AccuWeb Cloud\",\"description\":\"Cutting Edge Cloud Computing\",\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\",\"name\":\"AccuWeb.Cloud\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"width\":156,\"height\":87,\"caption\":\"AccuWeb.Cloud\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\",\"name\":\"Jilesh Patadiya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"caption\":\"Jilesh Patadiya\"},\"description\":\"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.\",\"sameAs\":[\"https:\/\/accuweb.cloud\/resource\",\"https:\/\/www.facebook.com\/accuwebhosting\",\"https:\/\/www.instagram.com\/accuwebhosting\/\",\"https:\/\/www.linkedin.com\/company\/accuwebhosting\/\",\"https:\/\/x.com\/accuwebhosting\",\"https:\/\/www.youtube.com\/c\/Accuwebhosting\"],\"url\":\"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"PostgreSQL Replication and Auto Clustering with AccuWeb.Cloud","description":"Discover efficient PostgreSQL database replication methods and step-by-step guides for setting up primary-secondary clusters.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL Database Replication","og_description":"Discover efficient PostgreSQL database replication methods and step-by-step guides for setting up primary-secondary clusters.","og_url":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication","og_site_name":"AccuWeb Cloud","article_modified_time":"2026-02-19T04:32:30+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#article","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication"},"author":{"name":"Jilesh Patadiya","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58"},"headline":"PostgreSQL Database Replication","datePublished":"2024-05-30T13:23:50+00:00","dateModified":"2026-02-19T04:32:30+00:00","mainEntityOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication"},"wordCount":1916,"publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication","url":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication","name":"PostgreSQL Replication and Auto Clustering with AccuWeb.Cloud","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/#website"},"primaryImageOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","datePublished":"2024-05-30T13:23:50+00:00","dateModified":"2026-02-19T04:32:30+00:00","description":"Discover efficient PostgreSQL database replication methods and step-by-step guides for setting up primary-secondary clusters.","breadcrumb":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#primaryimage","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/accuweb.cloud\/resource\/articles\/postgresql-replication#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/accuweb.cloud\/resource\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Database Replication"}]},{"@type":"WebSite","@id":"https:\/\/accuweb.cloud\/resource\/#website","url":"https:\/\/accuweb.cloud\/resource\/","name":"AccuWeb Cloud","description":"Cutting Edge Cloud Computing","publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/accuweb.cloud\/resource\/#organization","name":"AccuWeb.Cloud","url":"https:\/\/accuweb.cloud\/resource\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","width":156,"height":87,"caption":"AccuWeb.Cloud"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58","name":"Jilesh Patadiya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","caption":"Jilesh Patadiya"},"description":"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.","sameAs":["https:\/\/accuweb.cloud\/resource","https:\/\/www.facebook.com\/accuwebhosting","https:\/\/www.instagram.com\/accuwebhosting\/","https:\/\/www.linkedin.com\/company\/accuwebhosting\/","https:\/\/x.com\/accuwebhosting","https:\/\/www.youtube.com\/c\/Accuwebhosting"],"url":"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin"}]}},"_links":{"self":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/42706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq"}],"about":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/comments?post=42706"}],"version-history":[{"count":12,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/42706\/revisions"}],"predecessor-version":[{"id":53188,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/42706\/revisions\/53188"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media\/52879"}],"wp:attachment":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media?parent=42706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}