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.增加設備
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com