Sie sind auf Seite 1von 9

Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.

com/Postgresql_Warm_Standby_point_in_time_recovery/

『 AskWan』

Related About My Life,Unix,Linux,Mysql,PostgreSQL,Oracle Etc

Home Archive RSS Login Tags feedsky Links Message About Me


Search use pgFouine analyse postgresql slow queries
Postgresql Warm oracle 10g em and isqlplus unrecognizable chinese characters on debian lenny
Title Search Standby Testing Large | Medium | Small

[ 2009/12/03 11:24 | by askwan ]


OS: Debian5.0 lenny x86_64
Categories
Postgresql:8.3.8
Master :192.168.0.121
Oprating System Warm Standby:192.168.0.122
[103]

DataBase [49]

Architecture &
HA [10]

Application [3]

Scripts [33]

My Diary [39]

Latest Entries

How to install ipmitool


to support IPMI on
Debian Lenny for Dell
PE sc1435 1. install postgresql on both master and warm standby server.
胶囊公寓
How to configure #cd /usr/local/src/postgresql-8.3.8/
bounce handling in #./configure –prefix=/usr/local/pgsql

1 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

PhpList #make
That a "machine" you #make install
are sitting in front of #mkdir /usr/local/pgsql/data
the machine? #chown postgres /usr/local/pgsql/data
oracle asm configure
#su - postgres
error
"500 ERROR: User 'root' $/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
cannot be used as an
NX user"

Links
2. Config passwordless ssh authentication use user postgres
��FriendsLinks��
�� ��
Please refer to http://www.petefreitag.com/item/532.cfm
jeson
???blog
sysadmin 3. Install pg_standby on both both master and warm standby server.
GGclub
mysql2008
techtarget
iamchaichai #cd /usr/local/src/postgresql-8.3.8/contrib/pg_standby
Vincent #make
��Sites&Blogs��
�� �� #make install
Highscalability
TaoJuKe
toplee.com
howtoforge 4. Config postgresql
mysqlperformance
linuxweblog In master server :
Norbert Tretkowski
webscalingblog Quotation
Bruce Momjian
askapache archive_mode = on
Ronald Bradford archive_command = 'rsync -arv %p postgres@192.168.0.122:/wal_archives/%f'
rocksclusters
archive_timeout = 1200
alexwilliams
��DBA
�� Group����
planetmysql
oracle-base
Xaprb in warm standby server :

2 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

Mark Callaghan
mysqlDBA #mkdir /wal_archives
guyharrison #chown postgres /wal_archives/
DimitriK
Venu Anuganti
ronaldbradford
mysqlsandbox start master server :
���Security���
��� ���
linuxsecurity pg_ctl -D /usr/local/pgsql/data/ start -l /usr/local/pgsql/data/logfile
microsoftsecurity
redhatsecurity
debiansecurity
blackhat
defcon
� Virtualization�
-� �- 5. Dump all production data to master server .
www.vcritical.com
xtravirt.com
You can check the warm standby server ‘s /wal_archives directory , whether there is archive logs from master
Archive server located on .

2011/05
6. Login to master server as postgres user.
2011/04
Create a script to do a base backup:
2011/03
2011/02
Quotation
2011/01
2010/12 #!/bin/bash
PGDATA=/usr/local/pgsql/data
Statistics
psql -c "CHECKPOINT;"
Visits 2265310 psql -c "SELECT pg_start_backup('BASEBACKUP');"
Entries 237 tar -C /usr/local/pgsql/ -zcf - data |ssh 192.168.0.122 "tar -C /usr/local/pgsql/ -zxf -"
Online 12
psql -c "select pg_stop_backup();"
Misc echo "BASEBACKUP compete!"

Login
Register
Link exchange 7. Login to warm standby server as postgresql user.
RSS: Entries | Comments Create a script to do some clean and configuration
Charset: UTF-8

3 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

XHTML 1.0
Quotation
Select the template style
#!/bin/bash
kseey
PG_HOME=/usr/local/pgsql
PGDATA=/usr/local/pgsql/data
trigger_file=/tmp/pgsql.trigger
pg_standby=$PG_HOME/bin/pg_standby
PG_ARCHIVES=/wal_archives
rm -f $PGDATA/recovery.*
rm -f $PGDATA/logfile
rm -f $PGDATA/postmaster.pid
rm -f $PGDATA/pg_xlog/0*
rm -f $PGDATA/pg_xlog/archive_status/0*
sed -i '/^archive_/s/^/#/g' $PGDATA/postgresql.conf
echo "restore_command = '$pg_standby -l -d -s 2 -t $trigger_file $PG_ARCHIVES %f %p %r 2>>/tmp
/standby.log'" > $PGDATA/recovery.co
nf
chown postgres.postgres $PGDATA/recovery.conf
echo "Init completed! now start warm standby server."

Note:PostgreSQL 8.4 provides the recovery_end_command option.so,in recovery.conf add


recovery_end_command=’rm –f /tmp/pgsql.trigger ’

pg_standby supports creation of a "warm standby" database server. It is designed to be a production-ready


program, as well as a customizable template should you require specific modifications.
More about pg_standby,refer to http://www.postgresql.org/docs/current/static/pgstandby.html
http://www.enterprisedb.com/docs/en/8.4/pg/pgstandby.html

8. Start warm standby server

4 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

