1、修改日志组数目
[db2inst1@DB2test183 ~]$ db2 update db cfg using LOGPRIMARY 5
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, the database
must be shutdown and reactivated before the configuration parameter changes
become effective.
[db2inst1@DB2test183 ~]$ ls -l /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
total 12312
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000000.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000001.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000002.LOG
[db2inst1@DB2test183 ~]$ db2 restart db aaa
DB20000I The RESTART DATABASE command completed successfully.
[db2inst1@DB2test183 ~]$
[db2inst1@DB2test183 ~]$
[db2inst1@DB2test183 ~]$ ls -l /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
total 20532
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000000.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000001.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000002.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000003.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 06:45 S0000004.LOG
[db2inst1@DB2test183 ~]$
小知识:
get db/dbm cfg 中的 show detail 选项可以看出参数值是否已经生效
[db2inst1@DB2test183 ~]$ db2 update db cfg using LOGPRIMARY 6
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, the database
must be shutdown and reactivated before the configuration parameter changes
become effective.
[db2inst1@DB2test183 ~]$ db2 get db cfg for aaa show detail|grep -i primary
Number of primary log files (LOGPRIMARY) = 5 6 (前面的是修改之前的原始值,后面的数字是修改之后的值,目前还未生效。简言之,前后数值不一致即说明参数更改未生效)
Percent max primary log space by transaction (MAX_LOG) = 0 0
[db2inst1@DB2test183 ~]$ db2 get db cfg for aaa |grep -i primary
Number of primary log files (LOGPRIMARY) = 6
Percent max primary log space by transaction (MAX_LOG) = 0
[db2inst1@DB2test183 ~]$
[db2inst1@DB2test183 ~]$
[db2inst1@DB2test183 ~]$ db2 restart db aaa
DB20000I The RESTART DATABASE command completed successfully.
[db2inst1@DB2test183 ~]$
[db2inst1@DB2test183 ~]$
[db2inst1@DB2test183 ~]$ db2 get db cfg for aaa |grep -i primary
Number of primary log files (LOGPRIMARY) = 6
Percent max primary log space by transaction (MAX_LOG) = 0
2、修改数据库归档模式
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa |grep -i logarchmeth1
First log archive method (LOGARCHMETH1) = OFF
Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF
Options for logarchmeth1 (LOGARCHOPT1) =
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ db2 update db cfg using LOGARCHMETH1 disk:/home/db2inst1/archivelog/aa
SQL5099N The value "/home/db2inst1/archivelog/aa" indicated by the database
configuration parameter "LOGARCHMETH1" is not valid, reason code "2".
SQLSTATE=08004
[db2inst1@DB2test183 aaa]$ db2 update db cfg for aaa using LOGARCHMETH1 disk:/home/db2inst1/archivelog/aaa
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, the database
must be shutdown and reactivated before the configuration parameter changes
become effective.
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa |grep -i logarchmeth1
First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/archivelog/aaa/
Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF
Options for logarchmeth1 (LOGARCHOPT1) =
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail |grep -i logarchmeth1
First log archive method (LOGARCHMETH1) = OFF DISK:/home/db2inst1/archivelog/aaa/
Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF OFF
Options for logarchmeth1 (LOGARCHOPT1) =
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ db2 archive log for aaa
SQL0104N An unexpected token "aaa" was found following "FOR". Expected
tokens may include: "DATABASE". SQLSTATE=42601
[db2inst1@DB2test183 aaa]$ db2 archive log databae aaa
SQL0104N An unexpected token "databae" was found following "LOG". Expected
tokens may include: "FOR". SQLSTATE=42601
[db2inst1@DB2test183 aaa]$ db2 archive log databae for aaa
SQL0104N An unexpected token "databae" was found following "LOG". Expected
tokens may include: "FOR". SQLSTATE=42601
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ db2 restart db aaa
SQL1116N A connection to or activation of database "AAA" failed because the
database is in BACKUP PENDING state. SQLSTATE=57019
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail |grep -i logarchmeth1
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail |grep -i logarchmeth1
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa |grep -i logarchmeth1
First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/archivelog/aaa/
Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF
Options for logarchmeth1 (LOGARCHOPT1) =
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail |grep -i logarchmeth1
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail |grep -i pri
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail |grep -i log
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail|grep -i primary
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa |grep -i log
Log retain for recovery status = NO
User exit for logging status = YES
Catalog cache size (4KB) (CATALOGCACHE_SZ) = 300
Log buffer size (4KB) (LOGBUFSZ) = 2149
Log file size (4KB) (LOGFILSIZ) = 1024
Number of primary log files (LOGPRIMARY) = 6
Number of secondary log files (LOGSECOND) = 3
Changed path to log files (NEWLOGPATH) =
Path to log files = /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
Overflow log path (OVERFLOWLOGPATH) =
Mirror log path (MIRRORLOGPATH) =
First active log file = S0000000.LOG
Block log on disk full (BLK_LOG_DSK_FUL) = NO
Block non logged operations (BLOCKNONLOGGED) = NO
Percent max primary log space by transaction (MAX_LOG) = 0
Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0
Percent log file reclaimed before soft chckpt (SOFTMAX) = 0
HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC
HADR spool log data limit (4KB) (HADR_SPOOL_LIMIT) = AUTOMATIC(0)
HADR log replay delay (seconds) (HADR_REPLAY_DELAY) = 0
First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/archivelog/aaa/
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) =
Failover log archive path (FAILARCHPATH) =
Number of log archive retries on error (NUMARCHRETRY) = 5
Log archive retry Delay (secs) (ARCHRETRYDELAY) = 20
Log pages during index build (LOGINDEXBUILD) = OFF
Log DDL Statements (LOG_DDL_STMTS) = NO
Log Application Information (LOG_APPL_INFO) = NO
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa show detail |grep -i log
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
total 24628
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:26 S0000000.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:26 S0000001.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:13 S0000002.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:13 S0000003.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:13 S0000004.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:13 S0000005.LOG
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/archivelog/aaa
total 4
drwxr-x---. 3 db2inst1 db2iadm1 4096 Jan 16 08:26 db2inst1
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/archivelog/aaa/db2inst1/AAA/NODE0000/LOGSTREAM0000/C0000000/
total 0
[db2inst1@DB2test183 aaa]$ db2 archive log for db aaa
SQL1116N A connection to or activation of database "AAA" failed because the
database is in BACKUP PENDING state. SQLSTATE=57019
[db2inst1@DB2test183 aaa]$ db2 backup database aaa
Backup successful. The timestamp for this backup image is : 20140116083522
[db2inst1@DB2test183 aaa]$ db2 archive log for db aaa
DB20000I The ARCHIVE LOG command completed successfully.
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa |grep -i log
Log retain for recovery status = NO
User exit for logging status = YES
Catalog cache size (4KB) (CATALOGCACHE_SZ) = 300
Log buffer size (4KB) (LOGBUFSZ) = 2149
Log file size (4KB) (LOGFILSIZ) = 1024
Number of primary log files (LOGPRIMARY) = 6
Number of secondary log files (LOGSECOND) = 3
Changed path to log files (NEWLOGPATH) =
Path to log files = /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
Overflow log path (OVERFLOWLOGPATH) =
Mirror log path (MIRRORLOGPATH) =
First active log file = S0000002.LOG
Block log on disk full (BLK_LOG_DSK_FUL) = NO
Block non logged operations (BLOCKNONLOGGED) = NO
Percent max primary log space by transaction (MAX_LOG) = 0
Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0
Percent log file reclaimed before soft chckpt (SOFTMAX) = 0
HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC
HADR spool log data limit (4KB) (HADR_SPOOL_LIMIT) = AUTOMATIC(0)
HADR log replay delay (seconds) (HADR_REPLAY_DELAY) = 0
First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/archivelog/aaa/
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) =
Failover log archive path (FAILARCHPATH) =
Number of log archive retries on error (NUMARCHRETRY) = 5
Log archive retry Delay (secs) (ARCHRETRYDELAY) = 20
Log pages during index build (LOGINDEXBUILD) = OFF
Log DDL Statements (LOG_DDL_STMTS) = NO
Log Application Information (LOG_APPL_INFO) = NO
[db2inst1@DB2test183 aaa]$ db2 archive log for db aaa
DB20000I The ARCHIVE LOG command completed successfully.
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa |grep -i first
First active log file = S0000004.LOG
First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/archivelog/aaa/
[db2inst1@DB2test183 aaa]$ db2 archive log for db aaa
DB20000I The ARCHIVE LOG command completed successfully.
[db2inst1@DB2test183 aaa]$ db2 get db cfg for aaa |grep -i first
First active log file = S0000006.LOG
First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/archivelog/aaa/
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/archivelog/aaa/db2inst1/AAA/NODE0000/LOGSTREAM0000/C0000000/
total 48
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:37 S0000000.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:37 S0000001.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000002.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000003.LOG
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
total 12336
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000004.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000005.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:38 S0000006.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:38 S0000007.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:38 S0000008.LOG
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ db2 archive log for db aaa
DB20000I The ARCHIVE LOG command completed successfully.
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/archivelog/aaa/db2inst1/AAA/NODE0000/LOGSTREAM0000/C0000000/
total 96
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:37 S0000000.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:37 S0000001.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000002.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000003.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000004.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000005.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000006.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000007.LOG
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
total 16440
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000006.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000007.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:38 S0000008.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:39 S0000009.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:39 S0000010.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:39 S0000011.LOG
[db2inst1@DB2test183 aaa]$ db2 archive log for db aaa
DB20000I The ARCHIVE LOG command completed successfully.
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/archivelog/aaa/db2inst1/AAA/NODE0000/LOGSTREAM0000/C0000000/
total 96
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:37 S0000000.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:37 S0000001.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000002.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:38 S0000003.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000004.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000005.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000006.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:39 S0000007.LOG
[db2inst1@DB2test183 aaa]$ ls -l /home/db2inst1/db2inst1/NODE0000/SQL00002/LOGSTREAM0000/
total 16440
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:40 S0000008.LOG
-rw-------. 1 db2inst1 db2iadm1 12288 Jan 16 08:40 S0000009.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:39 S0000010.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:39 S0000011.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:40 S0000012.LOG
-rw-------. 1 db2inst1 db2iadm1 4202496 Jan 16 08:40 S0000013.LOG