报警装置
1、设置虚拟机可以连接网络;
##物理机
[root@foundation74 ~]# iptables -t nat -I POSTROUTING -s 172.25.74.0/24 -j MASQUERADE
##7版本的虚拟机
[root@server11 ~]# route add default gw 172.25.74.250
[root@server11 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.25.74.250 0.0.0.0 UG 0 0 0 eth0
172.25.74.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
[root@server11 ~]# vim /etc/resolv.conf ##DNS域名解析
[root@server11 ~]# ping www.baidu.com ##测试网络是否ok;
PING www.baidu.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121: icmp_seq=1 ttl=51 time=56.2 ms
64 bytes from 61.135.169.121: icmp_seq=2 ttl=51 time=54.5 ms
^C
--- www.baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 54.557/55.425/56.293/0.868 ms
2、登陆onleart官网,免费注册帐号;登陆,添加应用zabbix,并获取key;
3、安装onelitsm软件到脚本目录zabbix下:
[root@server11 ~]# tar zxf oneitsm_zabbix_release-1.2.0.tar.gz -C /usr/lib/zabbix/alertscripts
[root@server11 ~]# cd /usr/lib/zabbix/alertscripts
[root@server11 alertscripts]# ls
oneitsm
[root@server11 alertscripts]# cd oneitsm/bin/
[root@server11 bin]# ls
alert.sh install.sh log.sh update.sh
[root@server11 bin]# ./install.sh e9f7ed02-f2b7-9990-3b51-68dd1fe92d6f
./log.sh: line 6: /usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf: No such file or directory
start to create config file...
Zabbix管理地址: http://172.25.74.11/zabbix
Zabbix管理员账号: Admin
Zabbix管理员密码: ##这里的密码是登陆zabbix的用户密码;初始默认的是zabbix,如果有修改,变为自定义的;
start to auth by zabbix admin user and password...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 195 100 70 100 125 587 1049 --:--:-- --:--:-- --:--:-- 1041
auth success!
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 109 100 41 100 68 995 1651 --:--:-- --:--:-- --:--:-- 1658
start to create mediatype...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 356 100 56 100 300 668 3581 --:--:-- --:--:-- --:--:-- 3614
create media type success!
start to create user group...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 214 100 54 100 160 408 1209 --:--:-- --:--:-- --:--:-- 1212
create user group success!
start to create user in zabbix...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 623 100 51 100 572 521 5853 --:--:-- --:--:-- --:--:-- 5896
create user success!
start to create action...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2013 100 51 100 1962 331 12770 --:--:-- --:--:-- --:--:-- 12823
create action success!
安装成功.
注:查看脚本目录zabbix的方法:
[root@server11 zabbix]# vim zabbix_server.conf
4、浏览器设置报警:
(1)停用除了oneitsm之外的所有媒介;
(2)设置报警媒介;
点击配置—> 模块 ——> 搜索mysql ,点击Template Percona MySQL Server ——>触发器,禁用mysql有关slave的监控项;:
(3)测试:
[root@server9 ~]# /etc/init.d/zabbix-agent stop
Shutting down Zabbix agent: [ OK ]
然后在邮箱查看是否收到警告信息;
agent 改被动为主动
下载软件 zabbix-agent-3.4.6-1.el6.x86_64.rpm
(1)文本方式:
server8(新开启一个6.5的虚拟机)
[root@server8 ~]# rpm -ivh zabbix-agent-3.4.6-1.el6.x86_64.rpm
warning: zabbix-agent-3.4.6-1.el6.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... (100########################################### [100%]
1:zabbix-agent ( 6########################################### [100%]
[root@server8 ~]# cd /etc/zabbix/
[root@server8 zabbix]# ls
zabbix_agentd.conf zabbix_agentd.d
[root@server8 zabbix]# vim zabbix_agentd.conf
注:这里的Hostname必须要有本地解析(vim /etc/hosts);
[root@server8 zabbix]# /etc/init.d/zabbix-agent start
Starting Zabbix agent: [ OK ]
[root@server8 zabbix]# netstat -antlp | grep 10050 ##这里我们将agent的被动变为主动,10050端口会消失;
(2)监控平台添加;
1、恢复原来的被动模式:
[root@server8 zabbix]# vim zabbix_agentd.conf
[root@server8 zabbix]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent: [ OK ]
Starting Zabbix agent: [ OK ]
[root@server8 zabbix]# netstat -antlp | grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1109/zabbix_agentd
tcp 0 0 :::10050 :::* LISTEN 1109/zabbix_agentd
浏览器:
点击全克隆:
点击监控项,全选,批量更新:
只选择类型,更新:
创建新的主机;
浏览器查看server8的状态:
proxy代理
下载软件 zabbix-proxy-mysql-3.4.6-1.el6.x86_64.rpm fping-2.4b2-16.el6.x86_64.rpm
(1)删除上一步创建的主机server8:
##server8
[root@server8 zabbix]# /etc/init.d/zabbix-agent stop
Shutting down Zabbix agent: [ OK ]
[root@server8 ~]# yum install mysql-server -y
[root@server8 ~]# /etc/init.d/mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h server8 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@server8 ~]# yum install zabbix-proxy-mysql-3.4.6-1.el6.x86_64.rpm fping-2.4b2-16.el6.x86_64.rpm -y
[root@server8 ~]# cd /etc/zabbix
[root@server8 zabbix]# ls
zabbix_agentd.conf zabbix_agentd.d zabbix_proxy.conf
[root@server8 zabbix]# vim zabbix_proxy.conf
[root@server8 zabbix]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix_proxy character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'westos';
Query OK, 0 rows affected (0.00 sec)
[root@server8 zabbix]# cd /usr/share/doc/zabbix-proxy-mysql-3.4.6/
[root@server8 zabbix-proxy-mysql-3.4.6]# ls
AUTHORS ChangeLog COPYING NEWS README schema.sql.gz
[root@server8 zabbix-proxy-mysql-3.4.6]# zcat schema.sql.gz | mysql -u zabbix -p zabbix_proxy
Enter password:
[root@server8 zabbix-proxy-mysql-3.4.6]# /etc/init.d/zabbix-proxy start
Starting Zabbix proxy: [ OK ]
server9:
[root@server9 ~]# cd /etc/zabbix
[root@server9 zabbix]# vim zabbix_agentd.conf
[root@server9 zabbix]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent: [ OK ]
Starting Zabbix agent: [ OK ]
浏览器:
然后再查看,看server8:server9的状态是否是可用的,如果是,那么监控正常;