"DB2" DB2 database restore, Backup

Source: Internet
Author: User
Tags db2 connect db2 connect to

Put the entire folder (jmam_dq.0) to D:\db_bak\
Start-run, enter Db2cmd:
1. Create a database
DB2 Create DB dbname on D:
(The database in the D disk, then the system will automatically add sql0000* directory, the result directory such as: D:\db2\node0000\sql0000*\ ...;
If the remote connection database is created, perform DB2 attach to Servernode user ... using ... before you perform the create. )

2. Restoring the database (re-pointing)
DB2 Restore DB JMAM_DQ from D:\db_bak\ taken in 20111226134239 into dbname redirect
3. Define the container path and table space, based on the path setting of the actual data creation
DB2 set tablespace containers for 0 using (path "d:\db2\node0000\sql0000*\sqlt0000.0")
DB2 set tablespace containers for 1 using (path "d:\db2\node0000\sql0000*\sqlt0001.0")
DB2 set tablespace containers for 2 using (path "d:\db2\node0000\sql0000*\sqlt0002.0")
DB2 set tablespace containers for 3 using (file "D:\db2\node0000\sql0000*\dbname. DBF "50000")--(can not, such as restore error added)
DB2 set tablespace containers for 4 using (file "d:\db2\node0000\sql0000*\dbname_temp.dbf" 12500)----(can be no, if the restore error is added)
DB2 Restore DB JMAM_DQ continue
4. Copying log files
After the last command succeeds, view the directory path, d:\db2\node0000\sql0000*\sqlogdir\, copy the log file in jmam_dq.0 to
In the destination folder. (If the path is not correct, you can view the "Newlogpath" entry by executing the DB2 get DB CFG for dbname, modifying the path: DB2 update DB CFG for sample using Newlogpath D:\DB2\NODE0 000\...\)
5. Finally roll back the database and complete the database restore
DB2 Rollforward DB dbname to end of logs and complete
Finish--------------

Other--------------------------
To back up the database:
DB2 Backup DB mam_32 online to D:\db_bak
Results such as: jmam_dq.0\db2\node0000\catn0000\20111226\134239.001
jmam_dq.0\db2\node0000\catn0000\**. LOG
Export Data File
Db2move <db name> Export [-sn < mode name, generally db2admin>] [-tn < table name, multiple separated by commas;]
Importing data files
Db2move <db name> Import
Other:
DB2 attach to Servernode user ... using: Connecting local Node instances
DB2 Drop DB dbname//delete database
DB2 Connect to dbname User username using password//connection database
DB2 Connect reset//exit the current connection database
DB2 get DB CFG for dbname//Get current database configuration information-can get the current database log file path
DB2 Set schema BTP modify the current mode to "BTP"
DB2 List tablespaces Show Detail view current database table space allocation status
DB2 list tablespace containers for 2 show Detail view tablespace id=2 using the directory where the container is located
DB2 List Application list connections
DB2 force application all disconnects database connection
DB2 List DB directory lists all databases
DB2 list Active databases lists all active databases
DB2 list tables for all lists all tables under the current database
DB2 list tables for schema BTP lists tables in the current database with schema BTP
DB2 List tablespaces show detail Show Database space usage
DB2 List packages for all
Db2start--Start the database
Db2stop--Stop the database
-------------------
--View Configuration
Get DB CFG for JS42GXR
--The statement heap is too small
Update DB CFG for sample using APP_CTL_HEAP_SZ 5120

--The maximum length of SQL text can be adjusted using the following statement:
Update DB CFG for sample using Stmtheap 20480
--but there is a possibility of running out of memory when there is too much data found in SQL
--You can use the following statement to adjust the memory size:
Update DB CFG for sample using Applheapsz 1024

DB2 Update DB CFG for dbtest using Logretain on– archived log mode, available for online backup
(Make sure the database connection is reset at this point)

DB2 "restore DB $db from $backdir without prompting"


DB2 using commands to catalog a remote database to a local

Test environment for this article: Windows 32-bit platform
DB2 V7 DB2 V8 version
1 Cataloging remote nodes:
DB2 catalog TCPIP node DB2CDB2 remote 10.81.XX. XX Server 50000
After success shows:
db20000i CATALOG TCPIP NODE command completed successfully.
db21056w directory changes will not take effect until the directory cache is refreshed.
2 Set the node for the catalog as the current node:
DB2 attach to DB2CDB2 user user_name using password
After success shows:
Instance connection information

Instance Server = Db2/nt 8.2.0
Authorization id = user_name
Local instance alias = Db2cdb2

3 Catalog Database:
DB2 Catalog DB db_name as Alias_name at NODE DB2CDB2
After success shows:
The db20000i CATALOG DATABASE command was successfully completed.
db21056w directory changes will not take effect until the directory cache is refreshed.

4 Testing the database connection:
DB2 Connect to Alias_name user user_name USING password
Successful display:
Database connection Information

Database Server = Db2/nt 8.2.0
SQL Authorization id = user_name
Local Database alias = Alias_name

"DB2" DB2 database restore, Backup

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.