DB2 pureScale online backup recovery instance

Source: Internet
Author: User

I just got started with DB2, but I am not very familiar with the Backup recovery mechanism of DB2, and I am not familiar with the relevant information, so I have to explore it myself.

Requirement

Online compression and backup of the production database, which contains archived logs, regularly restores the backup of the production database to the test environment to ensure that the test environment uses the latest production data.

Note: The data file storage path is inconsistent between the production environment and the test environment. Pay attention to this during the recovery process.

Environment

OS:

$ Oslevel-s
December 6100-06-06-1140

Database:

$ Pwd
/Opt/IBM/db2/V9.8FP5/install

$./Db2ls

Install Path Level Fix Pack Special Install Number Install Date Installer UID
Bytes ---------------------------------------------------------------------------------------------------------------------
/Opt/IBM/db2/V9.8 9.8.0.4 4 12 Mon Jun 4 16:19:38 2012 + 0800 0
/Opt/IBM/db2/V9.8FP5 9.8.0.5 5 Fri Jul 13 15:22:55 2012 + 0800 0

$ Db2instance-list
Id type state HOME_HOST CURRENT_HOST ALERT PARTITION_NUMBER LOGICAL_PORT NETNAME
------------------------------------------------------------------------
0 member started SXYCDBM0 SXYCDBM0 NO 0 SXYCDBM0-ib0
1 member started SXYCDBM1 SXYCDBM1 NO 0 SXYCDBM1-ib0
128 cf primary SXYCDBF0 SXYCDBF0 NO-0 SXYCDBF0-ib0, SXYCDBF0-ib1
129 cf peer SXYCDBF1 SXYCDBF1 NO-0 SXYCDBF1-ib0, SXYCDBF1-ib1

Hostname state INSTANCE_STOPPED ALERT
----------------------------------
SXYCDBF1 ACTIVE NO
SXYCDBF0 ACTIVE NO
SXYCDBM1 ACTIVE NO
SXYCDBM0 ACTIVE NO

Note: This is a pureScale environment with two Member and two CF.

Backup:

$ Db2 backup db $ DBNM online to/db2fs/db2backup/backup compress INCLUDE LOGS

Backup successful. The timestamp for this backup image is: 20120731182910

Remarks: online and compressed backup. The backup image contains all the archived logs generated during the backup.

You can use the following scripts to obtain the storage paths of various database files: DBPATH, LOGPATH, and DB_STORAGE_PATH.

Db2 "select substr (type,) as type, substr (path,) as path from sysibmadm. dbpaths order by type"

Restore

Ftp the backup set of the production database to the test environment and restore the database.

1. Restore data files

Db2 restore db $ DBNM from/db2fs/db2backup/yuch/20120731 on/db2fs/sxdata dbpath on/db2fs/sxlog NEWLOGPATH/db2fs/sxlog/db2sdin1/SX2/DBPARTITION0000/LOGSTREAM0000/

Note:

The database storage path, data file storage path, and online log storage path in the test environment are inconsistent with those in the production environment. You need to modify the path during recovery.

/Db2fs/sxdata is DB_STORAGE_PATH, that is, the database storage path.

/Db2fs/sxlog is DBPATH, that is, the storage path of the data file

/Db2fs/sxlog/db2sdin1 is NEWLOGPATH, which is the online log storage path.

2. restore archived log files

Db2 restore db $ DBNM logs from/db2fs/db2backup/yuch/20120731 logtarget/db2fs/db2backup/archive_log/sx2/db2sdin1/SX2

Note:

Restore the archive logs in the backup set to the specified directory.

Logtarget is the path of the newly specified archive log.

3. roll back the database to the backup End Time

$ Db2 "rollforward db sx2 to end of logs and stop overflow log path (/db2fs/db2backup/archive_log/sx2 )"

Rollforward Status

Input database alias = sx2
Number of members have returned status = 2

Member ID Rollforward Next log Log files processed Last committed transaction
Status to be read
-----------------------------------------------------------------------------------------------------------
0 not pending S0000095.LOG-S0000095.LOG 2012-07-31-03.22.53.000000 UTC
1 not pending S0000313.LOG-S0000313.LOG 2012-07-31-03.22.53.000000 UTC

DB20000I The ROLLFORWARD command completed successfully.

Note: in DB2, rollforward operations are similar to Oracle's recover operations. The whole process is to apply the archived logs generated during the backup to the database.

Specify the directory for archiving logs in the rollforward command.

Now the database in the test environment has been restored.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.