成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

Sybase數據庫日志過大導致不能啟動

2010-08-28 10:50:01來源:西部e網作者:

問:有個問題問一下,關于SYBASE的:我打開數據庫總是提醒:cannot open transaction log file-----cannot use log file "hms2000.log" since it is shorter than experted。我直接刪除了日志,也不能正常啟動,說找不到文件。

請問這是怎么回事啊?附上出錯的日志記錄:

I. 10/09 09:58:38. Sybase Adaptive Server Anywhere Network Server Version 7.0.2.1402
I. 10/09 09:58:38. This software contains confidential and trade secret information of
I. 10/09 09:58:38. Sybase, Inc.  Use, duplication or disclosure of the software and
I. 10/09 09:58:38. documentation by the U.S. Government is subject to restrictions set forth
I. 10/09 09:58:38. in a license agreement between the Government and Sybase, Inc. or other
I. 10/09 09:58:38. written agreement specifying the Government's rights to use the software
I. 10/09 09:58:38. and any applicable FAR provisions, for example, FAR 52.227-19.
I. 10/09 09:58:38.  
I. 10/09 09:58:38. Copyright 1989-2000 Sybase, Inc.  All rights reserved.
I. 10/09 09:58:38. All unpublished rights reserved.
I. 10/09 09:58:38.  
I. 10/09 09:58:38. Sybase, Inc. 6475 Christie Avenue, Emeryville, CA 94608, USA

I. 10/09 09:58:38. Networked Seat (per-seat) model. Access to the server is limited to 99 seat(s).
I. 10/09 09:58:38. This server is licensed to:
I. 10/09 09:58:38.     lb
I. 10/09 09:58:38.     
I. 10/09 09:58:38. 10240K of memory used for caching
I. 10/09 09:58:38. Minimum cache size: 10240K, maximum cache size: 230848K
I. 10/09 09:58:38. Using a maximum page size of 1024 bytes
I. 10/09 09:58:38. Starting database "XXXXXXX" (C:\Program Files\sybase\數據服務器\XXXXXXX.db)
 at Sun Oct 09 2005 09:58
I. 10/09 09:58:38. Database recovery in progress
I. 10/09 09:58:38.     Last checkpoint at Sat Oct 08 2005 19:15
I. 10/09 09:58:38.     Checkpoint log...
I. 10/09 09:59:03.     Transaction log: XXXXXXX.LOG...
E. 10/09 09:59:03. Error: Cannot open transaction log file -- Can't use log
file "XXXXXXX.LOG" since it is shorter than expected
I. 10/09 09:59:03. Error: Cannot open transaction log file -- Can't use log 
file "XXXXXXX.LOG" since it is shorter than expected

E. 10/09 09:59:03. Cannot open transaction log file -- Can't use log file "XXXXXXX.LOG" 
since it is shorter than expected
I. 10/09 09:59:04. Database server stopped at Sun Oct 09 2005 09:59
I. 10/09 10:58:33. Sybase Adaptive Server Anywhere Network Server Version 7.0.2.1402

I. 10/09 10:58:33. This software contains confidential and trade secret information of
I. 10/09 10:58:33. Sybase, Inc.  Use, duplication or disclosure of the software and
I. 10/09 10:58:33. documentation by the U.S. Government is subject to restrictions set forth
I. 10/09 10:58:33. in a license agreement between the Government and Sybase, 
Inc. or other
I. 10/09 10:58:33. written agreement specifying the Government's rights to
 use the software
I. 10/09 10:58:33. and any applicable FAR provisions, for example, FAR 52.227-19.
I. 10/09 10:58:33.  
I. 10/09 10:58:33. Copyright 1989-2000 Sybase, Inc.  All rights reserved.
I. 10/09 10:58:33. All unpublished rights reserved.
I. 10/09 10:58:33.  
I. 10/09 10:58:33. Sybase, Inc. 6475 Christie Avenue, Emeryville, CA 94608, USA

I. 10/09 10:58:33. Networked Seat (per-seat) model. Access to the server 
is limited to 99 seat(s).
I. 10/09 10:58:33. This server is licensed to:
I. 10/09 10:58:33.     lb
I. 10/09 10:58:33.     
I. 10/09 10:58:33. 10240K of memory used for caching
I. 10/09 10:58:33. Minimum cache size: 10240K, maximum cache size: 230848K
I. 10/09 10:58:33. Using a maximum page size of 1024 bytes
I. 10/09 10:58:33. Starting database "XXXXXXX" (C:\Program Files\sybase\數據服務器\XXXXXXX.db)
 at Sun Oct 09 2005 10:58
I. 10/09 10:58:33. Database recovery in progress
I. 10/09 10:58:33.     Last checkpoint at Sat Oct 08 2005 19:15
I. 10/09 10:58:33.     Checkpoint log...
I. 10/09 10:58:55.     Transaction log: XXXXXXX.LOG...
E. 10/09 10:58:55. Error: Cannot open transaction log file -- Can't use log 
file "XXXXXXX.LOG" since it is shorter than expected
I. 10/09 10:58:55. Error: Cannot open transaction log file -- Can't use log 
file "XXXXXXX.LOG" since it is shorter than expected

