环境:VMware centos6.9(su cat /etc/system-release 查看版本),已安装MySQL5.7(非编译安装)/nginx(占用了80端口)
步骤:
1、安装php
添加第三方源(直接yum install安装的话会不能满足zabbix 3.0要求的php最低版本)
su root
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
开始安装
yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
修改配置文件
vi /etc/php.ini
date.timezone = Asia/Shanghai
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
2、安装MySQL(因为已经安装,安装过程就略过了)
安装好之后 mysql -uroot -p,输入密码,进入MySQL命令行,输入:
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* To zabbix@localhost identified by 'test_13572864';
test_13572864 密码根据自己要求设置,后期安装zabbix-server需要)
flush privileges;
3、安装apache
yum httpd libxml2-devel net-snmp-devel libcurl-devel
因为我之前安装了nginx占用了80端口,需要修改apache端口。我设置成了88
vi /etc/httpd/conf/httpd.conf
#Listen 12.34.56.78:80 改成
Listen 88
NameVirtualHost *:80 改成
NameVirtualHost *:88
打开相应端口
iptables -I INPUT -p tcp -m multiport --dports 88 -j ACCEPT
service iptables save &&service iptables restart
4、安装zabbix3.0
groupadd zabbix #创建用户组
useradd -g zabbix -m -s /sbin/nologin #创建用户,并设为不可登陆
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz #下载tar.gz文件
tar -zxvf zabbix-3.0.3.tar.gz #解压
cd zabbix-3.0.3
导入zabbix库
/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
/usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
开始编译安装
./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2
make&make install
(我在这里出现了错误,configure: error: Not found mysqlclient library,把--with-mysql改成--with-mysql=/usr/local/mysql57/bin/mysql_config,重新编译安装就OK了。)
配置zabbix
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost #数据库ip地址
DBName=zabbix
DBUser=zabbix
DBPassword=test_13572864
ListenIP=192.168.174.130,127.0.0.1 # zabbix server ip地址
StartIPMIPollers=10
StartPollersUnreachable=10
StartTrappers=10
StartPingers=10
StartDiscoverers=10
CacheSize=256M
StartDBSyncers=40
HistoryCacheSize=128M
TrendCacheSize=128M
HistoryTextCacheSize=128M
ValueCacheSize=128M
Timeout=30
LogSlowQueries=10000
StartProxyPollers=50
打开相应端口
iptables -I INPUT -p tcp -m multiport --dports 10050:10051 -j ACCEPT
service iptables save &&service iptables restart
复制启动脚本
cp /usr/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_* /etc/init.d/
chmod +x /etc/init,d/zabbix_* #添加可执行权限
sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
配置zabbix web
vi /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
ServerName 192.168.174.130
DocumentRoot "/var/www/html"
添加zabbix web 目录
mkdir -p /var/www/html/zabbix
cp -r /usr/zabbix-3.0.3/frontends/php/* /var/www/html/zabbix/
chown -R apache.apache /var/www/html/zabbix/chkconfig
zabbix_server on/etc/init.d/zabbix_server start
service httpd restart
在主机浏览器中输入192.168.174.130:88/zabbix,并按照提示安装即可