程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SyBase數據庫 >> SyBase綜合文章 >> Sybase數據庫:日志過大導致不能啟動

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

編輯:SyBase綜合文章

問:有個問題問一下,關於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 FilesSybase數據服務器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 FilesSybase數據服務器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進行備份和清除。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved