sybase ASE日誌溢出解決方式探究


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.增加設備


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章