DB2_PureScale备份与恢复是怎样的

发布时间:2021-11-30 10:36:36 作者:柒染
来源:亿速云 阅读:171

DB2_PureScale备份与恢复是怎样的,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

执行在线备份
db2 backup database sampledb online to /gpfs1nsd/backup include logs
db2 list history backup all for sampledb

数据库创建测试表,并插入数据
db2 "create table test1 (name varchar(32))"
db2 "insert into test1 values ('Jack')"

检查表空间状态
db2 list tablespaces | grep State

restore数据库
db2 list active databases
db2inst1@psnode1:/gpfs1nsd/backup>  db2 restore database sampledb from /gpfs1nsd/backup taken at 20170117141422
SQL2539W  The specified name of the backup image to restore is the same as the
name of the target database.  Restoring to an existing database that is the
same as the backup image database will cause the current database to be
overwritten by the backup version.
Do you want to continue ? (y/n) y
DB20000I  The RESTORE DATABASE command completed successfully.

数据库前滚
db2inst1@psnode1:/gpfs1nsd/backup> db2 rollforward db sampledb query status

                                Rollforward Status

Input database alias                   = sampledb
Number of members have returned status = 2

Member ID    Rollforward                 Next log             Log files processed        Last committed transaction
             status                      to be read
-----------  --------------------------  -------------------  -------------------------  --------------------------
          0  DB  pending                 S0000000.LOG                     -              2017-01-17-06.14.26.000000 UTC
          1  DB  pending                 S0000000.LOG                     -              2017-01-17-06.14.26.000000 UTC

db2inst1@psnode1:/gpfs1nsd/backup> db2 list utilities show detail
SQL1611W  No data was returned by Database System Monitor.  SQLSTATE=00000
db2inst1@psnode1:/gpfs1nsd/backup> db2 rollforward db sampledb to end of logs and stop

                                Rollforward Status

Input database alias                   = sampledb
Number of members have returned status = 2

Member ID    Rollforward                 Next log             Log files processed        Last committed transaction
             status                      to be read
-----------  --------------------------  -------------------  -------------------------  --------------------------
          0  not pending                                      S0000000.LOG-S0000000.LOG  2017-01-17-06.22.58.000000 UTC
          1  not pending                                                  -              2017-01-17-06.14.26.000000 UTC

DB20000I  The ROLLFORWARD command completed successfully.

或者指定前滚的时间点
db2inst1@psnode1:/gpfs1nsd/backup> db2 "rollforward database sampledb to  2017-01-17-14.14.26.000000 using local time and complete overflow log path ('/gpfs1nsd/backup')"

                                Rollforward Status

Input database alias                   = sampledb
Number of members have returned status = 2

Member ID    Rollforward                 Next log             Log files processed        Last committed transaction
             status                      to be read
-----------  --------------------------  -------------------  -------------------------  --------------------------
          0  not pending                                                  -              2017-01-17-14.14.26.000000 Local
          1  not pending                                                  -              2017-01-17-14.14.26.000000 Local

DB20000I  The ROLLFORWARD command completed successfully.


db2inst1@psnode1:/gpfs1nsd/backup> db2 rollforward db sampledb query status

                                Rollforward Status

Input database alias                   = sampledb
Number of members have returned status = 2

Member ID    Rollforward                 Next log             Log files processed        Last committed transaction
             status                      to be read
-----------  --------------------------  -------------------  -------------------------  --------------------------
          0  not pending                                      S0000000.LOG-S0000000.LOG  2017-01-17-06.22.58.000000 UTC
          1  not pending                                                  -              2017-01-17-06.14.26.000000 UTC

db2inst1@psnode1:/gpfs1nsd/backup>

查看测试表数据

###活动日志###
PureScale每个member成员有自己的活动日志文件,可以看到两个member的活动日志分别存放在LOGSTREAM0000和LOGSTREAM0001中;
db2inst1@psnode2:/gpfs1nsd/db2log/NODE0000/LOGSTREAM0001> cd /gpfs1nsd/db2log/NODE0000/
db2inst1@psnode2:/gpfs1nsd/db2log/NODE0000> ls -rlt
total 0
drwxr-x--- 4 db2inst1 db2grp 4096 Jan 17 14:42 LOGSTREAM0000
drwxr-x--- 2 db2inst1 db2grp 4096 Jan 17 14:42 LOGSTREAM0001


###归档日志###
PureScale每个member成员有自己的归档日志文件,可以看到两个member的归档日志分别存放在LOGSTREAM0000和LOGSTREAM0001中;
db2inst1@psnode2:/gpfs1nsd/db2arch/db2inst1/SAMPLEDB/NODE0000> ls -rlt
total 0
drwxr-x--- 5 db2inst1 db2grp 4096 Jan 17 14:40 LOGSTREAM0000
drwxr-x--- 5 db2inst1 db2grp 4096 Jan 17 14:42 LOGSTREAM0001



###两套Purescale数据库间进行重定向恢复###

备库执行
cd /db2sd_20170116165543/backup
db2 "restore database sampledb from /db2sd_20170116165543/backup into sampledb redirect generate script sampledb.clp without rolling forward"

编辑 ESBDBFE.clp
    (1)-- LOGTARGET '<directory>'为      LOGTARGET '/db2sd_20170116165543/backup'
    (2) -- DBPATH ON '<target-directory>' 改为DBPATH ON  '/db2sd_20170116165543/SAMPLEDB'
    (2)注释掉without rolling forward

创建目录
mkdir data1
mkdir data2
mkdir data3
mkdir data4
mkdir data5
mkdir data6
mkdir data7
mkdir data8
mkdir db2log
mkdir db2logmir
mkdir db2arch

设置DB路径
db2 attach to db2sdin1
db2 update dbm cfg using DFTDBPATH '/db2sd_20170116165543/SAMPLEDB'

执行restore命令
db2 terminate
db2 -tvf /db2sd_20170116165543/backup/sampledb.clp

查看数据库恢复状态
db2 list utilities show detail

查看前滚状态
db2 rollforward db sampledb query status

执行前滚操作
db2 "rollforward db sampledb to end of logs and stop overflow log path ('/db2sd_20170116165543/backup')"

关于DB2_PureScale备份与恢复是怎样的问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. mongodb 备份与恢复
  2. MongoDB备份与恢复

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

db2 purescale

上一篇:DB2搜集数据脚本怎样用于数据库hang或性能问题的分析

下一篇:C/C++ Qt TreeWidget单层树形组件怎么应用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》