1、去zabbix官网下载源码包
wget -O zabbix-3.4.2.tar.gz http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.2/zabbix-3.4.2.tar.gz/download
【建议提前下载好源码包,通过lrzsz或ftp等方式传到主机上】
2、安装依赖库
yum -y install net-snmp-devel libxml2-devel libcurl-devel libevent libevent-devel
3、解压并编译
tar -zxvf zabbix-3.4.2.tar.gz
cd zabbix-3.4.2
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
报错:configure: error: MySQL library not found
需手动指定mysql_config绝对路径 :--with-mysql=/usr/local/mysql/bin/mysql_config
4、安装
make && make install
5、创建zabbix用户和用户组
# groupadd zabbix # useradd -r -g zabbix zabbix
# cd /usr/local && chown -R zabbix:zabbix zabbix
6、创建zabbix数据库,并导入表结构
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to 'zabbix'@'%' identified by "zabbix";
use zabbix;
source /root/zabbix-3.4.2/database/mysql/schema.sql;
source /root/zabbix-3.4.2/database/mysql/images.sql;
source /root/zabbix-3.4.2/database/mysql/data.sql;
7、创建日志目录
# cd /usr/local/zabbix # mkdir logs # chown zabbix:zabbix logs
8、修改zabbix_server.conf
LogFile=/usr/local/zabbix/logs/zabbix_server.log PidFile=/tmp/zabbix_server.pid DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/tmp/mysql.sock Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
9、修改zabbix_agent.conf
# vim ./etc/zabbix_agentd.conf PidFile=/tmp/zabbix_agentd.pid LogFile=/usr/local/zabbix/logs/zabbix_agentd.log Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
10、设置软连接并启动zabbix服务
ln -s /usr/local/zabbix/sbin/zabbix_server /etc/init.d/zabbix_server
ln -s /usr/local/zabbix/sbin/zabbix_agentd /etc/init.d/zabbix_agentd
/etc/init.d/zabbix_server
/etc/init.d/zabbix_agentd
11、拷贝zabbix项目文件至web环境中
cp -r zabbix-3.4.2/frontends/php/ /www/zabbix
chown www.www -R /www/zabbix
12、访问192.168.1.1/zabbix ,初始化安装的默认账号:Admin,密码:zabbix
13、中文乱码解决办法:
①去windows的文字目录如 C:\Windows\Fonts或
②将字体文件上传到web项目zabbix的字体目录 /www/zabbix/fonts/
③将字体重命名test.ttf
④vim defines.inc.php 将define('ZBX_GRAPH_FONT_NAME', '被修改处')改为 test;将define('ZBX_FONT_NAME', ''被修改处')改为test
⑤刷新zabbix图形界面,修改字体成功