db2 多分区数据库备份

编目分区:
Catalog database partition number = 0
这个就是编目分区。

//断掉所有的连接。
db2 force applications all


db2_all "<<+0<db2 backup database sample to d:\data compress"
db2_all "<<-0<db2 backup database sample to d:\data compress"

db2_all "<<+0< db2 restore db sample from d:\data taken at 20090212141538 replace existing "
db2_all "<<-0< db2 restore db sample from d:\data taken at 20090212141630 replace existing"

-----replace existing
If a database with the same alias as the target database alias already exists, this parameter specifies that the restore utility is to replace the existing database with the restored database. This is useful for scripts that invoke the restore utility, because the command line processor will not prompt the user to verify deletion of an existing database. If the WITHOUT PROMPTING parameter is specified, it is not necessary to specify REPLACE EXISTING, but in this case, the operation will fail if events occur that normally require user intervention.


为对分区数据库的所有分区进行备份操作,我们可利用 db2_all 的作用。在语句前加上 db2_all,并将语句引用在 "" 中,可令该语句在一个实例中的每个分区上被执行,而无需分别对每个分区重复发出相同的命令。BACKUP 便可通过这种方式实现对分区数据库的操作,但是对于编目分区例外。由于 DB2 在备份或恢复时要求独占编目分区,因此在对其它分区进行备份操作之前,首先必须先完成该分区的备份操作。

另外,在 db2_all 之后的 "" 语句中,我们还可以以下述方式作开头,以指定命令所作用的分区:

<<+分区号< :表示后续命令作用于该分区。
<<-分区号< :表示后续命令作用于除该分区之外的其它分区。
||<<-分区号< 或 <<-分区号; :表示后续命令作用于除该分区之外的其它分区,
并且是以并行方式进行的。

综上所述,对于分区数据库的数据进行备份操作的命令为(以编目分区号为 0 举例):

1. 无需并行操作的方式:

当备份操作不需要使用并行方式时,则不存在先对编目分区进行操作的问题,此时可通过一条命令实现备份操作。

db2_all "db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>"

2. 使用并行操作的方式:

db2_all "<<+0< db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>" (windows下)
db2_all "||<<-0< db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>"

db2_all "<<-0<; db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>"

即首先对编目分区 - 0 号分区进行备份操作,然后再对除编目分区之外的其它分区同时并行操作,以缩短操作的时间,这一点体现了分区数据库的优越性。


db2 force applications all
db2_all "<<+0<db2 connect to churndb;db2 backup database churndb to /db2log/db2buckup compress;db2 terminate"
db2_all "<<-0<db2 connect to churndb;db2 backup database churndb to /db2log/db2buckup compress;db2 terminate"

linux下这么写
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值