sybase 服务器断电 启动报错Error: 926 624 3414
昨天上午一用户的系统无法登陆,检查后发现数据库xxxxx没有正常online。
客户描述是由于异常断电引起的。
查询数据库状态
select name,status from sysdatabases
go

我们的sybase选项设置为12.所以这里的332不正常。
查看日志信息
00:00000:00001:2015/11/11 15:57:30.40 server Error: 926, Severity: 14, State: 1
00:00000:00001:2015/11/11 15:57:30.40 server Database 'xxxxx' cannot be opened. An earlier attempt at recovery marked it 'suspect'. Check the SQL Server errorlog for information as to the cause.
00:00000:00001:2015/11/11 15:57:30.42 server Unable to proceed with the recovery of dbid <5> because of previous errors. Continuing with the next database.
既然标记为可疑状态,那就进行恢复。
sp_configure "allow updates", 1
go
reconfigure with override
go
update master..sysdatabases set status =-32768 Where name="xxxxx"
go
shutdown with nowait
go
启动sybase
update master..sysdatabases set status=0 Where name="xxxxx"
go
sp_configure "allow updates" ,0
go
reconfigure with override
go
重新设置数据库参数
sp_dboption cwbase1,'trunc log on',true
go
sp_dboption cwbase1,'select into/bulkcopy',true
go
重启数据库
启动后检查数据库状态发现还是不对,再次查看日志
00:00000:00001:2015/11/11 21:52:37.04 server Recovering database 'xxxxx'.
00:00000:00001:2015/11/11 21:52:37.10 server Error: 624, Severity: 21, State: 1
00:00000:00001:2015/11/11 21:52:37.10 server Adaptive Server failed to retrieve a row via its RID in database 'xxxxx' because the requested RID has a higher number than the last RID on the page. Rid pageid = 0x5a136d; row num = 0x6. Page pointer = 0x49BAA000, pageno = 5903213, status = 0x1, objectid = 8, indexid = 0, level = 0.
00:00000:00001:2015/11/11 21:52:37.14 server Error: 3414, Severity: 21, State: 1
00:00000:00001:2015/11/11 21:52:37.14 server Database 'cwbase1' (dbid 5): Recovery failed. Check the SQL Server errorlog for further information as to the cause.
其中objectid = 8表示日志段,这就说明了日志段由于断电造成异常,接下来修复这个问题。
name id
---- -----------
syslogs 8
赋予sa用户sybase_ts_role的角色权限
sp_role "grant","sybase_ts_role",sa
先进行上述修复,设置参数后不要重启sybase。
dbcc rebuild_log(xxxxx,1,1)
使用此命令重建日志。
完成后重启sybase,顺利启动
再使用dbcc检查数据库
dbcc checkdb(xxxxx)
到此修复成功,最后提醒还是多备份,此次由于备份是上个月的,如果十分严重的话要恢复备份,用户就需要重做近一个月的数据了。
数据库虽小,数据无价,可不要大意。