Posts

Showing posts with the label replication

How To Create Streaming Replication In PostgreSQL in Linux?

 Note: Before all steps, make sure that postgreSQL is installed to both primary and standby servers. If you don't have any primary server yet, make sure to initialize and put into running state. Do not initialize any database on standby side. 1- Be sure about primary and replica database server's firewall policies. They should have access to each other through postgreSQL port. 2- On the primary side, add a line as below in order to replication user access: host     replication     rep_user     <replica_ip>/32     scram-sha-256 3- Create replication user on primary server with postgres user. createuser -U postgres rep_user -P --replication -p <port> 4- Find the relevant lines in postgresql.conf below and edit: max_wal_senders=10 max_replication_slots=10 wal_keep_size=50000MB max_slot_wal_keep_size=50000MB wal_level=replica Note: Adjust wal_keep_size for your needs. Wal files will override when they reach size. 5- In order to bypass...

Streaming Replication Without Archiving (Linux)

Initial Steps Summary Let’s sum up the initial steps, then dive into key points: Ensure that the primary and replica servers have proper firewall configurations. Both servers should be able to communicate over PostgreSQL service ports (default: 5432 ). Edit pg_hba.conf on the Primary Database by adding the following line to allow the replica server to connect: host replication rep_user /32 scram-sha-256 Create a replica user on the Primary Database with the following command: createuser -U postgres rep_user -P --replication -p Edit the postgresql.conf file on the Primary Database: wal_keep_size = 10000 MB max_slot_wal_keep_size = 10000 MB Note: Adjust these values based on your needs. For a high data load, increase the value. For a low data load, decrease it. The above values assume that, at most, 10GB of data might fail to be sent during an outage. Key Points 1. Handling Large Databases For large databases, replication may take hou...