在数据库中,日志的重要性那是大大的大,所以日志一定是要先了解的. 日志类型:主日志(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日志管理及主备同步.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.


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

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

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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