Page 1
Redirect Restore Of DB2 For an ABAP system
Overview : The redirected restore is intended to copy one database to
another database with changed container layout/changed storage path
layout(for autostorage enabled database) in the target database.
Source
System
Target
System
<SSID>
<TSID>
DB2
DB2
Contents :
1. Pre-requisite
2. Steps in Source System
3. Steps in target System
4. Post-Copy Steps
Page 2
1. Pre-requisite :
Update the tool brdb6brt (This tool is SAP provided) and check whether it supports
autostorage or not.
The tool is a part of the SAP kernel (DB2-specific kernel archive)
Login as user <ssid>adm.
cd /sapmnt/SID/exe
Execute :
db2cpp 4> brdb6brt -V
2. Steps in Source System:
Page 3
The tool db2adult is used with Tivoli Storage Manager (TSM) to work with backup
images.
For the target system to access the source systems images on TSM, a priviledge
needs to be assigned to the target systems database administration user which is
typically db2<sid> in an SAP environment. Below is the command to execute the
same.
db2ccp> db2adutl grant user db2ccq on nodename cccqae2_ccq for db ccp
Successfully added permissions for db2ccq to access CCP on node cccqae2_ccq
1. log in as root
2. change user to <SSID>adm
> stopsap
3. change user db2<SSID>
db2stop
IMP: if not getting down then
# db2 terminate
& again
# db2stop
# db2start
4. Check the backup stored in TSM using this command
> db2adutl query full db srp nodename cccsrpe2_srp owner db2srp
Page 4
You can query the backup images available in TSM of the source system
database. You can run this query from either the source or the target system.
5. Generate the script using brdb6brt utility
brdb6brt s <SSID> -bm RETRIEVE -ts <timestamp> replace
<SSID>=<TSID>, /db2/<SSID>=/db2/<TSID>,db2<TSID>=db2<SSID>
If Source SID = SRP & Target SID = SRQ
Command will be
brdb6brt -s SRP -bm RETRIEVE -ts 20101129180302 -replace
SRP=SRQ,db2srp=db2srq,/db2/SRP=/db2/SRQ
6. Script will be created with name like SRP_NODE0000.scr in current folder
7. copy the script with name <TSID>.scr
> cp TTM_NODE0000.scr <TSID>.scr
8. open with vi editor <TSID>.scr
Search for FROM in the script [/ ]
Edit the line like
RESTORE DATABASE SRP
-- ** Instance owner user id ( db2<dbsid> )
-- S##############################
-- USER <user> USING <password>
-- E##############################
-- INCREMENTAL AUTOMATIC
-- ** Path or device where the backup image is stored
-- S##############################
USE TSM options "-fromnode=cccsrpe2_srp
-fromowner=db2srp"
-- ** Timestamp (when was the backup image taken? )
-- ** use the given format: YYYYMMDDhhmmss
-- S##############################
TAKEN AT 20101129180302
9. After successful completion of backup, start sap with user <ssid>adm.
> su - <ssid>adm
> startsap
10. Transfer the backup image and script from source system to target system
Page 5
3. Steps in target System:
1. Login to Target System as root.
check sap instance status
# ps aef |grep dw
2. change user to <sid>adm
> stopsap
After successfully stopping the instances
> exit
3. Change user to db2<sid>
4. Start DB2 again : db2start
Make sure Database instance is running
db2 drop db <SID>
Stop DB2 again : db2stop force
5. Delete all sapdata and saptemp directory from /db2/<SID>
> rm rf sapdata* saptemp*
6. Create new directory with full permission
> mkdir sapdata1 sapdata2 sapdata3 sapdata4
> chmod 777 sap*
7.
Delete all the content for the directory log_dir/NODE0000
Page 6
8. change directory to /db2/<TSID>/restore and execute the script
db2 -tvf <TSID>.scr
9. Make sure that db2 instance is running, if not running issue db2start to start the
db2 instance.
The warning can be ignored.
The warning is like
SQL1277N Restore has detected that one or more table space containers are
inaccessible, or has set their state to 'storage must be defined'.
Output should be like
RESTORE DATABASE TTM CONTINUE
DB20000I The RESTORE DATABASE command completed successfully.
10. If Rollforward didnt finished successfully you will get this message
11. You have to retrieve log from TSM using this command :
db2adutl extract logs between <Start log> AND <End log> db <SSID>
nodename <SNODE NAME> owner <Owner Name>
db2adutl extract logs between S0000301.LOG AND S0000306.LOG db srp
nodename cccsrpe2_srp owner db2srp
12. Then execute this command
db2 ROLLFORWARD DATABASE SRQ TO END OF LOGS and stop
Page 7
Then execute :
db2 ROLLFORWARD DATABASE <SID> complete.
4. Post-copy Steps (on the target system) :
1. Check sap<ssid> user exist or not.
# cat /etc/passwd and look for sap<ssid>
2. Create sap<SSID> user of source
> useradd -create -c "SAP Database Connect User" -s /bin/csh -d
/home/sap<ssid> -g sapsys -m sap<ssid> passwd sap<ssid>
Also create a user db2<ssid> on the target system.
3. Connect to the System [as db2<ssid> which was just created]
> db2 connect to <SID>
Execute the following :
grant dbadm , secadm on database to user db2<tsid>
grant dbadm on database to user <tsid>adm
4. login as <tsid>adm and edit the below file in the users home directory.
vi ~/.dbenv_<hostname>.csh
example. vi ~/.dbenv_<hostname>.csh
Search for the string dbs_db6_schema and set the variable as follows.
From
Page 8
To
setenv dbs_db6_schema sap<tsid>
setenv dbs_db6_schema sap<ssid>
Logoff and login again as user <tsid>adm so that the change is in effect.
5. Update password in dscdb6.conf under /sapmnt/<SID>/global using the
following command :
dscdb6up create <password of sap<ssid>> <password of <tsid>adm>
6. Check schema user is connecting to DB2
R3trans d ( it should return value 0)
8. Start target SAP application
>startsap
( Note : The SAP kernel level on the target should be equal to or higher than the
kernel level of the source system )
Disclaimer : This document has been created during a customer assignment and
the contents may not fit exactly into your scenario.