一.服务端安装
1.配置国内源安装
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
yum clean all
2.安装服务端组件
yum install zabbix-server-mysql zabbix-agent zabbix-get zabbix-web-mysql-scl zabbix-apache-conf-scl centos-release-scl -y
3.安装测试数据库
yum install mariadb-server -y
systemctl start mariadb
mysqladmin password
4.登入数据库设置连接账户及库
mysql -uroot -ppassword
create database zabbix character set utf8 collate utf8_bin;#创建库并设定字符集
create user zabbix@localhost identified by 'password';#设置账户及密码
grant all privileges on zabbix.* to zabbix@localhost;#授予账户权限
quit;
OR
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';#创建用户并授权
5.导入初始架构和数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
mysql -uzabbix -pzabbix -e "show tables from zabbix;"#执行此命令可查看是否导入成功
6.为Zabbix server配置数据库
vim /etc/zabbix/zabbix_server.conf#添加zabbix连接数据库,账户密码
grep "^DB" /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
7.重启服务设置开机自动启动
systemctl restart zabbix-server zabbix-agent httpd mariadb
systemctl enable zabbix-server zabbix-agent httpd mariadb
!!!报错
1.server启动失败
查看日志
cat /var/log/zabbix/zabbix_agentd.log
active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to [[127.0.0.1]:10051]: [111] Connection refused)
解决方法
vim /etc/zabbix/zabbix_agent_conf
注释掉ServerActive=127.0.0.1
2.访问通过后依然无法正常启动server端
![SWAP分区未关闭无法启动server.png](https://upload-images.jianshu.io/upload_images/26140018-ea8c8411127b240a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
报错原因
最新版本zabbix-server配置文件起始行开启了swap分区,所以导致zabbix服务端无法启动
解决方法
vim /etc/zabbix/zabbix_server.conf
将swap分区行注释或删除
systemctl restart zabbix-server.service
3.网页无法打开404
报错原因
缺少配置文件
vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
重启httpd服务