DB2資料庫的備份測試--備份環境變數配置
1、 在/tmp目錄下建立 /tmp/db2inst1/sample/下建立以下目錄:
archivelog : 用來存放第一條歸檔路徑;
archivelog1:用於存放第二條歸檔路徑;
mirrorlog: 用於存放映象聯機日誌;
on_back:存放線上熱備份集;
off_abck:存放冷備份集;
[db2inst1@db2 ~]$ cd /tmp
[db2inst1@db2 tmp]$ mkdir db2inst1
[db2inst1@db2 tmp]$ cd db2inst1
[db2inst1@db2 db2inst1]$ ls
[db2inst1@db2 db2inst1]$ mkdir sample
[db2inst1@db2 db2inst1]$ cd sample
[db2inst1@db2 sample]$ mkdir mirrorlog
[db2inst1@db2 sample]$ mkdir archivelog
[db2inst1@db2 sample]$ mkdir archivelog1
[db2inst1@db2 sample]$ mkdir on_back
[db2inst1@db2 sample]$ mkdir off_back
2、 建立toolsdb實現備份排程
[root@db2 instance]# su - db2inst1
[db2inst1@db2 ~]$ db2 create tools catalog systools create new db toolsdb
DB20000I The CREATE TOOLS CATALOG command completed successfully.
3、 開歸檔日誌
[db2inst1@db2 sample]$ db2 update db cfg for sample using logretain on
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W One or more of the parameters submitted for immediate modification
were not changed dynamically. For these configuration parameters, all
applications must disconnect from this database before the changes become
effective.
3.1、重新啟動使之生效
[db2inst1@db2 sample]$ db2stop force
09/17/2009 04:29:01 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
[db2inst1@db2 sample]$ db2start
09/17/2009 04:29:08 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
FAQ:
如果繼續配置引數,會報如下錯誤,由於資料庫無法被開啟:
[db2inst1@db2 /]$ db2 update db cfg for sample using trackmod on
SQL1224N The database manager is not able to accept new requests, has
terminated all requests in progress, or has terminated your particular request
due to a problem with your request. SQLSTATE=55032
進入資料庫,會出現如下報錯:
db2 => connect to sample
SQL1116N A connection to or activation of database "SAMPLE" cannot be made
because of BACKUP PENDING. SQLSTATE=57019
解決辦法:
資料庫修改引數後,需要進行一次全備份,因此進行全備份就可以了。
[db2inst1@db2 /]$ cd /home/db2inst1
[db2inst1@db2 ~]$ ls
db2inst1 sqllib
[db2inst1@db2 ~]$ mkdir off_back
[db2inst1@db2 ~]$ db2 backup db sample to /home/db2inst1/off_back
Backup successful. The timestamp for this backup image is : 20090917043704
[db2inst1@db2 ~]$ db2 connect to sample
Database Connection Information
Database server = DB2/LINUX 9.1.3
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
4、 映象日誌:
[db2inst1@db2 mirrorlog]$ db2 update db cfg for sample using mirrorlogpath /tmp/db2inst1/sample/mirrorlog/
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W One or more of the parameters submitted for immediate modification
were not changed dynamically. For these configuration parameters, all
applications must disconnect from this database before the changes become
effective.
5、 開啟增量備份
[db2inst1@db2 mirrorlog]$ db2 update db cfg for sample using trackmod on
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W One or more of the parameters submitted for immediate modification
were not changed dynamically. For these configuration parameters, all
applications must disconnect from this database before the changes become
effective.
6、 指定第一條歸檔路徑:
[db2inst1@db2 archivelog1]$ db2 update db cfg for sample using logarchmeth1 disk:/tmp/db2inst1/sample/archivelog/
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
FAQ:當歸檔路徑配置後,需要重啟資料庫才能做第二個歸檔路徑,否則會報錯:
[db2inst1@db2 archivelog]$ db2 update db cfg for sample using logarchmeth2 disk:/tmp/db2inst1/archivelog1/
SQL5099N The value "/tmp/db2inst1/archivelog1/" indicated by the database
configuration parameter "LOGARCHMETH2" is not valid, reason code "2".
SQLSTATE=08004
解決辦法:重啟資料庫
[db2inst1@db2 archivelog]$ db2stop force
09/17/2009 04:47:34 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
[db2inst1@db2 archivelog]$ db2start
09/17/2009 04:47:40 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
7、 指定第二條歸檔路徑
[db2inst1@db2 archivelog]$ db2 update db cfg for sample using logarchmeth2 disk:/tmp/db2inst1/sample/archivelog1/
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
8、 察看最終配置
[db2inst1@db2 sample]$ db2 get db cfg for sample
...............
Path to log files = /home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/
Overflow log path (OVERFLOWLOGPATH) =
Mirror log path (MIRRORLOGPATH) = /tmp/db2inst1/sample/mirrorlog/NODE0000/
First active log file = S0000000.LOG
First log archive method (LOGARCHMETH1) = DISK:/tmp/db2inst1/sample/archivelog/
Options for logarchmeth1 (LOGARCHOPT1) =
Second log archive method (LOGARCHMETH2) = DISK:/tmp/db2inst1/sample/archivelog1/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8334342/viewspace-616032/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DB2資料庫的備份測試--開始備份DB2資料庫
- RMAN備份恢復——RAC環境資料庫的備份(zt)資料庫
- RMAN備份恢復--RAC環境資料庫的備份(十)資料庫
- RMAN備份恢復——RAC環境資料庫的備份(一)資料庫
- DB2資料庫的備份測試--開始恢復DB2資料庫
- RAC環境的STANDBY資料庫備份報錯資料庫
- DB2備份恢復測試DB2
- 成功恢復無備份RAC環境資料庫資料庫
- mysql資料庫xtrabackup壓縮備份測試MySql資料庫
- 楊廷琨大師總結:RMAN備份恢復--RAC環境資料庫的備份資料庫
- 配置xtrabackup備份mysql資料庫MySql資料庫
- 2 Day DBA-管理方案物件-執行備份和恢復-備份資料庫-驗證備份並測試你的備份策略物件資料庫
- DB2的資料庫備份與恢復DB2資料庫
- DB2資料庫的備份和恢復DB2資料庫
- db2備份和恢復資料庫DB2資料庫
- 【RAC】rac環境下的資料庫備份與還原資料庫
- RAC環境利用備份恢復RAC資料庫(五)資料庫
- RAC環境利用備份恢復RAC資料庫(四)資料庫
- RAC環境利用備份恢復RAC資料庫(三)資料庫
- RAC環境利用備份恢復RAC資料庫(二)資料庫
- RAC環境利用備份恢復RAC資料庫(一)資料庫
- Oracle資料庫的備份方法-冷備份(轉)Oracle資料庫
- 資料庫備份資料庫
- oracle資料庫備份之exp增量備份Oracle資料庫
- DB2資料庫自動備份方法TRDB2資料庫
- Mysql5.7在CentOs環境下定時備份資料庫MySqlCentOS資料庫
- Linux環境下資料庫自動邏輯備份Linux資料庫
- 【備份恢復】從備份恢復資料庫資料庫
- 【RMAN】使用增量備份更新資料庫備份映象資料庫
- Oracle學習系列—資料庫備份—熱備份Oracle資料庫
- mysql 資料庫 備份MySql資料庫
- 資料庫備份策略資料庫
- MongoDB資料庫備份MongoDB資料庫
- mysql 資料庫備份MySql資料庫
- 資料庫備份方案資料庫
- 數棧資料安全案例:混合雲環境資料庫備份容災實現資料庫
- Dedecms備份的資料檔案位置及備份資料庫的方法資料庫
- 資料備份≠容災備份