db2设置归档模式

环境:

Os:Centos 7

DB:V11.5.6

1.查看数据库是否处于归档模式

[db2inst1@host135 SQL00001]$ db2 get db cfg for db_hxl|grep LOGARCH
 First log archive method                 (LOGARCHMETH1) = OFF
 Archive compression for logarchmeth1    (LOGARCHCOMPR1) = OFF
 Options for logarchmeth1                  (LOGARCHOPT1) = 
 Second log archive method                (LOGARCHMETH2) = OFF
 Archive compression for logarchmeth2    (LOGARCHCOMPR2) = OFF
 Options for logarchmeth2                  (LOGARCHOPT2) = 

 

2.创建归档目录

[root@host135 tmp]# su - db2inst1
[db2inst1@host135 ~]$ mkdir arch
[db2inst1@host135 arch]$ pwd
/home/db2inst1/arch

 

3.为数据库设置归档

[db2inst1@host135 arch]$db2 update db cfg for db_hxl using LOGARCHMETH1 "disk:/home/db2inst1/arch" ##单独某个库归档

 

4.重启
[db2inst1@host135 arch]$db2stop force
[db2inst1@host135 arch]$db2start

 

5.需要进行备份

db2 => connect to db_hxl
SQL1116N  A connection to or activation of database "DB_HXL" failed because the database is in BACKUP PENDING state.  SQLSTATE=57019


[db2inst1@host135 backup]$ db2 backup database db_hxl to /home/db2inst1/backup/

再次链接
db2 => connect to db_hxl

   Database Connection Information

 Database server        = DB2/LINUXX8664 11.5.6.0
 SQL authorization ID   = DB2INST1
 Local database alias   = DB_HXL

 

6.手工归档

[db2inst1@host135 LOGSTREAM0000]$ db2 archive log for db db_hxl
DB20000I The ARCHIVE LOG command completed successfully.

 

7.新创建数据库查看是否会归档
[db2inst1@host135 C0000000]$ db2
db2 create db db_hxl01 using codeset utf-8 territory CN

 

发现新建的库不会启用归档的

 

[db2inst1@host135 backup]$ db2 get db cfg for db_hxl01|grep LOGARCH
 First log archive method                 (LOGARCHMETH1) = OFF
 Archive compression for logarchmeth1    (LOGARCHCOMPR1) = OFF
 Options for logarchmeth1                  (LOGARCHOPT1) = 
 Second log archive method                (LOGARCHMETH2) = OFF
 Archive compression for logarchmeth2    (LOGARCHCOMPR2) = OFF
 Options for logarchmeth2  

 

需要手工设置归档
[db2inst1@host135 arch]$db2 update db cfg for db_hxl01 using LOGARCHMETH1 "disk:/home/db2inst1/arch"

 

posted @ 2024-01-25 09:59  slnngk  阅读(155)  评论(0编辑  收藏  举报