Zabbix的安装与配置
环境:Centos6.5 虚拟机中搭建
zabbix为c/s架构,一台服务器,一台客户端,IP分别为:
192.168.1.14 服务器
192.168.1.15 客户端
1,首先检测一下安装包,如果有没安装的,用yum进行安装,一定记得安装php-fpm
[root@localhost~]# rpm -q mysql-server mysql-devellibcurl-devel net-snmp-devel php php-gd php-xml php-mysql php-mbstringphp-bcmath httpd
2,解压安装包
[root@localhost~]# tar xf zabbix-2.4.6.tar.gz
3,创建用户和组
[root@localhost~]# groupadd zabbix
[root@localhost~]# useradd -g zabbix zabbix
4,创建zabbix数据库,将数据导入
[root@localhost~]# mysql -uroot –p (出示不需要密码)
mysql> createdatabase zabbix character set utf8 collate utf8_bin;
Query OK, 1 rowaffected (0.16 sec)
mysql> grantall on zabbix.* to zabbix@'localhost' identified by 'zabbix';
Query OK, 0 rowsaffected (0.08 sec)
mysql> flushprivileges;
Query OK, 0 rowsaffected (0.02 sec)
[root@localhostmysql]# cd /root/zabbix-2.4.6/database/mysql
[root@localhostmysql]# ls
data.sql p_w_picpaths.sql schema.sql
导入这些数据的时候有先后顺序的,一定是要这个顺序,不然导入的时候会出错,我这个是直接进入到数据库中导入的,全是OK说明导入成功,用show tables;查看一下,下面是两种导入数据的方法,任意一种都行,导入成功就行
mysql> source/root/zabbix-2.4.6/database/mysql/schema.sql
mysql> source/root/zabbix-2.4.6/database/mysql/p_w_picpaths.sql
mysql> source/root/zabbix-2.4.6/database/mysql/data.sql
mysql –uzabbix –pzabbixzabbix < ./ schema.sql
mysql –uzabbix –pzabbixzabbix < ./p_w_picpath.sql
mysql –uzabbix –pzabbixzabbix < ./data.sql
5,下面进行编译安装
[root@localhost~]# cd zabbix-2.4.6
[root@localhostzabbix-2.4.6]# ./configure --prefix=/usr/local/zabbix --enable-server--enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl&& make && make install
6,安装完成之后进行配置
[root@localhost~]#cd /usr/local/zabbix/etc
[root@localhostetc]# cp zabbix_server.conf zabbix_server.conf.bak
将配置文件这些项全部改为如下,有注释掉的取消注释就行
[root@localhost etc]#grep -v '#' zabbix_server.conf|sed '/^$/d'
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/tmp/mysql.sock
7,启动zabbix
[root@localhostetc]# /usr/local/zabbix/sbin/zabbix_server
启动之后用ps –aux查看一下,如果能查看到如下内容说明启动成功
[root@localhost~]# ps -aux |grep zabbix
Warning: badsyntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
zabbix 2313 0.1 0.2 136644 2828 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server
zabbix 2315 0.0 0.1 136644 1556 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:configuration syncer [waiting 60 sec for processes]
zabbix 2316 0.0 0.1 136644 1800 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:db watchdog [synced alerts config in 0.714804 sec, idle 60 sec]
zabbix 2317 0.5 0.3 234508 3428 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:poller #1 [got 0 values in 0.000018 sec, idle 5 sec]
zabbix 2318 0.5 0.3 234508 3428 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:poller #2 [got 0 values in 0.000025 sec, idle 5 sec]
zabbix 2319 0.5 0.3 234508 3428 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:poller #3 [got 0 values in 0.000015 sec, idle 5 sec]
zabbix 2320 0.5 0.3 234508 3428 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:poller #4 [got 0 values in 0.000015 sec, idle 5 sec]
zabbix 2321 0.5 0.3 234508 3428 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:poller #5 [got 0 values in 0.000025 sec, idle 5 sec]
zabbix 2322 0.5 0.3 234508 3428 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:unreachable poller #1 [got 0 values in 0.000019 sec, idle 5 sec]
zabbix 2323 0.0 0.1 136644 1800 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server: trapper #1 [processed data in0.000000 sec, waiting for connection]
zabbix 2324 0.0 0.1 136644 1800 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix 2325 0.0 0.1 136644 1800 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix 2326 0.0 0.1 136644 1800 ? S 17:03 0:00/usr/local/zabbix/sbin/zabbix_server: trapper #4 [processed data in 0.000000sec, waiting for connection]
zabbix 2327 0.0 0.1 136644 1800 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:trapper #5 [processed data in 0.000000 sec, waiting for connection]
zabbix 2328 0.0 0.1 137028 1640 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:icmp pinger #1 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix 2329 0.0 0.1 136644 1780 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:alerter [sent alerts: 0 success, 0 fail in 0.452774 sec, idle 30 sec]
zabbix 2330 0.0 0.1 136644 1556 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:housekeeper [startup idle for 30 minutes]
zabbix 2331 0.0 0.1 136644 1780 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in0.000000 sec, idle 8 sec]
zabbix 2332 0.0 0.1 136644 1796 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:http poller #1 [got 0 values in 0.456791 sec, idle 5 sec]
zabbix 2333 0.5 0.3 234236 3408 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:discoverer #1 [processed 0 rules in 0.066735 sec, idle 60 sec]
zabbix 2334 0.0 0.1 136644 1788 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:history syncer #1 [synced 0 items in 0.000001 sec, idle 5 sec]
zabbix 2335 0.0 0.1 136644 1788 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:history syncer #2 [synced 0 items in 0.000001 sec, idle 5 sec]
zabbix 2336 0.0 0.1 136644 1788 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:history syncer #3 [synced 0 items in 0.000001 sec, idle 5 sec]
zabbix 2337 0.0 0.1 136644 1788 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:history syncer #4 [synced 0 items in 0.000001 sec, idle 5 sec]
zabbix 2338 0.0 0.1 136644 1792 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:escalator [processed 0 escalations in 0.002586 sec, idle 3 sec]
zabbix 2339 0.0 0.1 136644 1796 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:proxy poller #1 [exchanged data with 0 proxies in 0.000003 sec, idle 5 sec]
zabbix 2340 0.0 0.1 136644 1600 ? S 17:03 0:00 /usr/local/zabbix/sbin/zabbix_server:self-monitoring [processed data in 0.000004 sec, idle 1 sec]
root 2361 0.0 0.0 103252 840 pts/1 S+ 17:03 0:00 grep zabbix
8,将web复制到/var/www/html下
[root@localhost~]# cd /var/www/html/
[root@localhosthtml]# mkdir zabbix
[root@localhost~]#cd /root/zabbix-2.4.6/frontends/php
[root@localhostphp]# cp -a * /var/www/html/zabbix/
9,修改php
[root@localhostzabbix]# vim /etc/php.ini
946 date.timezone=Asia/Shanghai
729 post_max_size= 16M
440max_execution_time = 300
449 max_input_time= 300
10,配置现在就配置的差不多了,接下来就可以用浏览器进行访问了
用户名:Admin
密码:zabbix
在组态—主机下面的主机状态和可用性那里,如果Z 这个标志是红色的,说明zabbix的客户端没有起来,你在服务器上启动客户端就行
/usr/local/zabbix/sbin/zabbix_agentd,一会自己会变为绿色,如果要检测别的服务器,则你要检测的服务器必须安装zabbix的客户端
当把字体变为中文之后还有一个问题,就是在监测中不显示字体,
解决办法:
首先在Windows中找到一个字体,下载到桌面,然后在服务器进行如下操作
[root@localhost ]#cd /var/www/html/zabbix/fonts
[root@localhostfonts]# ls
DejaVuSans.ttf
将以前这个随便改一个名字,然后把你在Windows中找的字体上传到这个目录下面,然后把你上传的字体改为DejaVuSans.ttf即可
[root@localhostfonts]# mv DejaVuSans.ttf aaa
[root@localhostfonts]# ls
aaa STXINGKA.TTF
[root@localhostfonts]# mv STXINGKA.TTF DejaVuSans.ttf
[root@localhostfonts]# ls
aaa DejaVuSans.ttf
再刷新浏览器,字体就能显示
监测另外的Linux服务器需要在要监控的服务器上安装zabbix客户端,具体安装如下
1, 解压
[root@localhost~]# tar xf zabbix-2.4.6.tar.gz
[root@localhost~]# cd zabbix-2.4.6
2,编译安装
[root@localhostzabbix-2.4.6]# ./configure --prefix=/usr/local/zabbix --enable-agent
[root@localhostzabbix-2.4.6]# make && make install
3,配置,修改以下内容
[root@localhostzabbix-2.4.6]# cd /usr/local/zabbix/etc/
[root@localhostetc]# cp zabbix_agentd.conf zabbix_agentd.conf.bak
[root@localhostetc]# vim zabbix_agentd.conf
81Server=192.168.1.14
122ServerActive=192.168.1.14
133 Hostname=192.168.1.15
4,启动客户端并查看启动是否成功,查看进程即可
[root@localhostetc]# /usr/local/zabbix/sbin/zabbix_agentd
[root@localhostetc]# ps -aux |grep zabbix
Warning: badsyntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
zabbix 46994 0.0 0.0 17620 716 ? S 19:00 0:00 /usr/local/zabbix/sbin/zabbix_agentd
zabbix 46995 0.0 0.0 17620 748 ? S 19:00 0:00 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 46996 0.0 0.0 17620 980 ? S 19:00 0:00 /usr/local/zabbix/sbin/zabbix_agentd:listener #1 [waiting for connection]
zabbix 46997 0.0 0.0 17620 980 ? S 19:00 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting forconnection]
zabbix 46998 0.0 0.0 17620 980 ? S 19:00 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting forconnection]
zabbix 46999 0.0 0.0 17632 792 ? S 19:00 0:00 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 47182 0.0 0.0 103248 832 pts/0 S+ 19:14 0:00 grep zabbix
客户端安装脚本:
#!/bin/bash
yum install gcc gcc-c++ -y
cd /usr/local/src
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz
tar xf zabbix-2.4.6.tar.gz
cd zabbix-2.4.6
./configure --enable-agent --prefix=/usr/local/zabbix
make install
sed -i 's/127.0.0.1/192.168.1.14/g' /usr/local/zabbix/etc/zabbix_agentd.conf
echo '/usr/local/zabbix/sbin/zabbix_agentd' >> /etc/rc.local
groupadd zabbix
useradd -g zabbix zabbix
/usr/local/zabbix/sbin/zabbix_agentd