俺现在正在使用的nagios+cacti组合,没有考虑上zabbix,但领导要求搞搞zabbix,没办法盛情难却。只有先搞了。只是把环境搞起来了。具体使用没怎么研究。测试了添加主机各一台linux和windows,由于使用的云主机。linux还算正常,但是zabbix有个发现规则,找出了很多网卡,禁用又很麻烦。哎,废话不多说了,先搞出来再说。
一 服务端配置
[root@zabbix ~]# cat /etc/redhat-release CentOS release 6.4 (Final) [root@zabbix ~]# service iptables stop iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ] [root@zabbix ~]# chkconfig iptables off [root@zabbix ~]# getenforce Disabled
[root@zabbix ~]# yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear
root@zabbix ~]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gz/download
[root@zabbix ~]# yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI
[root@zabbix ~]# usermod -s /sbin/nologin zabbix
[root@zabbix ~]#tar zxf zabbix-2.0.6.tar.gz [root@zabbix ~]#mysqladmin -u root password 123456 mysql> mysql -p123456 mysql> create database zabbix; mysql> grant all on zabbix.* to zabbix@localhost identified by '123456'; mysql> use zabbix; mysql> source /root/zabbix-2.0.6/database/mysql/schema.sql mysql> source /root/zabbix-2.0.6/database/mysql/images.sql mysql> source /root/zabbix-2.0.6/database/mysql/data.sql mysql> exit
cd /root/zabbix-2.0.6 [root@zabbix zabbix-2.0.6]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl 报错: checking for main in -lmysqlclient... no configure: error: Not found mysqlclient library 解决:[root@zabbix zabbix-2.0.6]# ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib64/mysql/libmysqlclient.so *********************************************************** * Now run 'make install' * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * *********************************************************** make install
[root@zabbix zabbix-2.0.6]# grep -vE '(^#|" "|^)' /usr/local/etc/zabbix_server.conf >> /usr/local/etc/zabbix_server.conf.bak [root@zabbix etc]# cp zabbix_server.conf.bak zabbix_server.conf [root@zabbix etc]# grep -vE '(^#|" "|^$)' zabbix_agentd.conf >> zabbix_agentd.conf.bak [root@zabbix etc]# cp zabbix_agentd.conf.bak zabbix_agentd.conf cp: overwrite `zabbix_agentd.conf'? y [root@zabbix etc]# more zabbix_server.conf #服务端的配置 LogFile=/var/log/zabbix_server.log DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456 [root@zabbix etc]# more zabbix_agentd.conf #客户端配置 LogFile=/tmp/zabbix_agentd.log Server=127.0.0.1 UnsafeUserParameters=1 [root@zabbix etc]# touch /var/log/zabbix_server.log [root@zabbix etc]# touch /var/log/zabbix_agentd.log [root@zabbix etc]# chmod 777 /var/log/zabbix_*
[root@zabbix zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_server /etc/init.d/ [root@zabbix zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/ [root@zabbix zabbix-2.0.6]# chmod +x /etc/init.d/zabbix_* 在文件头部#!/bin/bash下面分别添加两行 #!/bin/sh #chkconfig: 35 95 95 #description:zabbix Agent server 添加服务 [root@zabbix zabbix-2.0.6]# chkconfig --add zabbix_server [root@zabbix zabbix-2.0.6]# chkconfig --add zabbix_agentd 设置服务器开机自动启动 [root@zabbix ~]# chkconfig zabbix_server on [root@zabbix ~]# chkconfig zabbix_agentd on [root@zabbix ~]# /etc/init.d/zabbix_server start Zabbix server started. [root@zabbix ~]# /etc/init.d/zabbix_agentd start Zabbix agent started. [root@zabbix ~]# ps -ef |grep zabbix zabbix 1803 1 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd zabbix 1805 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd zabbix 1806 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd zabbix 1807 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd zabbix 1808 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd zabbix 1814 1 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_server root 2043 2006 0 08:23 pts/0 00:00:00 grep zabbix [root@zabbix ~]# netstat -lantp |grep 10050 tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1803/zabbix_agentd [root@zabbix ~]# netstat -lantp |grep 10051 tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2308/zabbix_server
[root@zabbix zabbix-2.0.6]# cp -r frontends/php /var/www/html/zabbix [root@zabbix html]# /etc/init.d/httpd restart #启动apache服务 Stopping httpd: [ OK ] Starting httpd: [ OK ]
[root@zabbix zabbix]# vi /etc/php.ini [Date] ; Defines the default timezone used by the date functions ; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone date.timezone = Asia/Shanghai [root@zabbix zabbix]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
报错:根据提示修改/etc/php.ini文件里的参数
[root@zabbix zabbix]# yum install -y php-bcmath [root@zabbix zabbix]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
搞定。。下面是改成中文,虽然翻译的不是很好,看着亲切啊。
二.WINDOWS客户端安装
1.官网上下载windows客户端zabbix
4.安装zabbix客户端
三.服务端测试
[root@10-6-8-200 ~]# zabbix_get -s 10.6.1.126 -k agent.ping 1
测试OK