Cacti监控mysql数据库服务器实现过程_MySQL

php中文网
发布: 2016-06-01 13:12:49
原创
1580人浏览过

前言: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 ~]#

Android配合WebService访问远程数据库 中文WORD版
Android配合WebService访问远程数据库 中文WORD版

采用HttpClient向服务器端action请求数据,当然调用服务器端方法获取数据并不止这一种。WebService也可以为我们提供所需数据,那么什么是webService呢?,它是一种基于SAOP协议的远程调用标准,通过webservice可以将不同操作系统平台,不同语言,不同技术整合到一起。 实现Android与服务器端数据交互,我们在PC机器java客户端中,需要一些库,比如XFire,Axis2,CXF等等来支持访问WebService,但是这些库并不适合我们资源有限的android手机客户端,

Android配合WebService访问远程数据库 中文WORD版 0
查看详情 Android配合WebService访问远程数据库 中文WORD版

[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连接,如下图所示:

 Cacti监控mysql数据库服务器实现过程_MySQL

然后点击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

相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号