Cacti如何监控Mysql

运维 系统运维
Cacti如何监控Mysql:Cacti和Nagios是现在比较用得多的网络监控软件。cacti偏重于网络流量,系统负载方面的监控。Nagios则比较注重于主机和服务的监控。但是他们详细的区别在哪儿呢。本文讲述的是Cacti如何监控Mysql

  cacti监控mysql数据库的方法

  环境:

  Cactiez或者cacti主机:192.168.12.5

  被监控mysql数据库主机:192.168.5.231

  1. 安装监控插件

  1.   cd /opt  
  2.  
  3.   tar -xzvf mysql-cacti-templates-1.1.2.tar.gz  
  4.  
  5.   cp /opt/mysql-cacti-templates-1.1.2/ss_get_mysql_stats.php /var/www/html/scripts/  
  6.  

  其实里面我们要监控mysql用到的是:acti_host_template_x_db_server_ht_0.8.6i.xml和mysql_definitions.pl

  其他则是监控Apache和Nginx的,接下来我们会介绍到,这里不再详细的讲了。

  1.   chown -R apache.apache /var/www/html/scripts  
  2.  
  3.   chmod -R 755 /var/www/html/scripts  
  4.  

  使用 http 访问 cacti主机 导入

  1. /opt/mysql-cacti-templates-1.1.2/cacti_host_template_x_db_server_ht_0.8.6i.xml  
  2.  
  3. http://192.168.12.5  
  4.  

  默认CactiEZ 和Cacti别是 admin admin

  控制台 - 导入导出 - 模板导入 - 浏览

  选中 cacti_host_template_x_db_server_ht_0.8.6i.xml

  保存

  2. 配置cacti的mysql插件

  修改 ss_get_mysql_stats.php

  1.   vi /var/www/html/scripts/ss_get_mysql_stats.php  
  2.  
  3.   $mysql_user = 'cacti';  
  4.  
  5.   $mysql_pass = 'cacti';  
  6.  
  7.   $cache_dir = "/tmp/cacti/cache/";  
  8.  

  这个账户和密码是 被监控端主机 给 Cacti主机 授权的 账户和密码

  Cacti需要这个账户和密码去连接 被监控机 查询状态

  1.   mkdir -p /tmp/cacti/cache  
  2.  
  3.   chown -R apache.apache /tmp/cacti  
  4.  
  5.   chmod -R 755 /tmp/cacti  
  6.  

  设置 cacti 缓存目录在 /tmp/cacti/cache/ 并给予权限

  3. 配置被监控端(192.168.5.231)的mysql 给 cacti 主机授权

  1.   mysql -uroot -p  
  2.  
  3.   grant process,super on *.* to 'cacti'@'192.168.12.5' identified by 'cacti';  
  4.  
  5.   exit  
  6.  

  grant process,super on *.* to '账户'@'Cacti主机IP地址' identified by '密码';此命令意义

  只允许IP为 192.168.12.5 的主机 以账户 cacti 密码 cacti 去访问 本机数据

  4. 在Cacti主机上(192.168.12.5) 监控Mysql

  4.1 为主机添加mysql模块

  控制台 - 管理 - 设备 - 选中之前创建好的主机

  然后移到最下面的 添加图形模版 选中 Mysql相关模块 然后保存

  4.2 为mysql模块创建图形

  控制台 - 创建 - 创建图形 - 选中该主机 - 选中mysql模块 - 创建

  4.3 插件mysql性能数据

  监视器 - 选中该主机 - 查阅对应的mysql

  完毕

  -----一些数据库操作语句

  1.   mysqld_safe --user=mysql &  
  2.  
  3.   mysql -uroot -p  
  4.  
  5.   mysql -uroot -proot  
  6.  
  7.   grant ALL PRIVILEGES ON *.* to ‘root’@"%" identified by "root" WITH GRANT OPTION;  
  8.  
  9.   exit  
  10.  
  11.   grant select,insert,update,delete on cacti.* to ‘cacti’@”*”identified by "cacti";  
  12.  
  13.   exit  
  14.  
  15.   grant process,super on *.* to 'cacti'@'%' identified by 'cacti';  
  16.  
  17.   grant all privileges on cacti.* to ‘cacti’@"%" identified by "cacti";  
  18.  

  客户端开启Cacti访问本机mysql的权限

  1.   grant process,super on *.* to 'cacti'@'192.168.12.5' identified by 'cacti';  
  2.  
  3.   grant process,super on *.* to 'cacti'@'192.168.5.231' identified by 'cacti';  
  4.  
  5.   = = = = =  
  6.  
  7.   mysql -ucacti -pcacti -h 192.168.5.231  
  8.  

【编辑推荐】

MRTG、Cacti、Rrdtool、Nagios、Zabbix大比拼

Redhat配置nagios-配置linux被监控机

Nagios监控Linux与Windows主机

责任编辑:zhaolei 来源: baidu
相关推荐

2011-04-01 16:29:27

Cacti监控apache

2011-04-01 16:29:23

Cacti监控Tomcat

2011-09-06 10:23:33

2011-09-30 13:04:17

51CTO博客一周热门监控网络

2011-03-29 16:30:06

cacti

2011-03-31 09:36:35

Cacti监控

2011-04-01 16:23:14

Cacti监控Nginx

2011-03-29 15:35:14

cactimemcache

2011-03-25 15:01:26

Cacti监控memcache

2012-02-22 23:17:10

2011-03-24 15:35:01

Cacti

2010-06-17 17:22:30

Cacti 监控Lin

2011-03-24 14:05:17

Cacti监控

2014-04-03 14:05:04

CactiCacti监控

2011-03-31 14:44:55

cactisquid监控

2010-05-26 15:43:45

cacti 监控lin

2011-03-25 09:00:34

Cacti

2011-03-29 11:20:36

Cacti模板MySQL stats

2011-03-25 09:00:36

Cacti插件

2011-03-25 09:00:36

Cacti插件
点赞
收藏

51CTO技术栈公众号