`
youyu4
  • 浏览: 440285 次
社区版块
存档分类
最新评论

DB2 The transaction log for the database is full

 
阅读更多

DB2在执行一个大的insert/update操作的时候报“The transaction log for the database is full.. ”错误,查了一下文档是DB2的日志文件满了的缘故。

 

1.连接db2服务器

  切换linux用户

 

  su - db2inst1

 

 

2.连接数据库

 

     db2 connect to 数据库名 user 用户名 using 密码

 

 

3. 首先运行下面命令来查看DB2的日志配置信息

 

  1. $ db2 get db cfg | grep LOG  

 

4. 注意其中的下面配置项

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
 
  1. Log file size (4KB)                         (LOGFILSIZ) = 1024  
  2. Number of primary log files                (LOGPRIMARY) = 45  
  3. Number of secondary log files               (LOGSECOND) = 20  

 

5. 此时可以通过下面的命令来修改B2的日志配置信息

  1. $ db2 update db cfg using LOGFILSIZ 10240  
  2. $ db2 update db cfg using LOGPRIMARY 100  
  3. $ db2 update db cfg using LOGSECOND 100  

 

6. 修改配置以后需要重新启动数据库实例

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
 
  1. $ db2stop force  
  2. $ db2start  

7. 最后再次查看修改后的参数,然后重新运行insert/update操作。

 

 

 

下面稍微想想其原因,DB2数据库的日志原理:

事务日志记录数据库中所有对象和数据的改变,在早前版本中最大可达256G,其大小为( logprimary + logsecond ) * logfilsiz,其中logprimary + logsecond的值小于或等于256,logfilsiz的最大为262144,在9.5版本中,日志最大已经可以达到512G,其中logfilsz的大小更改为524286。

 

DB2数据库的日志分为主日志辅助日志,其中主日志在第一个连接到达数据库或者数据库被激活后立即分配,而辅助日志在主日志大小不够的时候动态分配。所以需要注意一点,日志所在的文件系统的大小必须大于主日志文件与辅助日志文件的大小之和。

 

DB2数据库有2种日志配置方式,循环日志与归档日志。

循环日志:这是数据库默认的日志使用方式,主日志用来记录所有的更改,当事务提交后,日志文件会被重用。当主日志文件达到限制时,辅助日志文件将被使用。这种日志方式可以进行崩溃恢复和版本恢复,不能进行前滚恢复,不支持在线备份。

当活动事务的使用空间超过主日志和辅助日志的限制或者日志空间超过磁盘可使用空间,将会得到日志满的错误。

 

归档日志:启用logarchmetd1、logarchmetd2或打开logretain参数,注意,在9.5版本中,不推荐使用logretain参数,其所有的设置值将被忽略。在数据库归档日志规划时,建议不再使用logretain的方法。日志文件将不会被删除-保持在线或者离线状态。支持前滚恢复和在线备份。

 

疑问:归档日志下,日志一直保留,持续生成新日志,为什么还会出现日志满的错误?

归档日志下,其可用的活动日志大小依然受到主日志与辅助日志大小之和的限制,所以,即使在归档日志下,日志满的场景与活动日志下是完全一样的。

 

分享到:
评论

相关推荐

    Attach a SQL Server database with a missing transaction log file

    ### Attach a SQL Server Database with a Missing Transaction Log File 在日常的数据库管理与维护工作中,遇到丢失事务日志文件的情况并不少见。这类问题通常会给数据库的正常运行带来一定困扰,尤其是当试图附加...

    Addressing OLTP Solutions with CICS:The Transaction Server for AIX

    在《Addressing OLTP Solutions with CICS: The Transaction Server for AIX》这本206页的PDF格式书籍中,作者深入探讨了如何使用CICS (Customer Information Control System) 解决大规模在线事务处理(OLTP)问题,...

    Plate Rolling Order Transaction Log.xls

    Plate Rolling Order Transaction Log.xls

    There is no active transaction解决

    之前一直找原因,最后知道了解决方法,具体请下载源码查看。特别是用到throw的事务中

    Oracle Database 10g: The Top 20 Features for DBAs

    This information is critical for diagnosing performance issues and tuning the database. **Benefits:** - Enables precise diagnosis of performance bottlenecks. - Supports proactive performance tuning....

    oracle 10g-admin1 考试试题

    - **Datafiles and Online Redolog Files Are Checked for Consistency While Opening the Database (E)**: Before the database can be opened, a consistency check is performed on all datafiles and online ...

    LogExplorer4.2 For sql server使用教程

    ### LogExplorer4.2 For SQL Server使用教程 #### 一、LogExplorer4.2简介与功能 **Log Explorer**是一款专用于Microsoft SQL Server事务分析和数据恢复的强大工具。这款工具可以帮助用户浏览数据库日志文件、导出...

    微软内部资料-SQL性能优化3

    For example, if you defer constraint checking, it is your responsibility to ensure that the database is consistent. Isolation Concurrent transactions are isolated from the updates of other incomplete...

    Log Explorer for SQL Server v4.22

    恢复完后,再打开log explorer 提示No log recorders found that match the filter,would you like to view unfiltered data 选择yes 就看不到刚才在2中修改的日志记录,所以无法做恢复. 3) 不要用SQL的备份...

    Absolute Database for D7

    Overview Absolute Database: Delphi database with SQL support.Absolute Database lets you forget the Borland Database Engine (BDE). This BDE replacement is the compact, high-speed, robust and easy-to-...

    Log Explorer for SQL Server v4.22 含注册机

    恢复完后,再打开log explorer 提示No log recorders found that match the filter,would you like to view unfiltered data 选择yes 就看不到刚才在2中修改的日志记录,所以无法做恢复. 3) 不要用SQL的备份功能...

    PLATE ROLLING ORDER TRANSACTION LOG(表格模板、XLS格式).XLS

    PLATE ROLLING ORDER TRANSACTION LOG(表格模板、XLS格式).XLS

    SALVAGE PLATE DIVERTING TRANSACTION LOG(表格模板、XLS格式).XLS

    SALVAGE PLATE DIVERTING TRANSACTION LOG(表格模板、XLS格式).XLS

    Best Practices for SAP BW on DB2 UDB for z/OS V8

    The IBM Redbook titled "Best Practices for SAP Business Information Warehouse (BW) on DB2 UDB for z/OS V8" provides comprehensive guidance on leveraging IBM's DB2 Universal Database (UDB) Version 8 ...

    Unidac Pro 7.1.4 XE8

    Bug with closing a connection that has an active transaction for Firebird 3 is fixed Bug with recreating a connection on Linux and mobile platforms is fixed PostgreSQL data provider SSPI ...

    SSD7: Database Systems

    The course explains what a database system is, and then proceeds for the greater part of the learning material to explore relational database systems—databases designed according to the relational ...

    cli guide and Reference

    ### CLI (Call Level Interface) ... Understanding the basics of initialization, transaction processing, and SQL statement execution is crucial for effectively using DB2 CLI in application development.

    Oracle Database Transactions and Locking Revealed(Apress,2014).

    Oracle Database Transactions and Locking Revealed provides much-needed information for building scalable, high-concurrency applications and deploy them against the Oracle Database. Read this short, ...

    unidac_7_1_4_pro DELPHI 10 Tokyo

    Bug with closing a connection that has an active transaction for Firebird 3 is fixed Bug with recreating a connection on Linux and mobile platforms is fixed PostgreSQL data provider SSPI ...

    unidac_7_1_4_pro DELPHI 10 Berlin

    Bug with closing a connection that has an active transaction for Firebird 3 is fixed Bug with recreating a connection on Linux and mobile platforms is fixed PostgreSQL data provider SSPI ...

Global site tag (gtag.js) - Google Analytics