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. 執行