yum install mariadb-server -y
mysql
create databases zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix’;
flush privileges;
2、创建zabbix用户组
groupadd zabbix -g 201
useradd -M -r -g zabbix -u 201 -s /bin/false zabbix
4、导入zabbix数据库
cd /root/zabbix-*/database/mysql/
[root@localhost mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql [root@localhost mysql]# mysql -uzabbix -pzabbix zabbix < images.sql
[root@localhost mysql]# mysql -uzabbix -pzabbix zabbix < data.sql
5、安装依赖
yum install httpd php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml php-bcmath -y
yum install gcc gcc-c++ net-snmp-devel libssh2 libssh2-devel curl-devel -y
yum install unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel
6、编译安装zabbix
./configure –prefix=/usr/local –sysconfdir=/apps/zabbix –enable-server –with-ssh2 –with-openssl –with-mysql=/usr/local/mysql/bin/mysql_config –enable-ipv6 –with-net-snmp –with-libcurl –with-libxml2 –enable-java
make && make install
同时安装server和agent,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure –enable-server –enable-agent –with-mysql –enable-ipv6 –with-net-snmp –with-libcurl –with-ssh2
如果仅安装server,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure –enable-server –with-mysql –with-net-snmp –with-libcurl
如果仅安装proxy,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure –prefix=/usr –enable-proxy –with-net-snmp –with-mysql –with-ssh2
如果仅安装agent,可使用类似如下配置命令:
./configure –enable-agent
编译常遇到错误
缺少java的开发库:
configure: error: Unable to find “javac” executable in path
解决方法:
yum install java* -y
configure: error: Not found mysqlclient library #yum -y install mysql-devel
configure: error: LIBXML2 library not found #yum -y install libxml2-devel
configure: error: unixODBC library not found # yum -y install unixODBC-devel
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config #yum -y install net-snmp-devel
configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h #yum -y install OpenIPMI-devel
configure: error: Curl library not found #yum -y install curl-devel
7、修改zabbix配置文件
默认zabbix日志在/tmp下,建议更改,我这里更改到了/var/log/zabbix下
mkdir /var/log/zabbix
chown -R zabbix.zabbix /var/log/zabbix/
sed -i s/“# DBPassword=”/DBPassword=zabbix/ /apps/zabbix/etc/zabbix/zabbix_server.conf
sed -i s#”LogFile=/tmp/zabbix_server.log”#”LogFile=/var/log/zabbix/zabbix_server.log”# /apps/zabbix/etc/zabbix/zabbix_server.conf
8、设置启动脚本
cp /usr/local/src/zabbix-*/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
chkconfig –add /etc/init.d/zabbix_server
chkconfig zabbix_server on
9、启动zabbix4.0server
/etc/init.d/zabbix_server start
10、设置php.ini文件
sed -i s/“;always_populate_raw_post_data = -1”/“always_populate_raw_post_data = -1”/ /etc/php.ini
sed -i s/“max_input_time = 60”/“max_input_time = 300”/ /etc/php.ini
/etc/init.d/php-fpm restart
还有几个参数在zabbix步骤里按照报错提示进行修改php.ini
11、设置web
cp -a /usr/local/src/zabbix-/frontends/php/ /var/www/html
12、访问http://IP,进行设置
默认登录帐号为Admin,密码zabbix
登录进去后会有个Zabbix agent on Zabbix server is unreachable for 5 minutes警报,是因为当前server没有运行zabbix-agent
13、安装zabbix4.0-agent
zabbix-agent推荐使用rpm包直接安装
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum install zabbix-agent
systemctl start zabbix-agent
systemctl enable zabbix-agent