Table of Contents
自动化收集SQLSERVER诊断信息
Home Database Mysql Tutorial 自动化收集SQLSERVER诊断信息

自动化收集SQLSERVER诊断信息

Jun 07, 2016 pm 03:44 PM
sqlserver information collect automation diagnosis

自动化收集SQLSERVER诊断信息 相信很多人都遇到过当SQLSERVER出现问题的时候,而你又解决不了需要DBA或者微软售后支持工程师 去帮忙解决问题,那么他们一般需要你收集一些系统信息和SQLSERVER诊断信息。 而收集这些信息又需要图形工具,又需要指令,步骤又非

自动化收集SQLSERVER诊断信息

相信很多人都遇到过当SQLSERVER出现问题的时候,而你又解决不了需要DBA或者微软售后支持工程师

去帮忙解决问题,那么他们一般需要你收集一些系统信息和SQLSERVER诊断信息。

而收集这些信息又需要图形工具,又需要指令,步骤又非常复杂。

我们要按照步骤一步一步把需要的信息收集全,在收集的过程中,往往折腾几次就头痛了


解决问题的工具

这个问题随着一个在SQL2005里的工具的出现而得到了解决

这个工具可以自动收集很多信息,扩展了原来的应用,增强了其信息收集的能力

这个工具就是SQLDIAG.exe    SQL代表:SQLSERVER  DIAG 代表Diagnostic(诊断)

 

SQLDiag这个工具可以收集的信息有:

(1)Windows事件日志

(2)SQLSERVER ErrorLog,以及SQL配置信息,一些重要运行信息

(3)SQL曾经产生的DUMP文件

(4)服务器系统配置信息

(5)同时包含有系统和SQL性能计数器的性能日志

(6)服务器端Trace

 

这个工具可以帮助DBA自动打开服务器端Trace,比用SQLSERVER Profiler要安全多了

因为SQLSERVER Profiler属于客户端跟踪工具,而且需要消耗系统资源跟服务器通信需要

进程间通信,而这个工具用的是服务器端Trace

SQLDiag工具默认安装在:C:\Program Files\Microsoft SQL Server\90\Tools\Binn

C盘是我的SQLSERVER安装路径,大家安装SQLSERVER不是选择默认路径的话可能跟我不一样

 


 

使用工具

 这个工具需要在命令行窗口运行,可以在命令行直接运行\SQLdiag.exe,工具会使用默认的配置,收集系统信息

 把SQLDIAG.exe拖到cmd窗口,按回车键就可以启动了,详细步骤看下图

自动化收集SQLSERVER诊断信息

 

 当出现SQLDIAG Collection started.  Press Ctrl+C to stop. 信息以后就按Crtl+C,终止这个工具的执行。

SQLDIAG 工具会在Binn目录下产生三个XML文件,并且产生一个SQLDIAG子目录,存放刚才收集的信息

 自动化收集SQLSERVER诊断信息

自动化收集SQLSERVER诊断信息

 使用默认配置(即Binn目录下的SQLDiag.xml)只会收到:

(1)SQL errorlog文件内容,以及SQL配置信息和一些重要运行信息(XXXX_sp_sqldiag_Shutdown.out)

(2)SQL曾经产生的dump记录(XXXX_SQLDUMPER_ERRORLOG.log)

(3)服务器系统配置信息(XXXX_MSINFO32.txt)

(4)SQL默认开启的Default Trace文件(log_XXX.trc)

 


使用配置文件

 你可以使用另外两个SQLDiag自带的XML配置文件SD_General.xml 和 SD_Detailed.xml,这两个xml文件跟SQLDiag.exe在同一目录下,

如果使用这两个配置文件就能够收集到SQL Trace和性能日志。

但是如果要使用这两个配置文件所产生的文件就会比较大,放在SQL安装目录下就不再合适,

需要在SQLDiag里指定输出文件路径。

例子 在cmd下输入:

格式:SQLdiag.exe /I /O

我使用SD_General.XML配置文件,配置F:\SQLDIAOUT为输出目录,这个文件夹不用预先创建好,他最帮你自动创建

SQLdiag.exe /I SD_General.XML /O F:\SQLDIAOUT

 自动化收集SQLSERVER诊断信息

 

运行的过程中能够看到SQLdiag开启Perfmon(AddingPerfmon counters)和Trace(Starting Profiler Trace)

