一.zabbix agentd的安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
groupadd zabbix
useradd
-g zabbix -G zabbix -s
/sbin/nologin
-d
/dev/null
zabbix
tar
zxvf zabbix-2.2.2.
tar
.gz
cd
zabbix-2.2.2
.
/configure
--prefix=
/data/zabbix
--sysconfdir=
/data/zabbix/conf
--
enable
-agent
make
&&
make
install
cp
misc
/init
.d
/fedora/core/zabbix_agentd
/etc/init
.d/
chmod
755
/etc/init
.d
/zabbix_agentd
vim
/etc/init
.d
/zabbix_agentd
修改BASEDIR=
/data/zabbix
vim
/data/zabbix/conf/zabbix_agentd
.conf
LogFile=
/data/zabbix/log/zabbix_agentd
.log
//
日志的路径
Server=zabbix.
test
.com
//
这里是zabbix server的地址
ServerActive=zabbix.
test
.com:10051
//
同上
Hostname=Node1
mkdir
-p
/data/zabbix/log/
chown
zabbix.zabbix
/data/zabbix/log
service zabbix_agentd start
chkconfig --level 345 zabbix_agentd on
查看是否正常
netstat
-an |
grep
10050
|
二.监控MySQL的复制
原理:利用在slave上运行show slave status获取Slave_IO_Running和Slave_SQL_Running的值
1.在mysql上新建监控用户
1
2
|
grant replication client on *.* to
'zabbix'
@
'localhost'
identified by
'zabbix'
;
flush privileges;
|
2.在/data/zabbix/sbin下新建check_mysql_replication.sh脚本
1
2
|
#!/bin/bash
mysql -uzabbix -pzabbix -e
"show slave status\G"
|
grep
-E
"Slave_IO_Running|Slave_SQL_Running"
|
awk
'{print $2}'
|
grep
-c Yes
|
给上述文件授权
1
|
chmod
+x
/data/zabbix/sbin/check_mysql_replication
.sh
|
3.修改/data/zabbix/conf/zabbix_agentd
.conf
文件
1
2
|
UnsafeUserParameters=1
UserParameter=mysql.replication,
/data/zabbix/sbin/check_mysql_replication
.sh
|
4.重启下zabbix_agemtd服务
1
|
service zabbix_agentd restart
|
三.配置zabbix server
1.在zabbix server上测试,这里zabbix server是安装在/webserver/zabbix,则运行
1
|
/webserver/zabbix/bin/zabbix_get
-s 192.168.100.223 -k
"mysql.replication"
|
如果上面返回的是2,那么是正常(1.mysql的复制正常 2.zabbix_agentd是配置正常),代表Slave_IO_Running和Slave_SQL_Running两个状态都是Yes,这里192.168.100.223是我的slave的IP地址
2.添加监控项目
点击“configuration”,接着点击"Host",然后找到要监控的Slave,点击它的"Items".
2.点击“create items”
3.填写监控项目内容
4.创建Triggers,就是创建mysql.replication到什么时候报警
这个时候我们在Slave机器上,在mysql环境下运行stop slave;
本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1379787