DB2資料庫的建庫備份和恢複,db2資料庫建庫

來源:互聯網
上載者:User

DB2資料庫的建庫備份和恢複,db2資料庫建庫

Db2環境下建庫步驟如下:

1. su – db2inst 注意 ‘-’少了後邊會出錯;

2. db2 進入db2命令列模式;

3. create database pb_db on /home/db2inst using codeset gbk territory zh_CN pagesize 8192   ---建庫;

4. connect to pb_db  ---串連;

5. create bufferpool testpool size 2000 pagesize 32k --暫存資料表空間緩衝池;

6. create temporary tablespace temp pagesize 32k managed by database using  (file   '\home\db2inst1\rdl\data' 5000) extentsize 80 bufferpool testpool --暫存資料表空間;

7. create bufferpool pbloop immediate size 1000 pagesize 32k  --使用者資料表空間緩衝池;

8. create regular tablespace pbxt pagesize 32k managed by database using (file '\home\db2inst1\rdl\data\user' 1024M) autoresize no extentsize 32 overhead 10.5 prefetchsize 32 transferrate  0.14 bufferpool pbloop --使用者資料表空間


Db2Database Backup步驟如下:

1. 確保沒有使用者使用DB2:

db2 list applications for db pb_db;

 

2. 停掉資料庫並重新啟動,以便斷掉所有串連:

db2stop force

db2start;

 

3. 執行備份命令:(使用TSM作為備份介質)

db2 backup db pb_db use tsm備份成功,將會返回一個時間戳記

db2 backup db pb_db to /home/db2inst1/rdl/data 在data檔案夾下備份資料庫產生一個001檔案

 

Db2資料庫恢複步驟如下:

1. 查看備忘記錄:

db2 list history backup all for pb_db;

 

2. 恢複某個時間點的資料:

db2 restore database pb_db from /home/db2inst1/rdl/data taken at 20140625141510

 

此時會有警告提示,填寫y就會恢複完成

 

 


相關文章

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.