Home Database Mysql Tutorial DB2的归档模式设置方法

DB2的归档模式设置方法

Jun 07, 2016 pm 05:33 PM
db2 o database

DB2的日志使用通常有两种方式,既称之为循环日志,也就是不采用归档日志模式,另外一种就是归档日志模式,默认是循环日志模式,也

DB2的日志使用通常有两种方式,既称之为循环日志,也就是不采用归档日志模式,另外一种就是归档日志模式,默认是循环日志模式,也就是无法进行日志归档或在线备份。通常来说决定DB2日志配置的几个database级别的参数如下:
当前的数据库版本为:
[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 (4KB)                        (LOGBUFSZ) = 256
Log file size (4KB)                        (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                        (MIRRORLOGPATH) =
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) =

如上常用的参数介绍如下:
LOGPRIMARY+LOGSECOND是日志文件的个数,而每个日志文件的大小由LOGFILSIZ参数设定,如上当前的日志文件大小为2000 pages,而page大小为4K,所以每个日志文件为8M,总共的日志空间为400M,NEWLOGPATH参数决定了日志文件存放目录路径,修改后可以动态生效。
First active log file就是指DB当前使用的活动日志文件名称
MAX_LOG 指定单个事物可以使用主日志空间的百分比,当达到这个百分比后,这个事物就得被回滚,默认设置为0,也就是单个事务日志空间使用不受限制,可以使用主附日志的所有空间。
SOFTMAX 指定软检查点频率和范围,单位为一个日志文件大小的百分比,100也就是一个日志文件,当发生数据库崩溃恢复时,需要保持一致状态,就会发生崩溃恢复,需要使用指定日志文件数来做恢复,当然日志量越小恢复就越快,通常保持默认值。
LOGARCHMETH1 这个即设置归档的方式,可以指定DISK、TSM等参数。
上面大概介绍了参数设置,那么如何配置DB2归档呢?
其实DB2的归档配置比较简单,只需要需要修改LOGARCHMETH1参数即可如下:
[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
effective.

但是修改了这个参数还是无法生效的,需要执行重启数据库这里直接重启实例:
[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
发现重启后还是不能连接,这时数据库状态为BACKUP PENDING,需要做一个备份,,记住是离线备份。

更多详情见请继续阅读下一页的精彩内容:

推荐阅读:

DB2数据库性能调整和优化(第1、2版) PDF

DB2数据库性能优化介绍

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

How to install and register the btc trading app? How to install and register the btc trading app? Feb 21, 2025 pm 07:09 PM

This article will provide a detailed introduction to how to install and register a Bitcoin trading application. The Bitcoin trading app allows users to manage and trade cryptocurrencies such as Bitcoin. The article guides users through the installation and registration process step by step, including downloading applications, creating accounts, performing identity verification, and first deposit. The goal of the article is to provide beginners with clear and easy-to-understand guidelines to help them easily enter the world of Bitcoin trading.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

Top 10 global digital currency trading apps recommended (2025 currency trading software ranking) Top 10 global digital currency trading apps recommended (2025 currency trading software ranking) Mar 12, 2025 pm 05:48 PM

This article recommends the top ten digital currency trading apps in the world, including Binance, OKX, Huobi Global, Coinbase, Kraken, Gate.io, KuCoin, Bitfinex, Gemini and Bitstamp. These platforms have their own characteristics in terms of transaction pair quantity, transaction speed, security, compliance, user experience, etc. For example, Binance is known for its high transaction speed and extensive services, while Coinbase is more suitable for novices. Choosing a platform that suits you requires comprehensive consideration of your own needs and risk tolerance. Learn about the world's mainstream digital currency trading platforms to help you conduct digital asset trading safely and efficiently.

PHP Database Connection Pitfalls: Avoid Common Mistakes and Misunderstandings PHP Database Connection Pitfalls: Avoid Common Mistakes and Misunderstandings Jun 05, 2024 pm 10:21 PM

To avoid PHP database connection errors, follow best practices: check for connection errors and match variable names with credentials. Use secure storage or environment variables to avoid hardcoding credentials. Close the connection after use to prevent SQL injection and use prepared statements or bound parameters.

See all articles