找回丢失的SQL Server性能计数器

本文介绍了解决SQL Server性能监视器中性能计数器消失的问题。通过修复SQL Server二进制文件或使用命令行工具可以恢复这些计数器。文章详细说明了如何通过命令提示符操作来实现这一目标,并提供了确保计数器正常工作的额外步骤。

There was one time when I was delivering a Service using a tool that gathers performance data through the SQL Server Counters on Performance Monitor, I got surprised when I tried to review the data and there were no information. Them I checked the SQL Server counter directly on Performance Monitor and the counters were not on the list. That’s why I decided to write this blog, to know what to do if the SQL Server counters on Performance Monitor disappears.

The right and easiest way to recover the SQL counters is to repair the SQL Server binaries, trough add/remove programs. However this will require downtime on the SQL instance (If you’re using a cluster you could do a switch-over to another node)

Therefore there’s another option, you could recover this counter executing the following steps:

First you need to open a command prompt console with administrative rights.

Go to the directory BINN on the SQL Instance you want to fix (Ex: C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn)

Now to avoid any inconsistency eliminate any leftovers of the SQL Counters using unlodctr MSSQLSERVER, for named instances use the format MSSQL$NombreInstancia

 

Now to load the counters you should use the following command lodctr perf-MSSQLSERVERsqlctr.ini, if you’re using a named instance you should use this format perf- MSSQL$NombreInstanciasqlctr.ini, you could execute the command twice to check that the counters have been added.

Note:i tried sqlctr.ini,but it doesn't work.then after i tried perf-mssqlserversqlctr.ini,then it worked.

Now you should restart the services Remote Registry and Performance Logs & Alerts, using the followings commands:

net stop "Remote Registry"  &&  net start "Remote Registry"  

net stop "Performance Logs & Alerts"  &&  net start " Performance Logs & Alerts " 

Note:if a counter of mssqlserver :buffer cache hit ratio = 0,restart mssql service,then the value will equal 100.

If you are using the previous procedure to recover the SQL counters on a SQL Server Cluster, you should rebuild the clusters on both nodes, when you are rebuilding the counters an Active SQL Instance must be on the node.

If after you have executed the above steps the SQL Counters have not appear, you will need to review the registry hives and keys (it’s not recommended to do any changes at the registry level, doing so could lead to instability on the operating system. If you chose to do these changes you should have a backup of the Operating System and Registry, to recover it if necessary), the following registry keys should exist and have a valid configuration.

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\<<service name>>\Performance]

Library 
Open 
Collect 
Close 
PerfIniFile

You should also check if there’s a key named Disable Performance Counters insideHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib, if it is configure with the value 1, it should be configure with 0. This should allow you to rebuild the registry counters and help files. 

Now it may or not be necessary to rebuild the SQL and/or Operating System counters, look for the SQL Counters on perfmon, if they aren’t there use the previous steps to rebuild then, with the following command you can rebuild all the operating system counters.

cd %systemroot%\system32

lodctr /R

Another consideration that you should have is when you are executing SQL Server 32 bits on an Windows Server 64 bits environment

I hope this post is helpful, remember there’s a ton of good post on our blog that can help you on many SQL Server topics and how to Troubleshoot some problems. See you on the next post!

 

FROM:http://blogs.technet.com/b/pfelatam/archive/2011/08/08/sql-performance-counters-are-missing.aspx

转载于:https://www.cnblogs.com/dreamer-fish/p/3566277.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值