DB2备份还原
来源:互联网 发布:无硅油洗发水品牌知乎 编辑:程序博客网 时间:2024/05/16 00:41
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://zhuyan.blog.51cto.com/890880/189112
************创建存放归档日志和备份的目录****************
[root@yan ~]# su - db2inst1
[db2inst1@yan ~]$ mkdir archivelog
[db2inst1@yan ~]$ mkdir log
[db2inst1@yan ~]$ mkdir backup
************创建测试数据库和测试表***************************
db2 => create db yan
db2 => connect to yan
db2 => create table test (id int,name varchar(20),password varchar(20))
db2 => insert into test values (1,'zhu','yan')
************修改db2参数**************************************
db2 => update db cfg for yan using mirrorlogpath /home/db2inst1/archivelog--启用mirror log
db2 => update db cfg for yan using mirrorlogpath /home/db2inst1/archivelog--启用mirror log
db2 => update db cfg for yan using userexit on --启用用户出口
db2 => update db cfg for yan using logretain on --启用归档日志
db2 => update db cfg for yan using trackmod on --启用增量备份功能
db2 => backup db yan to /home/db2inst1/backup 这时数据库处于挂起状态,需要对数据库备份一次,否则不能用
Backup successful. The timestamp for this backup image is : 20090807082755
###############开始备份和还原###############################
***************冷备份和还原*********************************
db2 => backup db yan to /home/db2inst1/backup
Backup successful. The timestamp for this backup image is : 20090807083306
db2 => insert into test values (2,'hui','hui')
[db2inst1@yan ~]$ cp archivelog/NODE0000/* log --将归档日志拷贝走
db2 => drop db yan --手动删除数据库,模拟灾备
db2 => restore db yan from /home/db2inst1/backup taken at 20090807083306--恢复数据库
DB20000I The RESTORE DATABASE command completed successfully.
DB20000I The RESTORE DATABASE command completed successfully.
db2 => rollforward db yan to end of logs and complete overflow log path (/home/db2inst1/log)--前滚日志
Rollforward Status
Input database alias = yan
Number of nodes have returned status = 1
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000000.LOG - S0000000.LOG
Last committed transaction = 2009-08-07-12.34.41.000000 UTC
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000000.LOG - S0000000.LOG
Last committed transaction = 2009-08-07-12.34.41.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
db2 => select *from test --能查出test表中的所有数据证明成功了
*****************热备份和还原*********************************
db2 => insert into test values (3,'java','db') --插入测试数据
db2 => backup db yan online to /home/db2inst1/backup --热备
Backup successful. The timestamp for this backup image is : 20090807084334
db2 => insert into test values (4,'db2','jsp') --插入测试数据
[db2inst1@yan ~]$ cp -rf archivelog/NODE0000/* log --拷贝日志
db2 => drop db yan --手动删除数据库,模拟灾备
DB20000I The DROP DATABASE command completed successfully.
DB20000I The DROP DATABASE command completed successfully.
db2 => restore db yan from /home/db2inst1/backup taken at 20090807084334--恢复数据库
DB20000I The RESTORE DATABASE command completed successfully.
DB20000I The RESTORE DATABASE command completed successfully.
db2 => rollforward db yan to end of logs and complete overflow log path (/home/db2inst1/log)--前滚日志
Rollforward Status
Input database alias = yan
Number of nodes have returned status = 1
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000002.LOG - S0000002.LOG
Last committed transaction = 2009-08-07-12.43.35.000000 UTC
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000002.LOG - S0000002.LOG
Last committed transaction = 2009-08-07-12.43.35.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
db2 => select *from test --能查出所有的测试数据证明成功了
***************增量备份和还原********************************
db2 => insert into test values (5,'oracle','mysql') --插入测试数据
db2 => backup db yan online incremental to /home/db2inst1/backup --备份数据库
Backup successful. The timestamp for this backup image is : 20090807085501
[db2inst1@yan ~]$ cp -rf archivelog/NODE0000/* log --拷贝日志
db2 => drop db yan --手动删除数据库,模拟灾备
DB20000I The DROP DATABASE command completed successfully.
DB20000I The DROP DATABASE command completed successfully.
db2 => restore db yan incremental automatic from /home/db2inst1/backup taken at 20090807085501
DB20000I The RESTORE DATABASE command completed successfully. --恢复数据库
DB20000I The RESTORE DATABASE command completed successfully. --恢复数据库
db2 => rollforward db yan to end of logs and complete overflow log path (/home/db2inst1/log)
Rollforward Status
Input database alias = yan
Number of nodes have returned status = 1
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000004.LOG - S0000004.LOG
Last committed transaction = 2009-08-07-12.55.01.000000 UTC
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000004.LOG - S0000004.LOG
Last committed transaction = 2009-08-07-12.55.01.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
db2 => select *from test --能查出所有的测试数据证明成功了
本文出自 “zhuyan” 博客,请务必保留此出处http://zhuyan.blog.51cto.com/890880/189112
- 还原DB2备份
- DB2备份还原
- db2备份还原数据库
- DB2数据库备份还原
- db2备份、还原
- db2备份还原
- db2 数据库的备份还原
- DB2数据库备份与还原
- DB2 数据库备份还原 08
- db2的备份和还原
- DB2数据库的备份与还原
- DB2数据库的备份与还原
- DB2 数据库的备份与还原
- DB2 V9.5 备份还原增强特性,第1部分
- Linux下DB2数据库的备份及还原
- DB2 在线增量备份数据库、还原增量备份数据库、前滚恢复数据库脚本
- DB2在线增量备份 还原增量备份及前滚恢复
- DB2 在线增量备份数据库、还原增量备份数据库、前滚恢复数据库脚本
- C#中的Main(String[] args)的意思
- 查找高亮
- Oracle边导出边压缩方法
- Android_001_搭建开发环境_NetBeans
- 给C#程序添加说明——注释
- DB2备份还原
- 【观点】创业编程七个错误认识
- PE,PB 动态PE,PB
- Android_002_第一个简单的程序
- winform 制作安装程序,及程序的升级
- 创建一个控制台应用程序
- 十八个绝招把你从压力中营救出来
- 自我激励的方法
- 对话框修改名称(重命名)