18
[root@ppas1 ~]# edb-psql -p 9999 -U enterprisedb edbedb-psql (9.0.4.10)
Type "help" for help.
edb=# create table a (id int);
CREATE TABLE
edb=# insert into a values (5),(6);
INSERT 0 2
edb=# select * from a;
id
---
5
6
(2 rows)
19
[root@ppas1 ~]# /etc/init.d/ppas-9.0 stopStopping Postgres Plus Advanced Server 9.0:
waiting for server to shut down....... doneserver stopped
20
[root@ppas2 ~]# edb-psql -h 192.168.122.11 -p 9999 -U enterprisedbedb
edb-psql: server closed the connection unexpectedlyThis probably means the server terminated abnormallybefore or while processing the request.
以上连接出错是由于pgpool 正好此时的路由指向到PPAS1,但此时PPAS1的数据库已经STOP 。
[root@ppas2 ~]# edb-psql -h 192.168.122.11 -p 9999 -U enterprisedbedb
edb-psql (9.0.4.10)
Type "help" for help.
edb=#
重新再连接一次,此时pgpool 会将连接转向PPAS2,同时在pgpool 内部会将PPAS1定为故障状态,直到PPAS1的数据库重新可用。
21
edb=# insert into a values (7);
ERROR: cannot execute INSERT in a read-only transaction
由于PPAS2还在Stream Replication 的Slave 状态,因此不可做写数据操作
edb=# \q
22
[root@ppas2 ~]# touch /opt/PostgresPlus/9.0AS/data/recovery_trigger
[root@ppas2 ~]# edb-psql -h 192.168.122.11 -p 9999 -U enterprisedbedb
edb-psql (9.0.4.10)
Type "help" for help.
edb=# insert into a values (7);
ERROR: cannot execute INSERT in a read-only transaction
此处操作太快了,因此系统还没有改为Master 状态
edb=# insert into a values (7);
INSERT 0 1
再过1-2 秒进行操作,写入成功
edb=#
------------------------------------华丽丽的分割线------------------------------------
CentOS 6.3环境下yum安装PostgreSQL 9.3
Ubuntu下LAPP(Linux+Apache+PostgreSQL+PHP)环境的配置与安装
PostgreSQL配置Streaming Replication集群
------------------------------------华丽丽的分割线------------------------------------