Hot Standby in PostgreSQL 9.0:

As per definition of Hot Standby, its a method of redundancy in which primay and secondary (Backup Server) runs simultaneously. The data is mirrored to secondary so that both should contain identical data in real time. With this user, would be able to execute the Query against Database while secondary is in archive recovery mode.

This is what introduce in PG9.0. In-built Hot Standby.

PostgreSQL Community always try to make the things simpler as much as possible, same they have proven in Hot Standby Implementation.

Following are the steps of configuring Hot Standby:
1. Make sure following parameters are set in Configuration file, postgresql.conf of Primary:
wal_level = ‘hot_standby’
archive_mode = on
archive_command = ‘cp %p /Library/PostgreSQL/9.0/data/archivelog/%f’
2. After setting the above parameters, Now take the hot backup of PG9.0 Instance. Steps of Hot Backup is simple:
a) Execute following command in Primary:
select pg_start_backup(‘Hot Standby Backup’);
b) Take the file system backup of PG 9.0 Data directory, as given below:
cp -r $PRIMARY/* $HTStandby/
c). Execute following command to stop the Hot Backup:
select pg_stop_backup();
3. After taking the Hot Backup and restoring it desired location, set following parameter in postgresql.conf file of Hot Standby:
hot_standby = on
4. Create a recovery.conf file in Hot Standby restore location and set the following parameters:
standby_mode = 'on'
restore_command = 'cp /Library/PostgreSQL/9.0/data/archivelog/%f %p'
5. Clean the pg_xlog and pg_xlog/archive_status directories of Hot Standby Data directory.
6. Remove the postmaster.pid file from Hot Standby Data Directory.
7. Now start the Instance using following command:
pg_ctl -D $HTStandby start
Now, hot standby is up and running.

Following are few snapshots (Primary Port is 5432 and Hot Standby Port 5433:

1. Here I have inserted one value in table "test" and created a new table test2 with some records:



2. Now on Standby Following is a snapshot:


Comments

  1. Nice post.. One step is missing. - After taking the base backup, one needs to remove postmaster.pid from the standby cluster directory.
    -Sandeep

    ReplyDelete
  2. Hey Vibhor,

    Slony is giving me same features,then why should i go for streaming replication ?

    Please comment.

    -Rajiv

    ReplyDelete
  3. Following are the reasons which you can consider for using Streaming Replication:
    1. It replicates data and DDLs Both.
    2. Replication lag time is very very less.
    3. There is no overhead of Triggers in Streaming Replication.
    4. Failover is easier than Slony.

    ReplyDelete

Post a Comment

Popular posts from this blog

xDB Replication from Oracle to PPAS

Does UPDATE Change ROWID in Oracle?

PostgreSQL Database Link to Oracle Database on Linux