DB2在线备份恢复
2013-11-20 17:16
274 查看
DB2在线备份恢复:
1.查看数据库:
[db2inst1@localhost ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = PAYMENT2
Database name = PAYMENT2
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = SAMPLE
Database name = SAMPLE
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
2.删除数据库:(模拟灾难)
[db2inst1@localhost ~]$ db2 drop db payment2
DB20000I The DROP DATABASE command completed successfully.
[db2inst1@localhost ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
3.找到备份的数据
[db2inst1@localhost ~]$ cd /home/db2inst1/payment2_bak
[db2inst1@localhost payment2_bak]$ ls
PAYMENT2.0.db2inst1.DBPART000.20130514083706.001 PAYMENT2.0.db2inst1.DBPART000.20130514090118.001
PAYMENT2.0.db2inst1.DBPART000.20130514085824.001
[db2inst1@localhost payment2_bak]$ ll
总用量 475104
-rw-------. 1 db2inst1 db2iadm1 161419264 5月 14 08:37 PAYMENT2.0.db2inst1.DBPART000.20130514083706.001
-rw-------. 1 db2inst1 db2iadm1 165355520 5月 14 08:58 PAYMENT2.0.db2inst1.DBPART000.20130514085824.001
-rw-------. 1 db2inst1 db2iadm1 159727616 5月 14 09:01 PAYMENT2.0.db2inst1.DBPART000.20130514090118.001
4.备份恢复命令
[db2inst1@localhost payment2_bak]$ db2 restore database payment2 from /home/db2inst1/payment2_bak taken at 20130514085824
DB20000I The RESTORE DATABASE command completed successfully.
5.查看数据库是否恢复:
[db2inst1@localhost payment2_bak]$ db2 list db directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = PAYMENT2
Database name = PAYMENT2
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = SAMPLE
Database name = SAMPLE
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
6.尝试连接数据库:
由于是在归档模式下,数据库恢复后,处于 ROLL-FORWARD PENDING 状态,所以不能连接
[db2inst1@localhost payment2_bak]$ db2 connect to payment2
SQL1117N A connection to or activation of database "PAYMENT2" cannot be made
because of ROLL-FORWARD PENDING. SQLSTATE=57019
7.前滚数据库,使之可用
[db2inst1@localhost ~]$ db2 "ROLLFORWARD DATABASE payment2 TO END OF LOGS AND COMPLETE OVERFLOW LOG PATH ("/home/db2inst1/payment2_archive_log/")"
Rollforward Status
Input database alias = payment2
Number of members have returned status = 1
Member ID = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000002.LOG - S0000003.LOG
Last committed transaction = 2013-05-14-01.01.28.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
[db2inst1@localhost ~]$ db2 connect to payment2
Database Connection Information
Database server = DB2/LINUX 10.1.2
SQL authorization ID = DB2INST1
Local database alias = PAYMENT2
[db2inst1@localhost ~]$ db2 list tables
1.查看数据库:
[db2inst1@localhost ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = PAYMENT2
Database name = PAYMENT2
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = SAMPLE
Database name = SAMPLE
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
2.删除数据库:(模拟灾难)
[db2inst1@localhost ~]$ db2 drop db payment2
DB20000I The DROP DATABASE command completed successfully.
[db2inst1@localhost ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
3.找到备份的数据
[db2inst1@localhost ~]$ cd /home/db2inst1/payment2_bak
[db2inst1@localhost payment2_bak]$ ls
PAYMENT2.0.db2inst1.DBPART000.20130514083706.001 PAYMENT2.0.db2inst1.DBPART000.20130514090118.001
PAYMENT2.0.db2inst1.DBPART000.20130514085824.001
[db2inst1@localhost payment2_bak]$ ll
总用量 475104
-rw-------. 1 db2inst1 db2iadm1 161419264 5月 14 08:37 PAYMENT2.0.db2inst1.DBPART000.20130514083706.001
-rw-------. 1 db2inst1 db2iadm1 165355520 5月 14 08:58 PAYMENT2.0.db2inst1.DBPART000.20130514085824.001
-rw-------. 1 db2inst1 db2iadm1 159727616 5月 14 09:01 PAYMENT2.0.db2inst1.DBPART000.20130514090118.001
4.备份恢复命令
[db2inst1@localhost payment2_bak]$ db2 restore database payment2 from /home/db2inst1/payment2_bak taken at 20130514085824
DB20000I The RESTORE DATABASE command completed successfully.
5.查看数据库是否恢复:
[db2inst1@localhost payment2_bak]$ db2 list db directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = PAYMENT2
Database name = PAYMENT2
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = SAMPLE
Database name = SAMPLE
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
6.尝试连接数据库:
由于是在归档模式下,数据库恢复后,处于 ROLL-FORWARD PENDING 状态,所以不能连接
[db2inst1@localhost payment2_bak]$ db2 connect to payment2
SQL1117N A connection to or activation of database "PAYMENT2" cannot be made
because of ROLL-FORWARD PENDING. SQLSTATE=57019
7.前滚数据库,使之可用
[db2inst1@localhost ~]$ db2 "ROLLFORWARD DATABASE payment2 TO END OF LOGS AND COMPLETE OVERFLOW LOG PATH ("/home/db2inst1/payment2_archive_log/")"
Rollforward Status
Input database alias = payment2
Number of members have returned status = 1
Member ID = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000002.LOG - S0000003.LOG
Last committed transaction = 2013-05-14-01.01.28.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
[db2inst1@localhost ~]$ db2 connect to payment2
Database Connection Information
Database server = DB2/LINUX 10.1.2
SQL authorization ID = DB2INST1
Local database alias = PAYMENT2
[db2inst1@localhost ~]$ db2 list tables
相关文章推荐
- db2在线备份,没有日志,如何恢复
- DB2在线增量备份 还原增量备份及前滚恢复
- DB2离线和在线全备、增量备份及恢复的操作步骤
- DB2 在线增量备份数据库、还原增量备份数据库、前滚恢复数据库脚本
- DB2 pureScale在线备份恢复实例1
- DB2在线备份的恢复
- DB2在线增量备份 恢复增量备份及前滚恢复
- IBM DB2 UDB 在线备份及恢复实战
- DB2 在线增量备份数据库、还原增量备份数据库、前滚恢复数据库脚本
- DB2 数据库在线备份和恢复的操作步骤
- DB2使用在线备份和日志恢复到指定时间
- mysql之使用xtrabackup进行物理备份、恢复、在线克隆从库、在线重做主从
- innobackupex在线备份及恢复(全量和增量)
- 一个PHP在线备份和恢复MySQL数据库的类
- innobackupex在线备份及恢复(全量和增量)
- DB2离线备份与恢复
- DB2数据备份和恢复
- DB2的备份和恢复
- DB2离线和在线全备、增量备份及恢复的操作步骤
- IBM DB2 V8.2 数据库的备份以及恢复