In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to use backup to achieve off-machine restore in DB2 database". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
A production DB2 database needs to back up all its data, and then restore and import it into a test database, encountered some problems, and finally satisfactorily solved, now record the steps to facilitate learning and analysis.
System environment: AIX5.3
Database: DB2 V9.1
Two servers: production server 192.168.11.178
Test server 10.10.11.81
I. backup
Back up the database of the production server and the test server respectively (the database is the same on both servers)
$db2 backup db LAW online to / basefsnew/db2bak0111 include logs # production
Backup was successful. The timestamp of this backup image is: 20130111180236
$db2 backup db LAW online to / basefs/db2bak0111 include logs # Test
Backup was successful. The timestamp of this backup image is: 20130111190381
Transfer the backup of the production library to the test server
You can use SCP commands or other file transfer software to send backups. Here, remind you that backups need to be changed to master and group permissions, otherwise it will lead to errors during restore.
III. Specific reduction process and problem solving
$db2 force applications all (stop all application connections first)
DB20000I The FORCE APPLICATION command completed successfully.
DB21024I This command is asynchronous and may not be effective immediately.
Start the restore on the test server
$db2 restore db LAW from / home taken at 20130111180236
SQL2539W Warning! Restoring to an existing database that is the same as the backup p_w_picpath database. The database files will be deleted.
Do you want to continue? (YBO) y
DB20000I The RESTORE DATABASE command completed successfully.
Restore succeeded
But then connected to the database, the Times made an error.
$db2 connect to LAW
SQL1117N A connection to or activation of database "LAW" cannot be made
Because of ROLL-FORWARD PENDING. SQLSTATE=57019
This prompt means that the log during the roll forward is required to activate the database.
Execute this sentence to roll forward
$db2 rollforward db LAW to end of logs and complete
SQL4970N Roll-forward recovery on database "LAW" cannot reach the specified
Stop point (end-of-log or point-in-time) because of missing log file (s) on
Node (s) "0".
Prompt missing log, unable to reach the end point
Note: when it is successful, it is in this state.
$db2 rollforward db LAW to end of logs and complete
Rollforward Status
Input database alias = db
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed =-
Last committed transaction = 2013-1-11-10.59.23.000000
DB20000I The ROLLFORWARD command completed successfully.
Let's take a look at the status and prompts of the database through this command.
$db2 rollforward db LAW query status
Rollforward Status
Input database alias = LAW
Number of nodes have returned status = 1
Node number = 0
Rollforward status = DB working
Next log file to be read = S0003169.LOG
Log files processed =-
Last committed transaction = 2012-08-24-12.02.32.000000
With this command, we find that the prompt for the next log is S0003169.LOG
You need to find the path where this file is located and synchronize or copy all the logs from the backup point in time on the production server to the test server.
Locate the DB2 log on the production server with the directory / home/db2logs/db2inst2/LAW/NODE0000/C0000004
Put all copies of the logs in this directory after the point in time when the backup was made to the corresponding directory of the test server (the directory where the library can be backed up). At the same time, pay attention to modify the owner, group and permissions of the log files to prevent inconsistent permissions.
# chown db2inst1:db2iadm1 S0003170.LOG
# chown db2inst1:db2iadm1 S0003171.LOG
# chown db2inst1:db2iadm1 S0003172.LOG
# chown db2inst1:db2iadm1 S0003173.LOG
# chown db2inst1:db2iadm1 S0003174.LOG
# chown db2inst1:db2iadm1 S0003175.LOG
# chown db2inst1:db2iadm1 S0003176.LOG
# chmod 744 S0003170.LOG
# chmod 744 S0003171.LOG
# chmod 744 S0003172.LOG
# chmod 744 S0003173.LOG
# chmod 744 S0003174.LOG
# chmod 744 S0003175.LOG
# chmod 744 S0003176.LOG
Use the following command to roll forward the log and stop the log overflow, note the "(" / home ")" format, which refers to the path where the log is located
$db2 rollforward db LAW to end of logs and stop overflow log path "(" / home ")"
Rollforward Status
Input database alias = LAW
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0003169.LOG-S0003176.LOG
Last committed transaction = 2013-01-14-21.04.00.000000
DB20000I The ROLLFORWARD command completed successfully.
Finally, connecting to the database, it is found that it has been successful and the data are consistent after checking.
$db2 connect to LAW
Database Connection Information
Database server = DB2/6000 9.1
SQL authorization ID = DB2INST1
Local database alias = LAW
It has been verified by developers and testers that everything is fine.
This is the end of the content of "how to use backup to achieve off-machine restore in DB2 database". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.