search
HomeDatabaseMysql Tutorial 1. SQL Server服务器监控实现方法

对于服务器的监控,和对数据库的监控,很少有合二为一的工具,如果有的话,一般是付费软件,或者自行开发的工具。 所以如果不想购买软件,也不想花精力去开发的话,可以结合一些免费/开源的工具、自定义脚本,来完成对数据库服务器的监控。 一. 第三方工具 1

对于服务器的监控,和对数据库的监控,很少有合二为一的工具,如果有的话,一般是付费软件,或者自行开发的工具。
所以如果不想购买软件,也不想花精力去开发的话,可以结合一些免费/开源的工具、自定义脚本,来完成对数据库服务器的监控。

一. 第三方工具
1. 开源工具
比如:CACTI,Nagios,Zabbix等等,除了主机外,对于网络上的其他设备,比如路由器等也可以一并监控。
以CACTI为例(CACTI可以在windows下安装),服务器监控的图示:
(1) 设备状态

(2) SQL Server服务状态

(3) 服务器事件日志

(4) 磁盘空间

(5) 内存使用

(6) CPU使用

(7) 网卡使用

(8) 交换机流量

从图片中可以发现,服务器状态监控没问题,不过对于服务器性能的监控,仅仅是在磁盘空间/内存/CPU/网络带宽的使用量上面,没有细致的性能计数器信息。


这些开源的工具,香港服务器租用,大多基于SNMP协议(Simple Network Management Protocol,简单网络管理协议),该协议用以监测连接到网络上的设备状态,对于设备自身的详细性能参数,通常需要安装额外的插件来完成(这也是unix的思想 ),比如上面用到的syslog插件,用于接收windows事件日志;比如有人集成了snmptools插件,用于接受windows性能计数器信息。

2. 付费工具
不同工具,侧重点也不一样:
(1) 有的偏向主机监控,比如:MOM,SCOM,whatsup gold;
(2) 有的偏向SQL Server数据库监控,比如:Idera SQL Diagnostic Manager,SQL Sentry,Red-gate SQL Monitor;
(3) 有的是工具套件,不同功能选择其中某一款,比如:Quest Spotlight,BMC Patrol(已改名为BMC Performance Manager)


这些Windows平台的工具,大多对性能计数器支持的很好,通常是基于WMI实现的。
WMI :Windows Management Instrumentation,服务器空间,Windows 管理规范,WMI允许通过一个公共的接口访问多种操作系统构成单元,用户可以使用工具软件和脚本程序,调用 WMI 管理本地和远程计算机。


以sql monitor为例,服务器监控的图示:
(1) 有限的windows监控选项

(2) 对性能计数器支持的很直接

二. 性能监视器可以用来做监控吗?
关于性能监控,很多人可能想过在SQL语句里,把性能计数器的值一并读出来,不过从权限/安全的角度来说,SQL Server(应用程序)不应该也不能反向关心windows(操作系统)没有分配给它的资源,所以在sys.dm_os_performance_counters里能查到的也只是SQL Server自己的性能计数器值。不过话说回来,有些DMV/SQL语句确实是可以查看操作系统资源使用情况的,仅限部分,应该是SQL Server自身做了实现,毕竟是自家的东西。


如果想要自己做基于性能计数器的监视,不会使用开发工具,只会写点SQL语句,怎么办?
把性能计数器的日志记录保存出来,导入到数据库里用SQL语句分析,做告警。


1. 如何取性能计数器的值?
(1) 直接查看性能计数器的界面,仅限于查看,无法保存日志记录;
(2) 事先定义一个文件来保存性能计数器,打开性能监视器,里面有这个功能,windows 2003叫counter logs,windows 2008叫data collector,如图:


如果要自动化的话,可以用命令行工具typeperf,功能和图形界面是一样的。

2. 如何分析性能计数器日志?
(1) 直接查看日志,可以借助perfmon/excel/PAL等工具来分析,但这些工具只能帮忙生成图表,不能做自动化,不能做告警;
(2) 导入数据库做分析,可使用 Log Parser/SSIS等任何能自动把性能计数器日志导入数据库的工具,然后利用SQL 语句来做分析,既然是监控,那就得实时点,导入的频率得高些。

第三方工具通常都有页面告警,短信,邮件等等告警方式,如果自己做开发,告警这块也需要自己来实现,通常数据库这端都是用邮件来告警。
设置告警的阀值需要有系统的性能基线,如果不是很确定的话,就设的高一点,至少性能日志已经被记录了,追溯也不是问题。

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
What are stored procedures in MySQL?What are stored procedures in MySQL?May 01, 2025 am 12:27 AM

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

How does query caching work in MySQL?How does query caching work in MySQL?May 01, 2025 am 12:26 AM

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

What are the advantages of using MySQL over other relational databases?What are the advantages of using MySQL over other relational databases?May 01, 2025 am 12:18 AM

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

See all articles

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 Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.