Wednesday, May 18, 2011

DB2 DBA activity

Scenario 1: Restore DB A to DB B.

few prerequsite:
- there are two types of containers- device and file containers.


During a database backup operation, a record is kept of all the table space containers associated with the table spaces that are being backed up. During a restore operation, all containers listed in the backup image are checked to determine if they exist and if they are accessible. If one or more of these containers is inaccessible because of media failure (or for any other reason), the restore operation will fail. A successful restore operation in this case requires redirection to different containers. DB2(R) supports adding, changing, or removing table space containers.
You can redefine table space containers by invoking the RESTORE DATABASE command and specifying the REDIRECT parameter, or by using the Containers page of the Restore Database notebook in the Control Center. The process for invoking a redirected restore of an incremental backup image is similar to the process for a non-incremental backup image: Call the RESTORE DATABASE command with the REDIRECT parameter and specify the backup image from which the database should be incrementally restored.

 Example:


db2 "restore db maxdb72 from /db2offlinebackup taken at 20110516122902 into maxdbrep redirect without prompting"
SQL1277W  A redirected restore operation is being performed.  Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I  The RESTORE DATABASE command completed successfully.

db2 "set tablespace containers for 3 using (device '/dev/rmaxdbspacerep' 19968M)"
SQL0104N  An unexpected token "19968M" was found following
"<character-string>".  Expected tokens may include:  "<unsigned-long-number>".
SQLSTATE=42601
db2 "set tablespace containers for 3 using (path '/dev/rmaxdbspacerep')"
SQL0298N  Bad container path.  SQLSTATE=428B2

db2 set tablespace containers for 4 using (path '/dev/rmaxinspacerep')
SQL0298N  Bad container path.  SQLSTATE=428B2


[db2sbysa@pokxmx5dbru01] /db2offlinebackup> db2 "set tablespace containers for 0 using ( path '/maximo/syscatspacerep')"
DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.
[db2sbysa@pokxmx5dbru01] /db2offlinebackup> db2 "set tablespace containers for 7 using (path '/maximo/systempspacerep')"
SQL20319N  The SET TABLESPACE CONTAINERS command is not allowed on an
automatic storage table space.  SQLSTATE=55061
[db2sbysa@pokxmx5dbru01] /db2offlinebackup> db2 "set tablespace containers for 2 using (path '/maximo/userspacerep')"
DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.
[db2sbysa@pokxmx5dbru01] /db2offlinebackup> db2 "set tablespace containers for 5 using (path '/maximo/systemp32krep')"
DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.



db2 set tablespace containers for 8 using (path '/dev/rcidatarep1')
SQL0298N  Bad container path.  SQLSTATE=428B2

db2 set tablespace containers for 9 using (device '/dev/rscdatarep1' 5000M)
db2 set tablespace containers for 10 using (device '/dev/rtxtdatarep1' 5000M)
db2 set tablespace containers for 11 using (device '/dev/rwodatarep1' 5000M)


No comments:

Post a Comment