There are usually two ways to use DB2 logs: cyclic logs, that is, do not use the archive log mode. The other is the archive log mode, which is the cyclic log mode by default, that is, logs cannot be archived or backed up online. The following table lists the database-level parameters that determine the DB2 log Configuration:
The current database version is:
[Db2inst1 @ localhost] $ db2level
DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL09075"
With level identifier "08060107 ".
Informational tokens are "DB2 v9.7.0.5", "s111017", "IP23291", and Fix Pack
"5 ".
Product is installed at "/opt/ibm/db2/V9.7 ".
[Db2inst1 @ localhost] $ db2 get db cfg | grep-I log
Log retain for recovery status = NO
User exit for logging status = YES
Log buffer size (4 kb) (LOGBUFSZ) = 256
Log file size (4 kb) (LOGFILSIZ) = 2000
Number of primary log files (LOGPRIMARY) = 20
Number of secondary log files (LOGSECOND) = 30
Changed path to log files (NEWLOGPATH) =
Path to log files =/home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/
Overflow log path (OVERFLOWLOGPATH) =
Mirror log path (Mirror logpath) =
First active log file = S0000001.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) = 100
Log retain for recovery enabled (LOGRETAIN) = OFF
User exit for logging enabled (USEREXIT) = OFF
HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC
First log archive method (LOGARCHMETH1) = DISK:/db2src/TS/backup/
Options for logarchmeth1 (LOGARCHOPT1) =
Second log archive method (LOGARCHMETH2) = OFF
Options for logarchmeth2 (LOGARCHOPT2) =
Failover log archive path (FAILARCHPATH) =
The preceding common parameters are described as follows:
LOGPRIMARY + LOGSECOND is the number of log files, and the size of each log file is set by the LOGFILSIZ parameter. As shown in the preceding figure, the current log file size is 2000 pages, and the page size is 4 K, therefore, each log file is 8 MB, and the total log space is 400 mb. The NEWLOGPATH parameter determines the log file storage directory path, which can take effect dynamically after modification.
The First active log file is the name of the active log file currently used by the DB.
MAX_LOG specifies the percentage of primary log space that can be used by a single transaction. When this percentage is reached, the transaction must be rolled back. The default value is 0, that is to say, the use of a single transaction log space is not limited. You can use all the space of the primary log.
SOFTMAX specifies the soft checkpoint frequency and range. The unit is the percentage of the size of a log file. The value 100 is also a log file. When a database crashes and recovers, it must be in the same status, crash recovery occurs. You need to use the specified number of log files for recovery. Of course, the smaller the log volume, the faster the recovery will be. The default value is usually used.
LOGARCHMETH1: Specifies the archive mode. You can specify parameters such as DISK and TSM.
The preceding section describes the parameter settings. How do I configure DB2 archiving?
In fact, the archiving configuration of DB2 is relatively simple. You only need to modify the LOGARCHMETH1 parameter as follows:
[Db2inst1 @ localhost backup] $ db2 update db cfg using LOGARCHMETH1 'disk:/db2src/TS/backup'
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
Valid tive.
However, the modified parameter still does not take effect. You need to restart the database and restart the instance directly here:
[Db2inst1 @ localhost backup] $ db2stop force
11/25/2013 22:17:02 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
[Db2inst1 @ localhost backup] $ db2start
11/25/2013 22:17:07 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
[Db2inst1 @ localhost backup] $ db2 connect to sample
SQL1116N A connection to or activation of database "SAMPLE" cannot be made
Because of backup pending. SQLSTATE = 57019
After the instance is restarted, it cannot be connected. In this case, the database status is backup pending and a BACKUP is required. Remember that it is an offline BACKUP.
For more details, please continue to read the highlights on the next page:
Recommended reading:
DB2 database performance adjustment and optimization (1st and 2) PDF
DB2 database performance optimization