DB2数据库的备份测试--备份环境变量配置

1、 /tmp目录下创建 /tmp/db2inst1/sample/下创建以下目录:

archivelog : 用来存放第一条归档路径;

archivelog1:用于存放第二条归档路径;

mirrorlog 用于存放镜像联机日志;

on_back:存放在线热备份集;

off_abck:存放冷备份集;

[db2inst1@db2 ~]$ cd /tmp

[db2inst1@db2 tmp]$ mkdir db2inst1

[db2inst1@db2 tmp]$ cd db2inst1

[db2inst1@db2 db2inst1]$ ls

[db2inst1@db2 db2inst1]$ mkdir sample

[db2inst1@db2 db2inst1]$ cd sample

[db2inst1@db2 sample]$ mkdir mirrorlog

[db2inst1@db2 sample]$ mkdir archivelog

[db2inst1@db2 sample]$ mkdir archivelog1

[db2inst1@db2 sample]$ mkdir on_back

[db2inst1@db2 sample]$ mkdir off_back

 

2、 创建toolsdb实现备份调度

 

[root@db2 instance]# su - db2inst1

[db2inst1@db2 ~]$ db2 create tools catalog systools create new db toolsdb

DB20000I  The CREATE TOOLS CATALOG command completed successfully.

 

3、 开归档日志

[db2inst1@db2 sample]$ db2 update db cfg for sample using logretain on

DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

SQL1363W One or more of the parameters submitted for immediate modification

were not changed dynamically. For these configuration parameters, all

applications must disconnect from this database before the changes become

effective.

 

3.1、重新启动使之生效

    [db2inst1@db2 sample]$ db2stop force

09/17/2009 04:29:01     0   0   SQL1064N  DB2STOP processing was successful.

SQL1064N  DB2STOP processing was successful.

[db2inst1@db2 sample]$ db2start

09/17/2009 04:29:08     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.

 

FAQ

如果继续配置参数,会报如下错误,由于数据库无法被打开:

[db2inst1@db2 /]$ db2 update db cfg for sample using trackmod on

SQL1224N  The database manager is not able to accept new requests, has

terminated all requests in progress, or has terminated your particular request

due to a problem with your request.  SQLSTATE=55032

 

进入数据库,会出现如下报错:

db2 => connect to sample

SQL1116N  A connection to or activation of database "SAMPLE" cannot be made

because of BACKUP PENDING.  SQLSTATE=57019

 

解决办法:

数据库修改参数后,需要进行一次全备份,因此进行全备份就可以了。

[db2inst1@db2 /]$ cd /home/db2inst1

[db2inst1@db2 ~]$ ls

db2inst1  sqllib

[db2inst1@db2 ~]$ mkdir off_back

 

[db2inst1@db2 ~]$ db2 backup db sample to /home/db2inst1/off_back

 

  Backup successful. The timestamp for this backup image is : 20090917043704

 

   [db2inst1@db2 ~]$ db2 connect to sample

 

       Database Connection Information

 

     Database server        = DB2/LINUX 9.1.3

     SQL authorization ID   = DB2INST1

     Local database alias   = SAMPLE

 

4、 镜像日志:

[db2inst1@db2 mirrorlog]$ db2 update db cfg for sample using mirrorlogpath /tmp/db2inst1/sample/mirrorlog/

DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

SQL1363W One or more of the parameters submitted for immediate modification

were not changed dynamically. For these configuration parameters, all

applications must disconnect from this database before the changes become

effective.

 

5、 打开增量备份

  [db2inst1@db2 mirrorlog]$ db2 update db cfg for sample using trackmod on

DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

SQL1363W One or more of the parameters submitted for immediate modification

were not changed dynamically. For these configuration parameters, all

applications must disconnect from this database before the changes become

effective.

 

6、 指定第一条归档路径:

  [db2inst1@db2 archivelog1]$ db2 update db cfg for sample using logarchmeth1 disk:/tmp/db2inst1/sample/archivelog/

DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

FAQ:当归档路径配置后,需要重启数据库才能做第二个归档路径,否则会报错:

    [db2inst1@db2 archivelog]$ db2 update db cfg for sample using logarchmeth2 disk:/tmp/db2inst1/archivelog1/

SQL5099N  The value "/tmp/db2inst1/archivelog1/" indicated by the database

configuration parameter "LOGARCHMETH2" is not valid, reason code "2". 

SQLSTATE=08004

解决办法:重启数据库

[db2inst1@db2 archivelog]$ db2stop force

09/17/2009 04:47:34     0   0   SQL1064N  DB2STOP processing was successful.

SQL1064N  DB2STOP processing was successful.

[db2inst1@db2 archivelog]$ db2start

09/17/2009 04:47:40     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.

 

7、 指定第二条归档路径

   [db2inst1@db2 archivelog]$ db2 update db cfg for sample using logarchmeth2 disk:/tmp/db2inst1/sample/archivelog1/

DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

 

8、 察看最终配置

    [db2inst1@db2 sample]$ db2 get db cfg for sample

      ...............

    

Path to log files                                       = /home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/

 Overflow log path                     (OVERFLOWLOGPATH) =

 Mirror log path                         (MIRRORLOGPATH) = /tmp/db2inst1/sample/mirrorlog/NODE0000/

 First active log file                                   = S0000000.LOG

 

 First log archive method                 (LOGARCHMETH1) = DISK:/tmp/db2inst1/sample/archivelog/

 Options for logarchmeth1                  (LOGARCHOPT1) =

 Second log archive method                (LOGARCHMETH2) = DISK:/tmp/db2inst1/sample/archivelog1/

 

 

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8334342/viewspace-616032/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8334342/viewspace-616032/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值