How to clear SQL SERVER error logs and see operating system errors

Source: Internet
Author: User
Tags mssqlserver server error log

The SQL SERVER 2008 R2 database set up in The UAT environment has been used normally, but recently it was found that no operation can be performed in Sharepoint, I started to think that something went wrong with the configuration (because I have been studying some new applications and integration and need to be tested constantly), but later I found that the database hard disk is useless, naturally, no data can be stored, so we first began to clean up some useless database logs. the disk space was several GB more, but this was still the case the next day, the hard disk of the database is still full, and the problem persists. The backend carefully checks the capacity of all databases (because it was initially thought that the database space was growing too fast to fill up the hard disk ), I found that the disk space was only a dozen GB, and the total disk space was 126 GB. So I further checked the disk space and found that it was only 30 GB. I was puzzled at the beginning, why is there a shortage of nearly 90 GB? Later, we found that it was the relationship between the original windows Account and the previous login account had limited permissions and could not obtain all the disk space capacity. Therefore, after logging on with the Administrator account, I found that SQL SERVER had an error log capacity of nearly 90 GB, and finally found the reason why the disk is full. The next step is how to solve it.

At first, I listened to my colleagues' suggestions and directly moved the SQL server Error Log file to another hard disk by means of file clipping. After several hours, I finally ended up failing, it indicates that the error log is occupied by the system process and cannot be performed in this brute force mode. Therefore, the system is on the right track and runs through the SQL SERVER maintenance command to clear the 90g error log file, the specific process is as follows:
By default, SQL Server saves seven ErrorLog files named:

ErrorLog
ErrorLog.1
ErrorLog.2
ErrorLog.3
ErrorLog.4
ErrorLog.5
ErrorLog.6

-- Clear the SQL Server Error Log File Archive
EXEC sp_cycle_errorlog
GO

Execute EXEC sp_cycle_errorlog to generate a new errorlog and delete errorlog.6. In this case, the errorlog can be refreshed six times in a first-in-first-out (similar to a queue) loop.

When the following error message is displayed in the query window:

Message 17049, level 16, status 1, process sp_cycle_errorlog, row 9th
Operation System Error '5 (Access denied .) ', The error Log file cannot be recycled from 'C: \ Program Files \ Microsoft SQL Server \ MSSQL10_50.MSSQLSERVER \ MSSQL \ Log \ ERRORLOG.5' to 'C: \ Program Files \ Microsoft SQL Server \ MSSQL10_50.MSSQLSERVER \ MSSQL \ Log \ ERRORLOG.6 '. Processes outside SQL Server may prevent SQL Server from reading these files. Therefore, the error log entries may have been lost and it is impossible to view some SQL Server error logs. Make sure that no other process locks the file as write-only access. "
DBCC execution is complete. If DBCC outputs an error message, contact the system administrator.

Manually delete the 90 GB error log file.
Through this experience, it is also necessary to properly master some SQL server maintenance commands in actual work, and the maintenance of SQL SERVER is relatively simple compared with the mongoel database.

Related Article

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.