时间:2021-07-01 10:21:17 帮助过:107人阅读
1.准备数据库环境 --创建设备disk init name=dat1,physname=/opt/sybase/data/dat1,size=1Mdisk init name=log1,physname=/opt/sybase/data/log1,size=1M--设备太小,扩充disk resize name=dat1,size=1M--创建数据库create database test on dat1=2M log on l
1.准备数据库环境
--创建设备 disk init name='dat1',physname='/opt/sybase/data/dat1',size='1M' disk init name='log1',physname='/opt/sybase/data/log1',size='1M' --设备太小,扩充 disk resize name='dat1',size='1M' --创建数据库 create database test on dat1='2M' log on log1='1M'
2.插入数据一直到日志满
use test go create table person(name varchar(64)) insert into person values('name') insert into person select * from person --truncate table person dbcc checktable('syslogs')
3.出现现象如下
1.free为7%,进程出现logsuspend状态,数据库日志中出现 xtasks are sleeping .for space to become available in the log segment for database test 2.进程状态为LOGSUSPEND
4.经测试,执行如下操作可以解决问题
1.如果 syslogshold无数据,则可以直接执行dump transaction test with truncate_only
2.如果 syslogshold有数据,则直接执行dump transaction test with truncate_only,可能报如下错误
‘DUMP TRANSACTION for database 'test' could not truncate the log. Either extend the log using ALTER DATABASE ... LOG ON command or eliminate the oldest active transaction in database 'test' shown in syslogshold table.’
这个时候可以选择三种方式进行处理
1.kill进程,用kill with status_only监控回滚进度
2.重启服务
3.增加设备
重启方式测试:
[root@sybasehost ~]# isql -Usa -P -S ASE12_5_4 1> shutdown 2> go 2 task(s) are sleeping waiting for space to become available in the log segment for database test.
日志中出现如下信息:
SHUTDOWN is waiting for 1 process(es) to complete. SHUTDOWN is waiting for 1 process(es) to complete.
进程hang住,这时从另外一个窗口进去,用shutdown with nowait停掉,然后重启,重启后用户库标红,状态为suspend
执行执行online database test,报错如下
SQL Server could not bring database 'test' online.
执行dump transaction test with truncate_only,然后online database test成功
增加设备方式测试
disk init name='log2',physname='/opt/sybase/data/log2',size='1M' alter database test log on log2 ='1M'
显示执行成功
Extending database by 512 pages (1.0 megabytes) on disk log2 Warning: Using ALTER DATABASE to extend the log segment will cause user thresholds on the log segment within 128 pages of the last chance threshold to be disabled. 执行时间: 1.471 秒
原来挂起的进程自动继续执行
已插入 8192 行 Space available in the log segment has fallen critically low in database 'test'. All future modifications to this database will be suspended until the log is successfully dumped and space becomes available. The transaction log in database test is almost full. Your transaction is being suspended until space is made available in the log. 执行时间: 158.9 秒
总结:
出现日志挂起,先用截断日志的方式处理,如果不行,则根据情况以下采用三种方式处理
1.kill进程,用kill with status_only监控回滚进度
2.重启服务,记着要用shutdown with nowait,重启后要先截断日志再online数据库
3.增加设备