Database error Log Trouble _ database

Source: Internet
Author: User
Tags sql error

Click to have a surprise


The day before yesterday received a colleague phone: SQL Server full disk space caused the database inaccessible. Remote to the server, found that the original SQL error log files caused the trouble, the database in 1 seconds to produce 100M log, not how long will disk space blocked.

SQL error log records the database running process encountered a variety of problems and some important information, as a problem, we usually do not take the initiative to clean up these log files, only every time the server restart, SQL will automatically delete the oldest log files, and new into a log file.

By viewing the database log file on the server, there is a large number of query notification dialog information, and the frequency is very high, causing the log file to grow very quickly.

By using Google to understand that this error is related to the message mechanism of Service Broker, this information can be eliminated through the use of Trace tokens: DBCC traceon (4133,-1).

But now the urgent matter is how to clear out the log information, the easiest way is to go to the SQL log directory to delete these log files, but consider the need to stop the SQL Server service before the deletion, may cause the data loss in the cache, so this is not recommended practice.

So what should be the right thing to do?

Execute the following statement:

EXEC Sp_cycle_errorlog;

Each execution of SQL automatically initializes a log file, empties the contents of the log, and when SQL has 7 log files (the default), perform 7 of the operation, each time emptying the oldest of the log files.

Readers do not have to worry about the empty will take a long time, my side of the log has 40G, after the command execution, the file immediately emptied. In times of emergency, this approach is particularly handy.

So is there a way to set the fixed size of each log file?

Checked this information, some people said that can be set in the registry errorlogsizeinkb size, but only limited to SQL2012, other versions of the database settings do not take effect, this I have not verified, interested friends can discuss together.

Click to have a surprise


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.