E. 10/09 10:58:55. Cannot open transaction log file -- Can't use log file 
"XXXXXXX.LOG" since it is shorter than expected
I. 10/09 10:58:57. Database server stopped at Sun Oct 09 2005 10:58

答:首先要確定的一點:直接刪除日志的方法是不可取的。您的這個問題,是因為日志沒有及時整理導致自身過大,使數據庫不能正常啟動。

我們知道,SYBASE SQL Server用事務(Transaction)來跟蹤所有數據庫的變化。事務是SQL Server的工作單元。一個事務包含一條或多條作為整體執行的T -SQL語句。每個數據庫都有自己的事務日志(Transaction Log),即系統表(Syslogs)。事務日志自動記錄每個用戶發出的每個事務。日志對于數據庫的數據安全性、完整性至關重要,我們進行

數據庫開發和維護必須熟知日志的相關知識。

一、SYBASE SQL Server 如何記錄和讀取日志信息

SYBASE SQL Server是先記Log的機制。每當用戶執行將修改數據庫的語句時,SQL Server就會自動地把變化寫入日志。一條語句所產生的所有變化都被記錄到日志后,它們就被寫到數據頁在緩沖區的拷貝里。該數據頁保存在緩沖區中,直到別的數據頁需要該內存時,該數據頁才被寫到磁盤上。若事務中的某條語句沒能完成,SQL Server將回滾事務產生的所有變化。這樣就保證了整個數據庫系統的一致性和完整性。

二、日志設備

Log和數據庫的Data一樣,需要存放在數據庫設備上,可以將Log和Data存放在同一設備上,也可以分開存放。一般來說,應該將一個數據庫的 Data和Log存放在不同的數據庫設備上。這樣做有如下好處:一是可以單獨地備份Backup 事務日志;二是防止數據庫溢滿;三是可以看到Log的空間使用情況。

所建Log設備的大小,沒有十分精確的方法來確定。一般來說,對于新建的數據庫,Log的大小應為數據庫大小的30% 左右。Log的大小還取決于數據庫修改的頻繁程度。如果數據庫修改頻繁,則Log的增長十分迅速。所以說Log空間大小依賴于用戶是如何使用數據庫的。此外,還有其它因素影響Log大小,我們應該根據實際操作情況估計Log大小,并間隔一段時間就對Log進行備份和清除。

三、日志的清除

隨著數據庫的使用,數據庫的Log是不斷增長的,必須在它占滿空間之前將它們清除掉。清除Log有兩種方法:

1.自動清除法

開放數據庫選項 Trunc Log on Chkpt,使數據庫系統每隔一段時間自動清除Log。此方法的優點是無須人工干預,由SQL Server自動執行,并且一般不會出現Log溢滿的情況;缺點是只清除Log而不做備份。

2.手動清除法

執行命令“dump transaction”來清除Log。以下兩條命令都可以清除日志:

dump transaction with truncate_only

dump transaction with no_log

通常刪除事務日志中不活躍的部分可使用“dump transaction with trancate_only”命令,這條命令寫進事務日志時,還要做必要的并發性檢查。SYBASE提供“dump transaction with no_log”來處理某些非常緊迫的情況,使用這條命令有很大的危險性,SQL Server會彈出一條警告信息。為了盡量確保數據庫的一致性,你應將它作為“最后一招”。

以上兩種方法只是清除日志,而不做日志備份,若想備份日志,應執行“dump transaction database_name to dumpdevice”命令。

四、管理龐大的事務

有些操作會大批量地修改數據,如大量數據的修改(Update)、刪除一個表的所有數據(Delete)、大量數據的插入(Insert),這樣會使Log增長速度很快,有溢滿的危險。下面給大家介紹一下如何拆分大事務,以避免日志的溢滿。

例如執行“update tab_a set col_a=0”命令時,若表tab_a很大,則此Update動作在未完成之前就可能使Log溢滿,引起1105錯誤(Log Full),而且執行這種大的事務所產生的獨占鎖(Exclusive Table Lock),會阻止其他用戶在執行Update操作期間修改這個表,這就有可能引起死鎖。為避免這些情況發生,我們可以把這個大的事務分成幾個小的事務,并執行“dump transaction”動作。

上例中的情況就可以分成兩個或多個小的事務:

update tab_a set col_a=0 where col_b>x

go

dump transaction database_name with truncate_only

go

update tab_a set col_a=0 where col_b <=x

go

dump transaction database_name with truncate_only

go

這樣,一個大的事務就被分成兩個較小的事務。

按照上述方法可以根據需要任意拆分大的事務。若這個事務需要備份到介質上,則不用“with truncate_only”選項。若執行“dump transaction with truncate_only”命令,應該先執行“dump database”。以此類推,我們可以對表刪除、表插入等大事務做相應的拆分。

主站蜘蛛池模板: 石阡县| 金寨县| 民和| 从江县| 武陟县| 枣庄市| 象山县| 石台县| 南漳县| 汉阴县| 米林县| 文安县| 乐东| 武穴市| 拉萨市| 道孚县| 滨海县| 雷山县| 清镇市| 商洛市| 航空| 城口县| 莒南县| 荥经县| 银川市| 永登县| 吴川市| 辉南县| 曲阳县| 句容市| 镇雄县| 西贡区| 封丘县| 平利县| 军事| 海晏县| 通河县| 克山县| 来安县| 津市市| 富宁县|