PostgreSQL Hot Standby功能简析(二)

2014-11-24 11:35:41 · 作者: · 浏览: 2
ata # LOG: database system was interrupted; last known up at 2010-08-21 22:43:04 CST
LOG: entering standby mode
LOG: redo starts at 0/1000020
LOG: record with zero length at 0/10000B0
LOG: streaming replication successfully connected to primary
LOG: consistent recovery state reached at 0/2000000
LOG: database system is ready to accept read only connections
这时可以看到备库已经可以接受只读连接了。
在主库上做一些操作:
linux-david:/var/lib/pgsql/data # psql -p 5432 -d postgres
psql (9.0beta4) www.2cto.com
Type "help" for help.
postgres=# create table t (id int primary key,name varchar(20));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t_pkey" for table "t"
CREATE TABLE
postgres=# insert into t values (1,'xxxxxxx');
INSERT 0 1
postgres=# insert into t values (2,'xxxxxxx');
INSERT 0 1
postgres=#
然后在备库上看是否同步到了备库:
linux-david:/var/lib/pgsql/data # psql -p 5432 -d postgres
psql (9.0beta4)
Type "help" for help.
postgres=# \d
List of relations
Schema | Name | Type | Owner
--------+------+-------+-------
public | t | table | osdba
(1 row)
postgres=# select * from t;
id | name www.2cto.com
----+---------
1 | xxxxxxx
2 | xxxxxxx
(2 rows)
可以看到数据已经同步到了备库,基本上感觉不到延迟。
作者 's