{"id":3884,"date":"2024-03-25T20:38:00","date_gmt":"2024-03-25T20:38:00","guid":{"rendered":"https:\/\/code2deploy.com\/blog\/?p=3884"},"modified":"2024-03-25T20:47:19","modified_gmt":"2024-03-25T20:47:19","slug":"setting-up-streaming-replication-in-postgresql-on-ubuntu","status":"publish","type":"post","link":"https:\/\/code2deploy.com\/blog\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/","title":{"rendered":"Setting up Streaming Replication in PostgreSQL on Ubuntu"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">PostgreSQL Streaming Replication is a powerful feature that enables real-time data synchronization between primary and secondary databases. This step-by-step guide will walk you through the process of configuring streaming replication on Ubuntu, allowing you to achieve high availability and data redundancy in your PostgreSQL environment.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>1. Introduction to Streaming Replication<\/strong>\n<ul class=\"wp-block-list\">\n<li>Overview<\/li>\n\n\n\n<li>Importance in PostgreSQL<\/li>\n\n\n\n<li>Use Cases<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>2. How WAL is Shipped and Applied<\/strong>\n<ul class=\"wp-block-list\">\n<li>Write-Ahead Logging (WAL)<\/li>\n\n\n\n<li>Process of Shipping and Applying WAL<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>3. Characteristics of Synchronous and Asynchronous Replications<\/strong>\n<ul class=\"wp-block-list\">\n<li>Synchronous Replication<\/li>\n\n\n\n<li>Asynchronous Replication<\/li>\n\n\n\n<li>Performance Considerations<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>4. Prerequisites<\/strong>\n<ul class=\"wp-block-list\">\n<li>Required Server Setup<\/li>\n\n\n\n<li>User and Database Configuration<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>5. Configuration Steps<\/strong>\n<ul class=\"wp-block-list\">\n<li>Step 1: Configure Master<\/li>\n\n\n\n<li>Step 2: Initialize Slave<\/li>\n\n\n\n<li>Step 3: Verify Master<\/li>\n\n\n\n<li>Step 4: Verify Slave<\/li>\n\n\n\n<li>Step 5: Check Replication Type<\/li>\n\n\n\n<li>Step 6: Verify on Slave<\/li>\n\n\n\n<li>Step 7: Enable Synchronous Replication (Optional)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>6. Failover and Recovery<\/strong>\n<ul class=\"wp-block-list\">\n<li>Promoting Standby to Primary<\/li>\n\n\n\n<li>Adding Old Primary as Standby<\/li>\n\n\n\n<li>Monitoring Replication<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Introduction to Streaming Replication<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL Streaming Replication facilitates continuous data transfer from one PostgreSQL database (the primary) to one or more secondary databases (standbys). This enables near-real-time synchronization of data changes, making it ideal for applications requiring low latency and high availability, such as online transaction processing systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How the WAL is shipped and applied:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Write-Ahead Logging (WAL) records all changes made to the database before applying them to the data files. In streaming replication, these WAL records are shipped from the primary to the standby servers and applied to maintain consistency across the databases.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"463\" height=\"403\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" src=\"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/image.png\" alt=\"\" class=\"wp-image-3886\" srcset=\"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/image.png 463w, https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/image-300x261.png 300w\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Characteristics of synchronous and asynchronous replications:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Synchronous Replication: <\/strong>Ensures that every transaction is committed on both the primary and standby servers before acknowledging the commit to the client. This guarantees consistency but may impact performance due to the added latency.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Asynchronous Replication: <\/strong>Allows the primary server to acknowledge commits to the client before ensuring they are applied on the standby server. While providing better performance, it may result in potential data loss if the primary server fails before changes are replicated to the standby.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>One Master Database Server (Primary Server)<\/li>\n\n\n\n<li>One Slave Database Server (Standby Server)<\/li>\n\n\n\n<li>Database Created on both servers<\/li>\n\n\n\n<li>Database user for Application<\/li>\n\n\n\n<li>Replicator User for Master Node<\/li>\n\n\n\n<li>Both servers are accessible remotely to each other<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Primary\/Master-DB:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Host: 172.16.1.10<\/li>\n\n\n\n<li>DB-Name: rnd_db<\/li>\n\n\n\n<li>User: rnd_dbuser<\/li>\n\n\n\n<li>Pass: [hidden]<\/li>\n\n\n\n<li>Master-Replication-User: replicator<\/li>\n\n\n\n<li>Pass: [hidden]<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Secondary\/Slave-DB:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Host: 172.16.1.11<\/li>\n\n\n\n<li>DB-Name: rnd_db<\/li>\n\n\n\n<li>User: rnd_dbuser<\/li>\n\n\n\n<li>Pass: [hidden]<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Configuration Steps<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Configure Master<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Edit <strong>postgresql.conf <\/strong>and <strong>pg_hba.conf<\/strong> to allow replication and authenticate the standby server:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>##Allow the all host<br>vim \/etc\/postgresql\/14\/main\/postgresql.conf<br><br>listen_addresses = &#8216;*&#8217;&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Edit <strong>pg_hba.conf<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>## authenticate the specific host<br>vim \/etc\/postgresql\/14\/main\/pg_hba.conf<br>#add the below line<br>host&nbsp; &nbsp; replication &nbsp; &nbsp; replicator&nbsp; &nbsp; &nbsp; 172.16.1.11\/24&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; md5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Create Replication User:<\/strong><br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD &#8216;Password&#8217;;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br>Then restart the Postgres server<br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>systemctl restart postgresql&nbsp;&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Initialize Slave<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Stop PostgreSQL, backup the data directory, and initialize replication:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>systemctl stop postgresql<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">#Then login to the Postgres server&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>su &#8211; postgres<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Take a backup of the following directory&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>cp -r \/var\/lib\/postgresql\/14\/main\/ \/var\/lib\/postgresql\/14\/main_old\/<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Remove the <strong>main<\/strong> directory from the specific dir<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>rm -rf \/var\/lib\/postgresql\/14\/main<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Run the bashbackup<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>pg_basebackup -h 172.16.1.10 -D \/var\/lib\/postgresql\/14\/main\/ -U replicator -P -v -R -X stream -C -S slaveslot1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Verify Master<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>su &#8211; postgres<\/strong><strong><br><\/strong><strong>psql<\/strong><strong><br><\/strong><strong>SELECT<\/strong><strong> * <\/strong><strong>FROM<\/strong><strong> pg_replication_slots;<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Verify Slave<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the Postgres server&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>systemctl start postgresql<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Check replication status<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>select * from pg_stat_wal_receiver;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Check the Replication Type on the Master Node<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now, verify the replication type synchronous or asynchronous using the below command on the master database server.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>SELECT * FROM pg_stat_replication;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Create a database on the master server and verify if it replicates to the slave<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>create database stream;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6: Verify on Slave<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check if the newly created database has been replicated to the slave<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>select datname from pg_database;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 7: Enable Synchronous Replication (Optional)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to enable synchronous replication, run the following command on the master server and reload PostgreSQL service.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>ALTER SYSTEM SET synchronous_standby_names TO &#8216;*&#8217;;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Reload the database service&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>systemctl reload postgresql<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Failover and Recovery:<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If your primary PostgreSQL server is down<\/strong> and you need to promote the secondary standby server to become the new primary server, you can follow these general steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Verify the Status:<\/strong> Ensure that the primary server is indeed down and not just experiencing temporary issues. Check logs and monitor server status if possible.<\/li>\n\n\n\n<li><strong>Promoting Standby to Primary:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Log in to the standby server where replication is set up.<\/li>\n\n\n\n<li>Modify the PostgreSQL configuration file <strong>(postgresql.conf)<\/strong> to allow this server to be promoted to the primary role. You typically need to change the value of<strong> hot_standby to on.&nbsp;&nbsp;&nbsp;<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>hot_standby = <\/strong><strong>on<\/strong><strong>&nbsp;&nbsp;<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Restart the PostgreSQL service after making the changes.<\/li>\n\n\n\n<li>Set PGDATA Environment Variable (Optional): If necessary, set the PGDATA environment variable to point to the PostgreSQL data directory of the standby server.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>export PGDATA=\/var\/lib\/postgresql\/14\/main<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Promote Standby Server: Run the<strong> pg_ctl promote<\/strong> command to promote the standby server to the primary role.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>\/usr\/lib\/postgresql\/14\/bin\/pg_ctl promote<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Verify Promotion<\/strong>: Confirm the successful promotion of the standby server to the primary role by checking the status using <strong>SQL query:<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>SELECT pg_is_in_recovery();<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Adding Old Primary as Standby:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ensure Old Primary Is Up<\/strong>: Once the original primary server is back up and running, proceed to add it as a standby to the current primary server.<\/li>\n\n\n\n<li>Configure Recovery.conf (or <strong>Postgresql.auto.conf<\/strong>): Update the recovery.conf (or <strong>postgresql.auto.conf<\/strong> in newer versions) file on the old primary server to set it up as a standby. Include parameters such as <strong>standby_mode, primary_conninfo, and trigger_file.<\/strong><\/li>\n\n\n\n<li><strong>Start PostgreSQL: <\/strong>Start the PostgreSQL service on the old primary server. PostgreSQL will then begin streaming replication from the current primary server.<\/li>\n\n\n\n<li><strong>Monitor Replication:<\/strong> Monitor the replication status between the new primary server and the old primary server (now standby) to ensure data is being replicated correctly. You can use tools like <strong>pg_stat_replication<\/strong> or check the logs for any errors.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">By following these steps, you&#8217;ve successfully promoted the standby database to become the new primary database and added the old primary database as a standby. This ensures high availability and fault tolerance in your PostgreSQL database environment. If you encounter any issues or have further questions, feel free to ask!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step by Step PostgreSQL Streaming Replication guide. <\/p>\n","protected":false},"author":1,"featured_media":3885,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[116,118],"tags":[195,208,386],"class_list":["post-3884","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","category-postgresql","tag-postgresql","tag-self-hosted-postgresql","tag-streaming-replication"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Setting up Streaming Replication in PostgreSQL on Ubuntu - code2deploy.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting up Streaming Replication in PostgreSQL on Ubuntu - code2deploy.com\" \/>\n<meta property=\"og:description\" content=\"Step by Step PostgreSQL Streaming Replication guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/\" \/>\n<meta property=\"og:site_name\" content=\"code2deploy.com\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-25T20:38:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-25T20:47:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.code2deploy.com\/wp-content\/uploads\/2024\/03\/Streaming-Replication-in-PostgreSQL.png\" \/>\n\t<meta property=\"og:image:width\" content=\"606\" \/>\n\t<meta property=\"og:image:height\" content=\"344\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"enam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"enam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/\"},\"author\":{\"name\":\"enam\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"headline\":\"Setting up Streaming Replication in PostgreSQL on Ubuntu\",\"datePublished\":\"2024-03-25T20:38:00+00:00\",\"dateModified\":\"2024-03-25T20:47:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/\"},\"wordCount\":1072,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Streaming-Replication-in-PostgreSQL.png\",\"keywords\":[\"PostgreSQL\",\"Self-Hosted PostgreSQL\",\"Streaming Replication\"],\"articleSection\":[\"Database\",\"PostgreSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/\",\"url\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/\",\"name\":\"Setting up Streaming Replication in PostgreSQL on Ubuntu - code2deploy.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Streaming-Replication-in-PostgreSQL.png\",\"datePublished\":\"2024-03-25T20:38:00+00:00\",\"dateModified\":\"2024-03-25T20:47:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#primaryimage\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Streaming-Replication-in-PostgreSQL.png\",\"contentUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Streaming-Replication-in-PostgreSQL.png\",\"width\":606,\"height\":344,\"caption\":\"Streaming Replication in PostgreSQL\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-streaming-replication-in-postgresql-on-ubuntu\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting up Streaming Replication in PostgreSQL on Ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\",\"name\":\"code2deploy.com\\\/blog\",\"description\":\"TechOps\",\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\",\"name\":\"enam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"caption\":\"enam\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/code2deploy.com\\\/blog\"],\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/author\\\/enam\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting up Streaming Replication in PostgreSQL on Ubuntu - code2deploy.com","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:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/","og_locale":"en_US","og_type":"article","og_title":"Setting up Streaming Replication in PostgreSQL on Ubuntu - code2deploy.com","og_description":"Step by Step PostgreSQL Streaming Replication guide.","og_url":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/","og_site_name":"code2deploy.com","article_published_time":"2024-03-25T20:38:00+00:00","article_modified_time":"2024-03-25T20:47:19+00:00","og_image":[{"width":606,"height":344,"url":"https:\/\/blog.code2deploy.com\/wp-content\/uploads\/2024\/03\/Streaming-Replication-in-PostgreSQL.png","type":"image\/png"}],"author":"enam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"enam","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#article","isPartOf":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/"},"author":{"name":"enam","@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"headline":"Setting up Streaming Replication in PostgreSQL on Ubuntu","datePublished":"2024-03-25T20:38:00+00:00","dateModified":"2024-03-25T20:47:19+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/"},"wordCount":1072,"commentCount":0,"publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"image":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Streaming-Replication-in-PostgreSQL.png","keywords":["PostgreSQL","Self-Hosted PostgreSQL","Streaming Replication"],"articleSection":["Database","PostgreSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/","url":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/","name":"Setting up Streaming Replication in PostgreSQL on Ubuntu - code2deploy.com","isPartOf":{"@id":"https:\/\/code2deploy.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#primaryimage"},"image":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Streaming-Replication-in-PostgreSQL.png","datePublished":"2024-03-25T20:38:00+00:00","dateModified":"2024-03-25T20:47:19+00:00","breadcrumb":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#primaryimage","url":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Streaming-Replication-in-PostgreSQL.png","contentUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Streaming-Replication-in-PostgreSQL.png","width":606,"height":344,"caption":"Streaming Replication in PostgreSQL"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.code2deploy.com\/setting-up-streaming-replication-in-postgresql-on-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code2deploy.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Setting up Streaming Replication in PostgreSQL on Ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/code2deploy.com\/blog\/#website","url":"https:\/\/code2deploy.com\/blog\/","name":"code2deploy.com\/blog","description":"TechOps","publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code2deploy.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b","name":"enam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","caption":"enam"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g"},"sameAs":["https:\/\/code2deploy.com\/blog"],"url":"https:\/\/code2deploy.com\/blog\/author\/enam\/"}]}},"_links":{"self":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/comments?post=3884"}],"version-history":[{"count":2,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3884\/revisions"}],"predecessor-version":[{"id":3888,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3884\/revisions\/3888"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media\/3885"}],"wp:attachment":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media?parent=3884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/categories?post=3884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/tags?post=3884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}