Home  >  Article  >  Database  >  使用sp_cycle_errorlog管理SQL Server错误日志

使用sp_cycle_errorlog管理SQL Server错误日志

WBOY
WBOYOriginal
2016-06-07 17:18:071116browse

由于高可用的数据库服务器可能很少停机,SQL Server的日志文件增长会非常大。这样对于DBA使用错误日志查找信息就会比较困难,而且

由于高可用的数据库服务器可能很少停机,SQL Server的日志文件增长会非常大。这样对于DBA使用错误日志查找信息就会比较困难,而且日志大了写入以后性能也会受到影响。 

我们通常认为SQLServer启动的时候才会创建错误日志,所以需要停机才能重新创建日志文件,而这样的维护对于高可用性的数据库是不可想象的。  

其实完全可以不通过重启服务就可以实现日志的循环。 微软提供了一个存储过程

每次启动SQL Server 时,都会将当前错误日志重命名为errorlog.1;errorlog.1 变为errorlog.2,errorlog.2 变为 errorlog.3,依次类推。sp_cycle_errorlog 可使您循环访问错误日志文件,而不必停止和启动服务器。

以下示例将循环 SQL Server 错误日志。

所以你只需要按照自己的需要创建一个JOB定期执行这个存储过程,就可以实现对错误日志的管理。(方便吧)。

linux

Statement:
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