Cacti监控mysql数据库服务器实现过程_MySQL
前言:cacti服务器端安装请参考:http://blog.csdn.net/mchdba/article/details/27120605
1 先在cacti服务器端安装mysql模板
wgethttps://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz
tar –xvf better-cacti-templates-1.1.8.tar.gz
cd better-cacti-templates-1.1.8
将better-cacti-templates-1.1.8/scripts下的 ss_get_mysql_stats.php 这个脚本 这个脚本需要放在cacti的服务端。
比如cacti部署在/var/www/html目录下,那么就cp到/var/www/html/cacti/scripts/下
cp
/root/better-cacti-templates-1.1.8/scripts/ss_get_mysql_stats.php/var/www/html/cacti/scripts/
修改ss_get_mysql_stats.php文件 第30行
$mysql_user = 'cacti_user';
$mysql_pass = 'cacti';
$cache_dir = "/xok.la/cacti/cache/";
赋予apache账号操作权限
chown -R apache.apache/var/www/html/cacti/scripts
chmod -R 755 /var/www/html/cacti/scripts
使用http访问cacti主机导入:
/root/better-cacti-templates-1.1.8/templates/cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml
2,建立mysql账号
在被监控的mysql服务器建立数据库的cacti账号,需要PROCESS, SUPER, REPLICATION CLIENT权限,SQL如下:
GRANT PROCESS, SUPER, REPLICATION CLIENT ON*.* TO 'cacti'@'%' IDENTIFIED BY '';
3,在cacti上面添加主机:
3.1点击Create devices
3.2进去之后再点击add按钮,添加主机
3.3 录入描述符和主机名或者IP地址,点击右下角的Create按钮即可。
3.4 界面报错如下:
看到在cacti中添加监控主机时,提示错误“SNMP error”,一般有2种处理办法:
(1),确定cacti所有的主机能ping通被监控主机;如果不能ping通,请确认网络配置和被监控主机的ip设置是否正确。
[root@squid-2 templates]# ping 10.xxx.3.xx
PING 10.254.3.72 (10.254.3.72) 56(84) bytesof data.
64 bytes from 10.xx.3.xx: icmp_seq=1 ttl=64time=0.427 ms
64 bytes from 10.xx.3.xx: icmp_seq=2 ttl=64time=0.389 ms
64 bytes from 10.xx.3.xx: icmp_seq=3 ttl=64time=0.402 ms
64 bytes from 10.xx.3.xx: icmp_seq=4 ttl=64time=0.415 ms
可以ping通,证明不是网络故障。
(2),确认被监控主机是否启用snmpd服务:
[root@xxx ~]# ps -eaf|grep snmpd
root 4540 27133 0 17:15 pts/0 00:00:00 grep snmpd
[root@xxx ~]#
[root@xxx ~]# service snmpd start
snmpd: 未被识别的服务
[root@xxx ~]#
被监控主机需要安装snmpd服务,使用yum -y install snmpd 安装snmpd服务。
[root@db-m2-slave-1 ~]# service snmpdrestart
snmpd: 未被识别的服务
[root@db-m2-slave-1 ~]#
[root@db-m2-slave-1 ~]# yum -y install snmp
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
*base: mirror.neu.edu.cn
*extras: mirror.neu.edu.cn
*updates: mirror.neu.edu.cn
Setting up Install Process
No package snmp available.
Error: Nothing to do
Yum安装不了,试试yum install -y net-snmp,安装成功:
[root@db-m2-slave-1 ~]# yum install -ynet-snmp
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
*base: mirror.neu.edu.cn
*extras: mirror.neu.edu.cn
*updates: mirror.neu.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package net-snmp.x86_641:5.5-49.el6_5.1 will be installed
--> Processing Dependency: net-snmp-libs= 1:5.5-49.el6_5.1 for package: 1:net-snmp-5.5-49.el6_5.1.x86_64
--> Processing Dependency:libsensors.so.4()(64bit) for package: 1:net-snmp-5.5-49.el6_5.1.x86_64
--> Processing Dependency:libnetsnmptrapd.so.20()(64bit) for package: 1:net-snmp-5.5-49.el6_5.1.x86_64
--> Processing Dependency:libnetsnmpmibs.so.20()(64bit) for package: 1:net-snmp-5.5-49.el6_5.1.x86_64
[root@db-m2-slave-1 ~]# service snmpdrestart
停止 snmpd: [失败]
正在启动 snmpd: [确定]
[root@db-m2-slave-1 ~]#
也可以用 service snmpd reload命令来重新加载。
(3),这个时候去看主机状态,正在恢复中:
然后也可以到cacti服务器上,运行snmpwalk来check下:
snmpwalk-c public -v 2c 10.xxx.1.xx # (这个ip10.xxx.1.xx为被监控主机的ip地址)
如果能够接收到被监控机器的数据信息,则表示被监控主机的snmp配置已经完成,没有错误。
4,继续添加被监控主机的画图,增加graphs:
在Console界面右侧,点击Createdevices连接,如下图所示:
然后点击host主机名连接,如下:
然后点击右上角的Create Graphs for this Host 连接

在graphs下面添加tree,点击console,选择左边栏的Graphs Trees,点击右边的Add按钮,输入trees名字,选择排序类型为Natural Ordering,点击Create按钮创建。
之后选择创建好的graphs trees,点击add按钮往trees里面添加database主机,加完如下图:
之后点击最上面的graphs,就会出现
【待续编辑中】
参考:http://blog.csdn.net/hw_libo/article/details/6881480

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

According to news from this website on July 23, ASUS has launched a variety of server and workstation-level products powered by AMD EPYC 4004 series processors. Note from this site: AMD launched the AM5 platform and Zen4 architecture EPYC 4004 series processors in May, offering up to 16-core 3DV-Cache specifications. ASUSProER100AB6 server ASUSProER100AB6 is a 1U rack server product equipped with EPYC Xiaolong 4004 series processor, suitable for the needs of IDC and small and medium-sized enterprises. ASUSExpertCenterProET500AB6 workstation ASUSExpertCenterProET500AB6 is a
