日志过大导致不能启动

资讯 驱动中国 若水 665 次阅读 0 条评论
分享 Q
问:有个问题问一下,关于SYBASE的:我打开数据库总是提醒:cannot open transaction log file-----cannot use log file "hms2000.log" since it is shorter than experted。我直接删除了日志,也不能正常启动,说找不到文件。请问这是怎么回事啊?附上出错的日志记录:I. 10/09 09:58:38. Sybase Adaptive server Anywhere Network server Version 7.0.2.1402 aIo`<`u  
I. 10/09 09:58:38. This software contains confidential and trade secret information of 4g%VYa  
I. 10/09 09:58:38. Sybase, Inc.Use, duplication or disclosure of the software and 2k+|N*?ib  
I. 10/09 09:58:38. documentation by the U.S. Government is subject to restrictions set forth e7d$o*Tf~P  
I. 10/09 09:58:38. in a license agreement between the Government and Sybase, Inc. or other 33lJI M,1  
I. 10/09 09:58:38. written agreement specifying the Government's rights to use the software 4E;J)WK^W  
I. 10/09 09:58:38. and any applicable FAR provisions, for example, FAR 52.227-19. \1+O=nXC  
I. 10/09 09:58:38. ]C4yX !q  
I. 10/09 09:58:38. Copyright 1989-2000 Sybase, Inc.All rights reserved. t[VpHriw  
I. 10/09 09:58:38. All unpublished rights reserved. & n"s|  
I. 10/09 09:58:38. g]O`(I~  
I. 10/09 09:58:38. Sybase, Inc. 6475 Christie Avenue, Emeryville, CA 94608, USA _fIQV?  
I. 10/09 09:58:38. Networked Seat (per-seat) model. Access to the server is limited to 99 seat(s). {4 U m"|E  
I. 10/09 09:58:38. This server is licensed to: R e}+AG7  
I. 10/09 09:58:38.lb 7,P!6f!B  
I. 10/09 09:58:38. L}b*R^,>  
I. 10/09 09:58:38. 10240K of memory used for caching <6Nu.+  
I. 10/09 09:58:38. Minimum cache size: 10240K, maximum cache size: 230848K ?hX8uX,u  
I. 10/09 09:58:38. Using a maximum page size of 1024 bytes 8KAzdyv|  
I. 10/09 09:58:38. Starting database "XXXXXXX" (C:Program Filessybase数据服务器XXXXXXX.db) at Sun Oct 09 2005 09:58 ~SL(Pf.>L  
I. 10/09 09:58:38. Database recovery in progress 5O^Nj$  
I. 10/09 09:58:38.Last checkpoint at Sat Oct 08 2005 19:15 )&2A2JgSV  
I. 10/09 09:58:38.Checkpoint log... Z lo7c(~  
I. 10/09 09:59:03.Transaction log: XXXXXXX.LOG... ~)JnG-.68  
E. 10/09 09:59:03. Error: Cannot open transaction log file -- Can't use log file "XXXXXXX.LOG" since it is shorter than expected v0 &T)}J  
I. 10/09 09:59:03. Error: Cannot open transaction log file -- Can't use log file "XXXXXXX.LOG" since it is shorter than expected qWYW(Lbzc  
E. 10/09 09:59:03. Cannot open transaction log file -- Can't use log file "XXXXXXX.LOG" since it is shorter than expected soOzw<~1  
I. 10/09 09:59:04. Database server stopped at Sun Oct 09 2005 09:59 S$?7t1  
I. 10/09 10:58:33. Sybase Adaptive server Anywhere Network server Version 7.0.2.1402 < FXVb7  
I. 10/09 10:58:33. This software contains confidential and trade secret information of 9.qsC4zW]~  
I. 10/09 10:58:33. Sybase, Inc.Use, duplication or disclosure of the software and iSQOn'L  
I. 10/09 10:58:33. documentation by the U.S. Government is subject to restrictions set forth wj;i )E  
I. 10/09 10:58:33. in a license agreement between the Government and Sybase, Inc. or other )%\Ok#1D  
I. 10/09 10:58:33. written agreement specifying the Government's rights to use the software 8zZ\uNA  
I. 10/09 10:58:33. and any applicable FAR provisions, for example, FAR 52.227-19. \>qO"F)Z  
I. 10/09 10:58:33. \C<U Sm  
I. 10/09 10:58:33. Copyright 1989-2000 Sybase, Inc.All rights reserved.#p#分页标题#e# !fMK_4  
I. 10/09 10:58:33. All unpublished rights reserved. nNiU`=,w2  
I. 10/09 10:58:33. 39I{O=sY(  
I. 10/09 10:58:33. Sybase, Inc. 6475 Christie Avenue, Emeryville, CA 94608, USA %)_A4>`:tx  
I. 10/09 10:58:33. Networked Seat (per-seat) model. Access to the server is limited to 99 seat(s). 0a'Sr X F  
I. 10/09 10:58:33. This server is licensed to: qZ-zm/8  
I. 10/09 10:58:33.lb >^g7`xI  
I. 10/09 10:58:33. Tc2XzI|  
I. 10/09 10:58:33. 10240K of memory used for caching xH%%CWy|  
I. 10/09 10:58:33. Minimum cache size: 10240K, maximum cache size: 230848K eNu@B0d  
I. 10/09 10:58:33. Using a maximum page size of 1024 bytes $6\ t(=  
I. 10/09 10:58:33. Starting database "XXXXXXX" (C:Program Filessybase数据服务器XXXXXXX.db) at Sun Oct 09 2005 10:58 -U\c[rb  
I. 10/09 10:58:33. Database recovery in progress Lqo}$lZ p  
I. 10/09 10:58:33.Last checkpoint at Sat Oct 08 2005 19:15 ?X,->^  
I. 10/09 10:58:33.Checkpoint log... |\n4;lM  
I. 10/09 10:58:55.Transaction log: XXXXXXX.LOG... js hf4z*  
E. 10/09 10:58:55. Error: Cannot open transaction log file -- Can't use log file "XXXXXXX.LOG" since it is shorter than expected hwg^"Aoi  
I. 10/09 10:58:55. Error: Cannot open transaction log file -- Can't use log file "XXXXXXX.LOG" since it is shorter than expected Bcn eL[  
E. 10/09 10:58:55. Cannot open transaction log file -- Can't use log file "XXXXXXX.LOG" since it is shorter than expected OFvMhhg#  
I. 10/09 10:58:57. Database server stopped at Sun Oct 09 2005 10:58 ;bFv-HIZK  
答:首先要确定的一点:直接删除日志的方法是不可取的。您的这个问题,是因为日志没有及时整理导致自身过大,使数据库不能正常启动。 d1'(iC~H@  
我们知道,SYBASEsql Server用事务(Transaction)来跟踪所有数据库的变化。事务是SQLServer的工作单元。一个事务包含一条或多条作为整体执行的T-SQL语句。每个数据库都有自己的事务日志(TransactionLog),即系统表(Syslogs)。事务日志自动记录每个用户发出的每个事务。日志对于数据库的数据安全性、完整性至关重要,我们进行数据库开发和维护必须熟知日志的相关知识。 cfHN;[II{  
[&7 =  
一、SYBASEsql server 如何记录和读取日志信息 )neF0A 5E  
G}!X26m  
SYBASEsql Server是先记Log的机制。每当用户执行将修改数据库的语句时,SQLServer就会自动地把变化写入日志。一条语句所产生的所有变化都被记录到日志后,它们就被写到数据页在缓冲区的拷贝里。该数据页保存在缓冲区中,直到别的数据页需要该内存时,该数据页才被写到磁盘上。若事务中的某条语句没能完成,SQLServer将回滚事务产生的所有变化。这样就保证了整个数据库系统的一致性和完整性。 ,*8o>g  
eIb>Uq y  
二、日志设备 ^S_jdf  
e6/DW1  
Log和数据库的Data一样,需要存放在数据库设备上,可以将Log和Data存放在同一设备上,也可以分开存放。一般来说,应该将一个数据库的Data和Log存放在不同的数据库设备上。这样做有如下好处:一是可以单独地备份?Backup事务日志;二是防止数据库溢满;三是可以看到Log的空间使用情况。 K7 %/~Z  
v'X^{W&G%D  
所建Log设备的大小,没有十分精确的方法来确定。一般来说,对于新建的数据库,Log的大小应为数据库大小的30%左右。Log的大小还取决于数据库修改的频繁程度。如果数据库修改频繁,则Log的增长十分迅速。所以说Log空间大小依赖于用户是如何使用数据库的。此外,还有其它因素影响Log大小,我们应该根据实际操作情况估计Log大小,并间隔一段时间就对Log进行备份和清除。 NTrvI|6  
三、日志的清除 w; N2%"\n  
4n8,o  
随着数据库的使用,数据库的Log是不断增长的,必须在它占满空间之前将它们清除掉。清除Log有两种方法: Ogxo 1'A  
C&j6; 3Bp  
1.自动清除法#p#分页标题#e# (gQlF )m8  
R+x=W  
开放数据库选项 Trunc Log on Chkpt,使数据库系统每隔一段时间自动清除Log。此方法的优点是无须人工干预,由SQLServer自动执行,并且一般不会出现Log溢满的情况;缺点是只清除Log而不做备份。 @:, d1#  
rI~B T$T  
2.手动清除法 FJ #H0#O  
kPcDX0U  
执行命令“dump transaction”来清除Log。以下两条命令都可以清除日志: ch_~0GLe,  
0=F+8|lW@n  
dump transaction with truncate_only <P) 0rGN  
1EXF>LVR  
dump transaction with no_log U_OLQa4  
zkP>MX  
通常删除事务日志中不活跃的部分可使用“dump transaction with trancate_only”命令,这条命令写进事务日志时,还要做必要的并发性检查。SYBASE提供“dump transaction with no_log”来处理某些非常紧迫的情况,使用这条命令有很大的危险性,SQLServer会弹出一条警告信息。为了尽量确保数据库的一致性,你应将它作为“最后一招”。 _r@CKTLlo  
6Nb9=0'  
以上两种方法只是清除日志,而不做日志备份,若想备份日志,应执行“dump transaction database_name to dumpdevice”命令。 < pze{5i  
BCR NjaO  
四、管理庞大的事务 -*vTOY%guR  
r |g9tp/  
有些操作会大批量地修改数据,如大量数据的修改(Update)、删除一个表的所有数据(Delete)、大量数据的插入(Insert),这样会使Log增长速度很快,有溢满的危险。下面给大家介绍一下如何拆分大事务,以避免日志的溢满。 c tP'\79]  
> /zA]\^X  
例如执行“update tab_a set col_a=0”命令时,若表tab_a很大,则此Update动作在未完成之前就可能使Log溢满,引起1105错误(Log Full),而且执行这种大的事务所产生的独占锁(Exclusive table Lock),会阻止其他用户在执行Update操作期间修改这个表,这就有可能引起死锁。为避免这些情况发生,我们可以把这个大的事务分成几个小的事务,并执行“dump transaction”动作。 4R!W-B5  
bQaDIry'u  
lU)6}Q'  
xO"F!83O/  
上例中的情况就可以分成两个或多个小的事务: 'X5E-Cb  
/RD;| %w.  
update tab_a set col_a=0 where col_b>x 4 EzC*VFd  
r)Uth![  
go D+!IZ oV  
SHO`4CTGK  
dump transaction database_name with truncate_only 2i L $v  
BexvL n  
go PRC@4~ m  
OU8_'!I*  
update tab_a set col_a=0 where col_b <=x 3:]O|H zxn  
Z9 aA{r  
go ( P(m7,N`  
KJJofnALA  
dump transaction database_name with truncate_only Fg>>mKEFy  
{Q[LnN  
go yJ`NQ  
rc!OS'@v  
这样,一个大的事务就被分成两个较小的事务。 )upo?~V  
<cw-8-@  
按照上述方法可以根据需要任意拆分大的事务。若这个事务需要备份到介质上,则不用“with truncate_only”选项。若执行“dump transaction with truncate_only”命令,应该先执行“dump database”。以此类推,我们可以对表删除、表插入等大事务做相应的拆分。 >ozK3xV  
版权声明:本文由驱动中国整理发布,转载需注明出处与原文链接。如有疑问请联系 editor@qudong.com
本文价值 成为第一个评分的人
登录后为本文打分
网友评论0 条评论
正在回复 的评论取消
评论加载中…
🔐

登录后参与互动

评论、点赞均可赚积分
连续签到、邀请好友也有奖励 🎁

电脑端: 微信扫码登录 微信内: 一键登录

微信扫一扫

打开微信「扫一扫」,分享本文到朋友圈或好友