DB20000I TheSTOP HADR ON DATABASE command completed successfully.
测试:
db2inst1@DB2server1:~> db2 "insert into orgvalues (5,'org5')"
DB20000I The SQLcommand completed successfully.
备库查看
db2inst2@DB2server2:/opt/bak> db2 get snapshot fordb on oga | grep -i file
Database files closed = Not Collected
File number of first active log = Not applicable
File number of last active log = Not applicable
File number of current active log = 12
File number of log being archived = Not applicable
Rollforward log file being processed = 7
Primary logposition(file, page, LSN) = S0000012.LOG, 76, 0000000005374584
Standby logposition(file, page, LSN) = S0000012.LOG, 76, 0000000005374584
接管主库
原来的主库可以停掉也可以不停
db2inst2@DB2server2:/opt/bak> db2 takeover hadr ondatabase oga user db2inst1 using db2inst1
DB20000I TheTAKEOVER HADR ON DATABASE command completed successfully.
db2inst2@DB2server2:/opt/bak> db2 connect to oga userdb2inst1 using db2inst1
db2inst2@DB2server2:/opt/bak> db2 "select *from org"
ORGID ORGNAME
----------- --------------------
1org1
2org2
3org3
4 org4
5org5
5 record(s)selected.
查看原来主机的状态
db2inst1@DB2server1:~> db2 get snapshot for db onoga | more
Database Snapshot
Database name = OGA
Database path =/data_inst1/db2inst1/db2inst1/NODE0000/SQL00001/
Input database alias = OGA
Database status = Standby
Catalog database partition number = 0
Catalog network node name =
Operating system running at database server= LINUXAMD64
Location of the database = Local
First database connect timestamp = 2012-03-28 15:21:16.354049
Last reset timestamp =
Last backup timestamp = 2012-03-2715:20:54.000000
Snapshot timestamp = 2012-03-2816:26:47.497005
Number of automatic storage paths = 1
原来备库的状态
db2inst2@DB2server2:/opt/bak> db2 get snapshot fordb on oga | more
Database Snapshot
Database name = OGA
Database path =/data_inst2/db2inst2/db2inst2/NODE0000/SQL00001/
Input database alias = OGA
Database status = Active
Catalog database partition number = 0
Catalog network node name =
Operating system running at database server= LINUXAMD64
Location of the database = Local
First database connect timestamp = 03/28/2012 15:20:41.342208
Last reset timestamp =
Last backup timestamp =
Snapshot timestamp = 03/28/201216:27:38.538201
Number of automatic storage paths = 1