Posts

Showing posts from September, 2010

Physical Standby Vs Hot Standby

Some thoughts always come in mind about standby terminologies. Once, Someone has asked question about Physical Standby of Oracle10g. Is Oracle10g Physical Standby a Hot Standby Or WarmStandby? Till Oracle 10g, Physical Standby of Oracle is a standby which has two mode: 1. Managed Recovery Mode 2. Read Only Mode. It cannot be in both mode at same time. If the standby is in recovery mode then, it's a Warm Standby and when its read only mode then, then it's lagging from Primary and would be able to response SELECT queries. Either way, till Oracle 10g physical standby was not meeting the requirement of Hot Standby. It was playing the role of Warm Standby. However, from Oracle 11g, Physical Standby can be Recovery mode and read only mode, both at the same time, which now fulfill the definition of Hot Standby. With the complexity of managing the Standby, licensing thing comes in Picture. PG9.0 onwards, PostgreSQL now has Cold Standby, Warm Standby and Hot Standby, with zero cost....

Hot Standby in PostgreSQL 9.0:

Image
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 fi...

pgAgent Configuration on Windows

Here are the steps which some one can use to configure the pgAgent. These steps are tested on my machine: 1. Login to system as test_user: Please create a pgpass.conf file in test_user %APPDATA%\postgresql directory: Entry for pgpass.conf should be as given below: hostname:port:database:username:password 2. Connect to database as given below: C:\”Program Files”\PostgresPlus\8.4\bin\psql.exe -U postgres (Above command will also verify that pgpass.conf is used by the psql command or not) 3. After connecting to database, create plpgsql language as given below: CREATE LANGUAGE plpgsql; 4. Now, run the pgagent.sql file. 5. Create pgAgent service, as given below: pgagent.exe INSTALL pgAgent -u test_user -p test hostaddr= dbname= user= 3. Start the created service using following command: net start pgAgent 4. While Creating job, Please keep the output of following command in “Host Agent” field of “pgAgent Job” window: select jagstation from pageant.pga_jobagent;

Monitor PG WarmStandBy

While working with Database, some people have asked to write a Monitoring script for WarmStandby. Here is a script which can be use for it: #!/bin/bash BIN=/opt/PostgresPlus/8.4SS/bin WARMDATA=/sata/data PSQL=$BIN/psql PRIM_HOST=primarserver.ic ST_LOGFILE=/usr/local/pgsql/pg_standby/standby.log STANDBYLOGLOC=/sata/backups/pg8.4/standby_wal echo -e "" echo -e "+-----------------------------------------------------------+" echo -e "|Finding the Minimum Recovery: |" echo -e "+-----------------------------------------------------------+" MINRECOV=`$BIN/pg_controldata $WARMDATA |grep 'Minimum recovery'|awk -F": " '{print $2}'|sed 's/ *//g'` MINRECOVWAL=`$PSQL -h $PRIM_HOST -t -p 5432 -c "select pg_xlogfile_name('$MINRECOV');"|sed 's/ *//g'` if [ -n $MINRECOVWAL ];then echo -e "|Minimum Recovery WAL file require: $MINRECOVWAL|" echo -e "+--------...