zabbix安装是一项很基础简单的工作,但有的时候常常会碰到比较奇葩的问题。装完agent获取不到被监控端数据(错误找到半,也是够了。特意留个笔记在此)
安装zabbix相关软件:
yum -y install make gcc httpd mysql-server mysql-devel net-snmp-devel libcurl-devel php php-mysql php-bcmath php-mbstring php-gd php-xml
添加zabbix用户:
useradd -M -s /sbin/nologin zabbix
启动mysql数据库:
/etc/init.d/mysqld start
进入mysql创建数据库并授权用户:
create database zabbix character set utf8;
grant all privileges on zabbix. to zabbix@localhost identified by 'passwod';
下载zabbix源码包:
wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.4/zabbix-2.2.4.tar.gz
解压安装:
tar zxvf zabbix-2.2.4.tar.gz
cd zabbix-2.2.4
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
make install
cd /usr/local/zabbix-2.2.4/
导入数据库:
mysql -uzabbix -ppasswd zabbix < zabbix2.2.4/database/mysql/schema.sql
mysql -uzabbix -ppasswd zabbix < zabbix2.2.4/database/mysql/images.sql
mysql -uzabbix -ppasswd zabbix < zabbix2.2.4/database/mysql/data.sql
复制启动脚本至/etc/init.d目录:
cp misc/init.d/fedora/core/zabbix_
/etc/init.d/
复制php网页数据:
cp frontends/php/ /var/www/html/zabbix
修改各项文件:
sed -i '/^DBUser=/s/=./=zabbix/;/DBPassword=/s/$/\n\nDBPassword=zabbix/' /usr/local/zabbix/etc/zabbixserver.conf
sed -i '/BASEDIR=/s/$/\/zabbix/' /etc/init.d/zabbix

sed -i '/^DirectoryIndex/s/$/ index.php/' /etc/httpd/conf/httpd.conf
sed -i '/^post_max_size/s/= ./= 16M/;/^max_execution_time/s/= ./= 300/;/^max_input_time/s/= ./= 300/;/^;date.timezone/{s/;//;s/$/ Asia\/Shanghai/}' /etc/php.ini
sed -i '/^post_max_size/s/= .
/= 16M/;/^max_execution_time/s/= ./= 300/;/^max_input_time/s/= ./= 300/;/^;date.timezone/{s/;//;s/$/ Asia\/Shanghai/}' /etc/php.ini
启动服务:
/etc/init.d/zabbix_server restart
/etc/init.d/httpd restart
安装 agentd:
创建用户:
groupadd zabbix -g 201
useradd -g zabbix -u 201 -m zabbix
tar -xf zabbix-2.2.4.tar.gz
cd zabb-2.2.4
./configure --prefix=/usr --sysconfdir=/etc//zabbix --enable-agent
make
make install
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod 755 /etc/init.d/zabbix_agentd
sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentd
vim /etc/services
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trappe
修改/etc/zabbix/zabbix_agentd.conf:
Server=127.0.0.1,服务端IP
ServerActive=服务端IP:10051
启动服务:
/etc/init.d/zabbix_agentd start