DB2

56次阅读
没有评论

共计 4880 个字符,预计需要花费 13 分钟才能阅读完成。

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 备份与恢复是怎样的问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注丸趣 TV 行业资讯频道了解更多相关知识。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-17发表,共计4880字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)