DB2備份恢複範例

來源:互聯網
上載者:User

以下CMDB 為db2資料庫名;此文經過測試環境驗證過。

1、 線上備份資料庫

不包含歸檔:
db2 backup db cmdb online to [路徑名]

包含歸檔:
db2 backup db cmdb online to [路徑名] include logs

2、 離線備份資料庫

db2 backup db cmdb to [路徑名]

3、 資料庫異機恢複(備份源為離線備份)
db2 "restore db cmdb from [路徑名] replace existing without rolling forward"
4、 資料庫異機恢複(備份源為線上備份)

利用on PATH redirect來重定位資料表空間路徑:
db2 “restore db cmdb from [路徑名] on [路徑名] logtarget /tmp replace existing redirect”
 
查看錶空間,修改沒有重新導向的資料表空間和資料檔案:
db2pd -db cmdb -tablespace

db2 “set tablespace containers for 3 using
  (Path ‘/db2sys/db2inst1/NODE0000/CMDB/USERSPACE2’)”

db2 “set tablespace containers for 5 using
  (File ‘/db2sys/db2inst1/NODE0000/CMDB/CMSEXT001.LRG’ 32736,File ‘/db2sys/db2inst1/NODE0000/CMDB/CMSEXT002.LRG’ 32736)”
 
開始恢複:
db2 restore db cmdb continue


恢複歸檔日誌:
db2 "rollforward db cmdb to end of logs and stop overflow log path (/tmp/logs)"

相關文章

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.