Update configuration parameters on primary database -
UPDATE DB CFG FOR DB SAMPLE USING LOGINDEXBUILD ON
UPDATE DB CFG FOR DB SAMPLE USING INDEXREC RESTART
Copy backup image from primary to standby system.
BACKUP DB SAMPLE TO '/home/db2inst/backups'
UPDATE DB CFG FOR DB SAMPLE USING INDEXREC RESTART
Copy backup image from primary to standby system.
BACKUP DB SAMPLE TO '/home/db2inst/backups'
Restore database on standby system
RESTORE DATABASE SAMPLE REPLACE HISTORY FILE WITHOUT PROMPTING
Configure databases for client reroute - Primary
UPDATE ALTERNATE SERVER FOR DATABASE SAMPLE USING HOSTNAME <Standby ip address> PORT <inst port>
Configure databases for client reroute -Standby
RESTORE DATABASE SAMPLE REPLACE HISTORY FILE WITHOUT PROMPTING
Configure databases for client reroute - Primary
UPDATE ALTERNATE SERVER FOR DATABASE SAMPLE USING HOSTNAME <Standby ip address> PORT <inst port>
Configure databases for client reroute -Standby
UPDATE ALTERNATE SERVER FOR DATABASE SAMPLE USING HOSTNAME <prim ip address> PORT <inst port>
Edit /etc/services file and create an HADR port on both systems.
On Windows:
On Windows:
notepad %SystemRoot%\system32\drivers\etc\services
Linux : vi /etc/services
Linux : vi /etc/services
Add HADR line on both primary and standby system.
Update HADR configuration parameters on primary database -
UPDATE DB CFG FOR SAMPLE USING HADR_LOCAL_HOST <prim ip>
UPDATE DB CFG FOR SAMPLE USING HADR_LOCAL_SVC DB2_HADR2
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_HOST <sb ip>
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_SVC DB2_HADR1
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_INST DB2
UPDATE DB CFG FOR SAMPLE USING HADR_SYNCMODE NEARSYNC
UPDATE DB CFG FOR SAMPLE USING HADR_TIMEOUT 120
UPDATE DB CFG FOR SAMPLE USING HADR_LOCAL_SVC DB2_HADR2
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_HOST <sb ip>
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_SVC DB2_HADR1
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_INST DB2
UPDATE DB CFG FOR SAMPLE USING HADR_SYNCMODE NEARSYNC
UPDATE DB CFG FOR SAMPLE USING HADR_TIMEOUT 120
Enable cfg changes by forcing off all connections
CONNECT TO SAMPLE
QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS
UNQUIESCE DATABASE
CONNECT RESET
Update HADR configuration parameters on standby database - --
QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS
UNQUIESCE DATABASE
CONNECT RESET
Update HADR configuration parameters on standby database - --
UPDATE DB CFG FOR SAMPLE USING HADR_LOCAL_HOST <sb ip>
UPDATE DB CFG FOR SAMPLE USING HADR_LOCAL_SVC DB2_HADR1
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_HOST <prim ip>
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_SVC DB2_HADR2
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_INST DB2
UPDATE DB CFG FOR SAMPLE USING HADR_SYNCMODE NEARSYNC
UPDATE DB CFG FOR SAMPLE USING HADR_TIMEOUT 120
Start HADR on standby database
DEACTIVATE DATABASE SAMPLE
START HADR ON DATABASE SAMPLE AS STANDBY
Start HADR on primary database
DEACTIVATE DATABASE SAMPLE
START HADR ON DATABASE SAMPLE AS PRIMARY
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_HOST <prim ip>
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_SVC DB2_HADR2
UPDATE DB CFG FOR SAMPLE USING HADR_REMOTE_INST DB2
UPDATE DB CFG FOR SAMPLE USING HADR_SYNCMODE NEARSYNC
UPDATE DB CFG FOR SAMPLE USING HADR_TIMEOUT 120
Start HADR on standby database
DEACTIVATE DATABASE SAMPLE
START HADR ON DATABASE SAMPLE AS STANDBY
Start HADR on primary database
DEACTIVATE DATABASE SAMPLE
START HADR ON DATABASE SAMPLE AS PRIMARY
View status of HADR
=>db2pd -db <dbname> -hadr
Swap roles of Primary and Standby
=>db2 takeover hadr on db <dbname>
Takeover Primary operation on the standby db when the original primary is down
=>db2 takeover hadr on db <dbname> by force
Work Sheet ::
db2 connect to lenovo
db2 create bufferpool bp4k0 size 200 pagesize 4k
db2 create tablespace tsd4k0 pagesize 4k managed by automatic storage bufferpool bp4k0
db2 "create table tabA (id int) in tsd4k0"
db2 "create table tabB (id int) in tsd4k0"
db2 "insert into tabA values (1)"
db2 "insert into tabB values (10)"
db2 backup db lenovo online to '/home/db2inst2/backups'
chmod a+x LENOVO.0.db2inst2.NODE0000.CATN0000.20150926220746.001
scp LENOVO.0.db2inst2.NODE0000.CATN0000.20150926220746.001
db2inst1@192.168.65.124:'/home/db2inst1/back2'
--restore in second sesion (server2)
db2 restore db lenovo from '/home/db2inst1/back2' taken at 20150926220746 on
'/home/db2inst1'
db2 update db cfg for lenovo using TRACKMOD ON
db2 update db cfg for lenovo using LOGARCHMETH1 DISK:/home/db2inst1/archs
db2 update db cfg for lenovo using LOGINDEXBUILD ON
db2 update db cfg for lenovo using INDEXREC RESTART
db2 update db cfg for lenovo using HADR_LOCAL_HOST 192.168.65.124
db2 update db cfg for lenovo using HADR_LOCAL_SVC DB2_db2inst2
db2 update db cfg for lenovo using HADR_REMOTE_HOST 192.168.65.124
db2 update db cfg for lenovo using HADR_REMOTE_SVC DB2_db2inst1
db2 update db cfg for lenovo using HADR_REMOTE_INST db2inst1
--do same updates in primay and standby by required changes(server1 and server 2)
--In server2
db2 start hadr on db lenovo as standby
--In server1
db2 start hadr on db lenovo as primary
db2 grant select on DB2INST2.EMP to user db2inst1
--In server2 (to switch roles/manual switch)
db2 takeover hadr on db lenovo
..
No comments:
Post a Comment