sqlserver日志采集

[TOC]

当 SQL Server 遇到错误或者性能问题,通常需要采集如下几种日志。待日志全部采集完之后,将 c:\dba 目录打包发给DBA分析

采集 windows event 日志

以下脚本请右键 cmd 以管理员身份运行

mkdir C:\dba
msinfo32 /nfo C:\dba\msinfo32.nfo /categories +systemsummary
wevtutil epl System C:\dba\system.evtx
wevtutil epl Application C:\dba\app.evtx

采集 sql server log 日志

以下脚本请在SQL窗口执行,并将查询出来的目录打包并放到 c:\dba 目录下

DECLARE @param nvarchar(512)
EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\Setup', N'SQLDataRoot', @param OUTPUT
PRINT @param+'\Log'

采集 windows cluster 日志

以下脚本请右键 powershell 以管理员身份运行

Import-Module failoverclusters
Get-ClusterLog -UseLocalTime -Destination c:\dba\

采集 windows cluster 群集日志

此日志的采集方法,请参考如下:

故障转移群集管理器 >> 实例xxx >> 群集网络 >> 将查询另存为 >> c:\dba\cluster.log
Copyright © www.sqlfans.cn 2023 All Right Reserved更新时间: 2022-01-26 10:14:36

results matching ""

    No results matching ""