当问题跟踪完毕以后,再按Ctrl+C工具会停止日志收集。

有些信息是在工具关闭前收集的,所以可能要等一会才能完全停止

 

 而在目录下 F:\SQLDIAOUT目录,可以看到以下信息

(1)SQL Trace文件(XXXX_sp_trace.trc)

(2)Windows事件日志(XXXX_applog_Shutdown.txt,XXXX_seclog_Shutdown.txt,XXXX_syslog_Shutdown.txt)

(3)Windows性能日志(SQLdiag.blg) 用性能监视器也打不开这个文件,要使用系统自带的小工具

 

 


 

总结

实际上,两个XML配置文件SD_General.xml 和 SD_Detailed.xml的主要区别是SD_Detailed.xml会在SQL Trace里收集更多的事件,

所以输出会要大很多。

DBA可以根据需要选择其中一个

缺点:

SQLdiag的唯一缺点,是不会定期查询系统管理视图DMV,

所以建议自动化信息收集是SQLdiag(使用SD_General.xml 和 SD_Detailed.xml做配置文件),在加上一些

系统动态管理视图作为辅助

 

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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
How to import mdf file into sqlserver How to import mdf file into sqlserver Apr 08, 2024 am 11:41 AM

The import steps are as follows: Copy the MDF file to SQL Server's data directory (usually C:\Program Files\Microsoft SQL Server\MSSQL\DATA). In SQL Server Management Studio (SSMS), open the database and select Attach. Click the Add button and select the MDF file. Confirm the database name and click the OK button.

How to solve the problem that the object named already exists in the sqlserver database How to solve the problem that the object named already exists in the sqlserver database Apr 05, 2024 pm 09:42 PM

For objects with the same name that already exist in the SQL Server database, the following steps need to be taken: Confirm the object type (table, view, stored procedure). IF NOT EXISTS can be used to skip creation if the object is empty. If the object has data, use a different name or modify the structure. Use DROP to delete existing objects (use caution, backup recommended). Check for schema changes to make sure there are no references to deleted or renamed objects.

Comprehensive Guide to PHP 500 Errors: Causes, Diagnosis and Fixes Comprehensive Guide to PHP 500 Errors: Causes, Diagnosis and Fixes Mar 22, 2024 pm 12:45 PM

A Comprehensive Guide to PHP 500 Errors: Causes, Diagnosis, and Fixes During PHP development, we often encounter errors with HTTP status code 500. This error is usually called "500InternalServerError", which means that some unknown errors occurred while processing the request on the server side. In this article, we will explore the common causes of PHP500 errors, how to diagnose them, and how to fix them, and provide specific code examples for reference. Common causes of 1.500 errors 1.

How to check sqlserver port number How to check sqlserver port number Apr 05, 2024 pm 09:57 PM

To view the SQL Server port number: Open SSMS and connect to the server. Find the server name in Object Explorer, right-click it and select Properties. In the Connection tab, view the TCP Port field.

How to recover accidentally deleted database in sqlserver How to recover accidentally deleted database in sqlserver Apr 05, 2024 pm 10:39 PM

If you accidentally delete a SQL Server database, you can take the following steps to recover: stop database activity; back up log files; check database logs; recovery options: restore from backup; restore from transaction log; use DBCC CHECKDB; use third-party tools. Please back up your database regularly and enable transaction logging to prevent data loss.

Where is the sqlserver database? Where is the sqlserver database? Apr 05, 2024 pm 08:21 PM

SQL Server database files are usually stored in the following default location: Windows: C:\Program Files\Microsoft SQL Server\MSSQL\DATALinux: /var/opt/mssql/data The database file location can be customized by modifying the database file path setting.

What to do if the sqlserver service cannot be started What to do if the sqlserver service cannot be started Apr 05, 2024 pm 10:00 PM

When the SQL Server service fails to start, here are some steps to resolve: Check the error log to determine the root cause. Make sure the service account has permission to start the service. Check whether dependency services are running. Disable antivirus software. Repair SQL Server installation. If the repair does not work, reinstall SQL Server.

How to delete sqlserver if the installation fails? How to delete sqlserver if the installation fails? Apr 05, 2024 pm 11:27 PM

If the SQL Server installation fails, you can clean it up by following these steps: Uninstall SQL Server Delete registry keys Delete files and folders Restart the computer

See all articles