DB2日志(1) 基础知识
在数据库中,日志的重要性那是大大的大,所以日志一定是要先了解的. 日志类型:主日志(Primary logs)预分配,可用数目由db cfg的L
在数据库中,日志的重要性那是大大的大,所以日志一定是要先了解的.
日志类型:
主日志(Primary logs)
预分配,可用数目由db cfg的LOGPRIMARY参数规定
辅助日志(Secondary logs)
依需要再动态分配,最大数目由db cfg的LOGSECOND参数来定.辅助日志同时会在数据库
所有连接全部关闭后被删除.
如果LOGSECOND为-1,则不限制记录日志的大小.
日志记录类型:
有两类循环日志和归档日志,可以通过"配置数据库日志记录"向导来修改数据库的日志记录类型。
(1)循环日志:
默认的日志记录策略,循环日志按顺序使用。当日志中所包含的工作已提交或回滚时,,可以重用。
主日志预先分配。 而辅助日志则在需要时才分配。
循环日志有两类日志,主日志和辅助日志.
主日志预先就要配好了,辅助日志在需要时再分分配.
DB2管理程序按顺序请求 -> 查找主日志 -> 需要的主日志不可用 -> 分配一个辅助日志.
-> 辅助日志也满了 -> 再去检查下主日志能用不 -> 还不可用就又分配一个新的辅助日志
-> 然后就一直重复上述检查
-> 一直到有主日志文件变为可重用为止.然后就把辅助日志释放掉.
循环日志在备份恢复中的作用:
不能进行前滚恢复,但可进行崩溃恢复和版本恢复
仅支持脱机备份.
(2)归档日志
归档日志是一种日志文件的管理技术,将那些处理非活动状态的日志文件进行归档.
归档日志是非默认的.
归档日志有几个要类
1.活动日志
包含发那些尚未提交(或回滚)的事务相关信息.还包含已提交但改动还没与的的事务相关信息
restart database;
rollforward
2.联机归档日志
当活动日志关闭时,将成为一个归档日志。称它们为"联机" 是因为它们和活动
日志存放在相同的子目录下。
3.脱机归档日志
这些日志文件已经从活动日志所在的目录中移开了。可以手动,也可以
通过 userexit这样的过程调用来自动进行。归档的日志文件可以
存储到磁带或其它介质上。如tsm上。
正在用的日志(活动日志) -> 如果日志用完了(联机归档日志) -> 再把这些不用的日志给备份或移开(脱机归档日志)
循环日志在备份恢复中的作用:
唯一支持前滚恢复和实现可恢复数据库的日志方法.
支持脱机备份和联机备份
在DB2数据库中查看与日志有关的主要参数:
userexit 是否启用用户出口
logretain 是否启用归档日志
trackmod 是否启用增量备份功能
这些默认是off,即循环日志模式,如为"Yes"或"Recovery",则表明为归档日志模式.
Unix/Linux下的查看命令:
db2 get db cfg for sample |grep "userexit"
db2 get db cfg for sample |grep "logretain"
db2 get db cfg for sample |grep "trackmod"
Windows下的查看命令:
db2 get db cfg for sample |find /I "userexit"
db2 get db cfg for sample |find /I "logretain"
db2 get db cfg for sample |find /I "trackmod"
可更改这些参数使DB2数据库处于归档日志模式,以便支持联机备份.
更改命令:
db2 update db cfg for sample using userexit on//启用用户出口
db2 update db cfg for sample using logretain on//启用归档日志
db2 update db cfg for sample using trackmod on//启用增量备份功能
注意事项:
变更这些归档模式参数后,是不能马上连接上数据库的,必须要做脱机备份一次才行.
脱机备份命令例子:
db2 backup db sample to c:\xclbkcold
关于日志的管理:
查看首活动日志:
db2 get db cfg for sample
First active log file= S0000011.LOG //Unix/Linux下
首个活动日志文件 = S0000011.LOG //Windows下
清理日志:
db2 connectto sample
db2 prune logfile prior to S0000011.LOG
其中S0000011.LOG就是刚刚的首活动日志
手工归档命令:
db2 archive log for db sample //会手工产生日志
推荐阅读:
DB2数据库性能调整和优化(第1、2版) PDF
DB2数据库性能优化介绍
DB2日志(2) 用C语言扩展实现DB2日志管理及主备同步.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The retention period of Oracle database logs depends on the log type and configuration, including: Redo logs: determined by the maximum size configured with the "LOG_ARCHIVE_DEST" parameter. Archived redo logs: Determined by the maximum size configured by the "DB_RECOVERY_FILE_DEST_SIZE" parameter. Online redo logs: not archived, lost when the database is restarted, and the retention period is consistent with the instance running time. Audit log: Configured by the "AUDIT_TRAIL" parameter, retained for 30 days by default.

Oracle database server hardware configuration requirements: Processor: multi-core, with a main frequency of at least 2.5 GHz. For large databases, 32 cores or more are recommended. Memory: At least 8GB for small databases, 16-64GB for medium sizes, up to 512GB or more for large databases or heavy workloads. Storage: SSD or NVMe disks, RAID arrays for redundancy and performance. Network: High-speed network (10GbE or higher), dedicated network card, low-latency network. Others: Stable power supply, redundant components, compatible operating system and software, heat dissipation and cooling system.

The amount of memory required by Oracle depends on database size, activity level, and required performance level: for storing data buffers, index buffers, executing SQL statements, and managing the data dictionary cache. The exact amount is affected by database size, activity level, and required performance level. Best practices include setting the appropriate SGA size, sizing SGA components, using AMM, and monitoring memory usage.

To create a scheduled task in Oracle that executes once a day, you need to perform the following three steps: Create a job. Add a subjob to the job and set its schedule expression to "INTERVAL 1 DAY". Enable the job.

The amount of memory required for an Oracle database depends on the database size, workload type, and number of concurrent users. General recommendations: Small databases: 16-32 GB, Medium databases: 32-64 GB, Large databases: 64 GB or more. Other factors to consider include database version, memory optimization options, virtualization, and best practices (monitor memory usage, adjust allocations).

Oracle Database memory requirements depend on the following factors: database size, number of active users, concurrent queries, enabled features, and system hardware configuration. Steps in determining memory requirements include determining database size, estimating the number of active users, understanding concurrent queries, considering enabled features, and examining system hardware configuration.

Oracle listeners are used to manage client connection requests. Startup steps include: Log in to the Oracle instance. Find the listener configuration. Use the lsnrctl start command to start the listener. Use the lsnrctl status command to verify startup.

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())
