Home Database Mysql Tutorial 数据库错误日志惹的祸

数据库错误日志惹的祸

Jun 07, 2016 pm 05:37 PM
database log mistake

前天接到同事电话:SQL服务器磁盘空间爆满导致数据库无法访问。远程到服务器上,发现原来是SQL错误日志文件惹的祸,数据库在1秒内产生上100M大小的日志,没多长时间就将磁盘空间堵满了。 SQL错误日志记录了数据库运行过程的遇到的各种问题及一些重要信息,作

前天接到同事电话:SQL服务器磁盘空间爆满导致数据库无法访问。远程到服务器上,发现原来是SQL错误日志文件惹的祸,数据库在1秒内产生上100M大小的日志,没多长时间就将磁盘空间堵满了。

SQL错误日志记录了数据库运行过程的遇到的各种问题及一些重要信息,作为排错需要,我们通常都不会主动去清理这些日志文件,只有每次重启服务器时,SQL会自动删除时间最老的日志文件,并新生成一个日志文件。

通过在服务器上查看数据库的日志文件,发现存在大量的query notification dialog的信息,而且出现的频率非常的高,导致日志文件增大非常快。

image

 

通过google了解到这个错误跟service broker的消息机制由关系,,可以通过使用跟踪标记:DBCC TraceOn(4133,-1)可消除此信息。

不过现在的当务之急是如何清掉这些日志信息,最简单的办法就是到SQL的日志目录中删除这些日志文件即可,不过考虑到删除之前需要停止SQL Server服务,可能会导致缓存中的数据丢失,因此,这不是推荐的做法。

那么正确的做法应该怎样呢?

执行如下语句:

EXEC sp_cycle_errorlog;

每执行一次SQL会自动初始化一个日志文件,将日志的内容清空,当SQL有7个日志文件时(默认),请执行7次该操作,每次会将日志文件时间最老那个清空。

读者不必担心清空会消耗很长的时间,我这边的有个日志有40G,命令执行完后,该文件立即清空了。在时间紧急的情况,这种方式尤为方便。

那么有没有办法设置每个日志文件的固定大小呢?

查过这方面的资料,有人说可以在注册表中设置ErrorLogSizeInKb的大小,不过仅限于SQL2012,其他版本的数据库设置后不生效,这个我没有验证过,有兴趣的朋友可以一起讨论下。

 

参考文档:

     

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution to Windows Update prompt Error 0x8024401c error Solution to Windows Update prompt Error 0x8024401c error Jun 08, 2024 pm 12:18 PM

Table of Contents Solution 1 Solution 21. Delete the temporary files of Windows update 2. Repair damaged system files 3. View and modify registry entries 4. Turn off the network card IPv6 5. Run the WindowsUpdateTroubleshooter tool to repair 6. Turn off the firewall and other related anti-virus software. 7. Close the WidowsUpdate service. Solution 3 Solution 4 "0x8024401c" error occurs during Windows update on Huawei computers Symptom Problem Cause Solution Still not solved? Recently, the web server needs to be updated due to system vulnerabilities. After logging in to the server, the update prompts error code 0x8024401c. Solution 1

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How to connect to remote database using Golang? How to connect to remote database using Golang? Jun 01, 2024 pm 08:31 PM

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Performance optimization tips for logging mechanism in Java functions? Performance optimization tips for logging mechanism in Java functions? May 02, 2024 am 08:06 AM

Logging optimization tip: Disable debug logging to eliminate the impact. Batch log messages to reduce overhead. Use asynchronous logging to offload logging operations. Limit log file size to improve application startup and processing performance.

How to handle database connections and operations using C++? How to handle database connections and operations using C++? Jun 01, 2024 pm 07:24 PM

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.

See all articles