pg_ctl -D /usr/local/pgsql/data start -l /usr/local/pgsql/data/logfile

9. check warm standby postgresql logfile:

Quotation

LOG: database system was interrupted; last known up at 2009-12-03 11:44:37 CST
LOG: starting archive recovery
LOG: restore_command = '/usr/local/pgsql/bin/pg_standby -l -d -s 2 -t /tmp/pgsql.trigger
/wal_archives %f %p %r 2>>/tmp/standby.log
'
LOG: restored log file "000000010000000000000014.00000020.backup" from archive
LOG: restored log file "000000010000000000000014" from archive
LOG: automatic recovery in progress
LOG: redo starts at 0/14000068
FATAL: the database system is starting up
LOG: restored log file "000000010000000000000015" from archive
LOG: restored log file "000000010000000000000016" from archive
LOG: restored log file "000000010000000000000017" from archive
LOG: restored log file "000000010000000000000018" from archive
LOG: restored log file "000000010000000000000019" from archive
LOG: restored log file "00000001000000000000001A" from archive
LOG: restored log file "00000001000000000000001B" from archive
LOG: restored log file "00000001000000000000001C" from archive
LOG: restored log file "00000001000000000000001D" from archive
LOG: restored log file "00000001000000000000001E" from archive
LOG: restored log file "00000001000000000000001F" from archive
LOG: restored log file "000000010000000000000020" from archive
LOG: restored log file "000000010000000000000021" from archive
……

5 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

Check standby logfile:

Quotation

Trigger file : /tmp/pgsql.trigger


Waiting for WAL file : 00000001.history
WAL file path : /wal_archives/00000001.history
Restoring to... : pg_xlog/RECOVERYHISTORY
Sleep interval : 2 seconds
Max wait interval : 0 forever
Command for restore : ln -s -f "/wal_archives/00000001.history" "pg_xlog/RECOVERYHISTORY"
Keep archive history : 000000000000000000000000 and later
running restore : OK
Trigger file : /tmp/pgsql.trigger
Waiting for WAL file : 000000010000000000000014.00000020.backup
WAL file path : /wal_archives/000000010000000000000014.00000020.backup
Restoring to... : pg_xlog/RECOVERYHISTORY
Sleep interval : 2 seconds
Max wait interval : 0 forever
Command for restore : ln -s -f "/wal_archives/000000010000000000000014.00000020.backup"
"pg_xlog/RECOVERYHISTORY"
Keep archive history : 000000000000000000000000 and later
running restore : OK
Trigger file : /tmp/pgsql.trigger
Waiting for WAL file : 000000010000000000000014
WAL file path : /wal_archives/000000010000000000000014
Restoring to... : pg_xlog/RECOVERYXLOG
Sleep interval : 2 seconds
Max wait interval : 0 forever
Command for restore : ln -s -f "/wal_archives/000000010000000000000014"
"pg_xlog/RECOVERYXLOG"
Keep archive history : 000000000000000000000000 and later
running restore : OK

6 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

Trigger file : /tmp/pgsql.trigger


Waiting for WAL file : 000000010000000000000015
WAL file path : /wal_archives/000000010000000000000015
Restoring to... : pg_xlog/RECOVERYXLOG
Sleep interval : 2 seconds
Max wait interval : 0 forever
Command for restore : ln -s -f "/wal_archives/000000010000000000000015"
"pg_xlog/RECOVERYXLOG"
Keep archive history : 000000010000000000000014 and later
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
Trigger file : /tmp/pgsql.trigger
Waiting for WAL file : 000000010000000000000016
WAL file path : /wal_archives/000000010000000000000016
Restoring to... : pg_xlog/RECOVERYXLOG
Sleep interval : 2 seconds

Restoring to... : pg_xlog/RECOVERYXLOG


Sleep interval : 2 seconds
Max wait interval : 0 forever
Command for restore : ln -s -f "/wal_archives/000000010000000000000016"
"pg_xlog/RECOVERYXLOG"
Keep archive history : 000000010000000000000014 and later
running restore : OK
......
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
......

10. failover
In warm standby server

7 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

touch /tmp/ pgsql.trigger

相 关 日志
create a standby database using active database duplication in oracle 11g
Streaming Replication in postgresql 9.0
use Pgpool-II and HeartBeat realize high availability of postgresql
use pgFouine analyse postgresql slow queries

作者:askwan@『
作者: 『 AskWan』

地址:http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/
地址:
可以转载 转载时请 以 链 接形式注明作者和原始出处
可以 转载,转载时请
转载 转载时请以 接形式注明作者和原始出 处 及本声明!

Tags: postgresql , warm , standby , pitr

DataBase | Comments(1) | Trackbacks(0) | Reads(1432)

收藏到网摘:

Grant 2010/04/06 08:55


Nice tutorial. Very concise.

Pages: 1/1 1

Add a comment

Emots Nickname Password Optional

Site URI Email [Register]

8 of 9 5/24/2011 11:22 AM
Postgresql Warm Standby Testing - 『AskWan』 - Related About My Life,Unix,Linux,Mysql,Pos... http://www.askwan.com/Postgresql_Warm_Standby_point_in_time_recovery/

Enable HTML
Enable UBB
Enable Emots
Hidden
Remember

Submit Reset

沪ICP备07504956号
UI Designed By AskWan & Kseey

9 of 9 5/24/2011 11:22 AM

Das könnte Ihnen auch gefallen