Hadr Setup Step by Step
Hadr Setup Step by Step
Hadr Setup Step by Step
IBMStepbyStepProceduretosetupHADRreplicationbetweenDB2databasesUnitedStates
IBM Support
My support
Downloads
Training
Documents
Tickets
Communities
Other
IBM Support
system x3200|
Be the rst to ask a question Chat with our new IBM Support Agent Tool (Beta)
Technote (FAQ)
Question
You plan to setup High Availability Data Replication between two DB2 databases and need step
by step instructions
These instructions allow you to setup HADR for DB2 on a Windows environment. However the
same commands can be used for Linux and UNIX by simply changing the "D:\" to a valid path.
In
ON THE PRIMARY:
Answer
1.Createsampledbusingthedb2samplcommand.
http://www01.ibm.com/support/docview.wss?uid=swg21410648
1/4
9/29/2016
IBMStepbyStepProceduretosetupHADRreplicationbetweenDB2databasesUnitedStates
db2sampl
2.Enableitforlogarchiving.
db2updatedbcfgfor<DBNAME>usingLOGARCHMETH1LOGRETAIN
Abovecommandwillenabletodatabaseforlogarchivingandkeepthelogs
inthesameactivelogdirectory.Thiswillalsoplacethedbinbackup
pendingstate.
3.Takeanofflinebackup.
db2"backupdatabase<DBNAME>"
NOTE:AnofflinebackupisNOTmandatory.Anonlinebackupalsocanbe
used.ButonlinebackupscantakelongertobringtheHADRpairintopeer
state.Forsakeofsimplicity,weareusingofflinebackuphere.
4.SettingupHADRcfgparametersonPrimarydatabase.
Chat, contact and feedback
db2 update db cfg for <DBNAME> using HADR_LOCAL_HOST <IP ADDRESS OF PRIM>
db2 update db cfg for Need
<DBNAME>
using HADR_LOCAL_SVC <PORT # on PRIM>
support?
Ensure both the servers are on the same db2level so that a mismatch situation does not occur.
Run "db2level" command on both the servers to check whether they are on the same DB2
db2"backupdatabase<DBNAME>"
http://www01.ibm.com/support/docview.wss?uid=swg21410648
2/4
9/29/2016
IBMStepbyStepProceduretosetupHADRreplicationbetweenDB2databasesUnitedStates
6.FTPthebackupimage(fromtheprimarymachine)totheSTANDBYMACHINE
7.db2"restoredatabaseDBNAME"
8.SettingupHADRcfgparametersonstandbydatabase.
db2 update db cfg for <DBNAME> using HADR_LOCAL_HOST <IP ADDRESS ON
STANDBY>
db2 update db cfg for <DBNAME> using HADR_LOCAL_SVC <PORT # ON STANDBY>
db2 update db cfg for <DBNAME> using HADR_REMOTE_HOST <IP ADDRESS ON PRIM>
db2 update db cfg for <DBNAME> using HADR_REMOTE_SVC <PORT # ON PRIM>
db2 update db cfg for <DBNAME> using HADR_REMOTE_INST <INSTNAME ON PRIM>
9.db2starthadrondatabase<DBNAME>asstandby
10.StartingupHADRontheprimaryserver
Need support?
==================================================================
Directory of worldwide contacts
VerifingHADRisupandrunning
Submit feedback to IBM Support
db2pddb<DBNAME>hadr
1-800-IBM-7378 (USA)
Here'sthestepsonswitchingroles(PRIMARY/STANDBY)betweenthetwo
5.ONSTANDBY(CM11):db2takeoverhadrondatabase<dbname>byforce
In
6.TheSTANDBYinstanceonCM11(DB2)isnowtheprimary
machine(CM01andCM11).
1.ONPRIMARY(CM01):db2connectto<dbname>
2.ONPRIMARY(CM01):db2"createtabletab1(col1int)"
3.ONPRIMARY(CM01):db2"insertintotab1values(1)"insert20rows
4.ONPRIMARY(CM01):powerdownthePrimary>db2stopforce
7.ONCM11:db2pddb<dbname>hadr(theROLEshouldstate:PRIMARY)
http://www01.ibm.com/support/docview.wss?uid=swg21410648
3/4
9/29/2016
IBMStepbyStepProceduretosetupHADRreplicationbetweenDB2databasesUnitedStates
8.ONCM11:db2connectto<dbname>
9.ONCM11:db2"select*fromtab1"Youshouldseethe20rowsinserted
10.ONCM11:db2"createtabletab2(col1int)"
11.ONCM11db2"insertintotab2values(1)"insertabout20rows
12.ONCM01:db2starthadrondatabase<dbname>asstandby
13.ONCM01:db2pddb<dbname>hadr(theROLEshouldstate:STANDBY)
14.onCM01:db2takeoverhadrondatabase<dbname>
15.onCM01:db2pddb<dbname>hadr(theROLEshouldstate:PRIMARY)
16.ONCM01:db2"select*fromtab2"youshouldbeabletoseethe20
rowsinserted
17.onCM11:db2pddb<dbname>hadr(theROLEshouldstate;STANDBY)
Note:
1.HostnameoftheHADRpaircannotbethesameonboththeservers.
2.TheinstancenameandtheunderlyinguseridonUNIXsystemscanbe
different.Makesuretoupdatethecorrectnameoftheinstanceforthedb
cfgparameterHADR_REMOTE_INSTtothecorrectvalue.
Related information
Need support?
Community questions
andfeedback
discussion
to IBM Support
Submit
site do not represent the views or opinions of IBM. IBM, in its sole discretion, reserves the right to
Directory of worldwide contacts
remove any comments from this site. IBM is not responsible for, and does not validate or conrm,
1-800-IBM-7378
(USA)
By adding a comment, you accept
our Terms of Use.
Your comments entered on this IBM Support
the correctness or accuracy of any comments you post. IBM does not endorse any of your
comments. All IBM comments are provided "AS IS" and are not warranted by IBM in any way.
Be the rst to ask a question about this topic.
Ask a question
In
Select Lan
mail
http://www01.ibm.com/support/docview.wss?uid=swg21410648
4/4