cacti 监控 mysql
环境:
Cactiez或者cacti主机:192.168.12.5
被监控mysql数据库主机:192.168.5.231
1. 安装监控插件
cd /opt
wget http://mysql-cacti-templates.googlecode.com/files/mysql-cacti-templates-1.1.6.tar.gz
tar -xzvf mysql-cacti-templates-1.1.2.tar.gz
cp /opt/mysql-cacti-templates-1.1.2/ss_get_mysql_stats.php /var/www/html/scripts/
其实里面我们要监控mysql用到的是:acti_host_template_x_db_server_ht_0.8.6i.xml和mysql_definitions.pl
其他则是监控Apache和Nginx的,接下来我们会介绍到,这里不再详细的讲了。
chown -R apache.apache /var/www/html/scripts
chmod -R 755 /var/www/html/scripts
使用 http 访问 cacti主机 导入 /opt/mysql-cacti-templates-1.1.2/cacti_host_template_x_db_server_ht_0.8.6i.xml
http://192.168.12.5
默认CactiEZ 和Cacti别是 admin admin
控制台 - 导入导出 - 模板导入 - 浏览
选中 cacti_host_template_x_db_server_ht_0.8.6i.xml
保存
2. 配置cacti的mysql插件
修改 ss_get_mysql_stats.php
vi /var/www/html/scripts/ss_get_mysql_stats.php
$mysql_user = 'cacti';
$mysql_pass = 'cacti';
$cache_dir = "/tmp/cacti/cache/";
这个账户和密码是 被监控端主机 给 Cacti主机 授权的 账户和密码
Cacti需要这个账户和密码去连接 被监控机 查询状态
mkdir -p /tmp/cacti/cache
chown -R apache.apache /tmp/cacti
chmod -R 755 /tmp/cacti
设置 cacti 缓存目录在 /tmp/cacti/cache/ 并给予权限
3. 配置被监控端(192.168.5.231)的mysql 给 cacti 主机授权
mysql -uroot -p
grant process,super on *.* to 'cacti'@'192.168.12.5' identified by 'cacti';
exit
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
完毕
-----一些数据库操作语句
mysqld_safe --user=mysql &
mysql -uroot -p
mysql -uroot -proot
grant ALL PRIVILEGES ON *.* to ‘ root’@"% " identified by "root" WITH GRANT OPTION;
exit
grant select,insert,update,delete on cacti.* to ‘cacti’@”*”identified by "cacti";
exit
grant process,super on *.* to 'cacti'@'%' identified by 'cacti';
grant all privileges on cacti.* to ‘ cacti’@"% " identified by "cacti";
客户端开启Cacti访问本机mysql的权限
grant process,super on *.* to 'cacti'@'192.168.12.5' identified by 'cacti';
grant process,super on *.* to 'cacti'@'192.168.5.231' identified by 'cacti';
= = = = =
mysql -ucacti -pcacti -h 192.168.5.231
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com