参考官方网站https://www.zabbix.com/和互联网实现zabbix的安装及问题解决。
环境:
OS Version: CentOS 8.1.1911
DATABASE: Mysql-common-8.0.17
WEB SERVER: Nginx-1.14.1
安装步骤:
一、关闭防火墙和SElinux,为了可以正常访问zabbix server网页
临时关闭防火墙
systemctl stop firewalld
永久关闭防火墙
[root@localhost ~]# systemctl disable firewalld
临时关闭Selinux
setenforce 0
永久关闭Selinux,编辑/etc/selinux/config,设置参数SELINUX=disabled
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
二、安装Zabbix server
1. 官方文档安装Zabbix仓库
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
dnf clean all
2. 官方文档安装Zabbix server, 前端, 客户端
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-agent
在我的网络环境下,不能顺利完成所有依赖包的安装。
将安装源修改为国内下载源,修改/etc/yum.repos.d/zabbix.repo文件,设置为华为开源镜像地址:https://mirrors.huaweicloud.com/zabbix/
[root@localhost ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.huaweicloud.com/zabbix/zabbix/4.4/rhel/8/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.huaweicloud.com/zabbix/non-supported/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
清理并生成新的cache
dnf clean all
dnf makecache
再次执行dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-agent
依然无法完成安装,提示缺少依赖包libssh2
手动安装dnf -y install http://mirror.centos.org/centos/8.0.1905/AppStream/x86_64/os/Packages/libssh2-1.8.0-8.module_el8.0.0+189+f9babebb.1.x86_64.rpm
我们再次执行dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-agent
顺利完成安装
3.创建初始化数据库
进入mysql创建数据库zabbix,创建数据库用户zabbix并进行授权。
#mysql -u root -p
mysql root password
mysql> create database zabbix character set utf8 collate utf8_bin;mysql> create user 'zabbix'@'localhost' identified by 'password';
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
mysql> flush privileges;
4. 导入初始化结构和数据库,并输入你设置的密码password
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
5. 配置Zabbix server的数据库,编辑 /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=
password
6. 配置PHP for Zabbix前端,编辑文件/etc/nginx/conf.d/zabbix.conf, 取消注释 并设置 'listen' 和 'server_name' 参数。
listen 80;
server_name server_ip;
7. 编辑/etc/php-fpm.d/zabbix.conf, 取消注释并设置正确的时区。
php_value[date.timezone] = Asia/Shanghai
8. 启动Zabbix server和agent进程,设置开机启动。
# systemctl restart zabbix-server zabbix-agent nginx php-fpm
# systemctl enable zabbix-server zabbix-agent nginx php-fpm
9. 配置Zabbix前端。
浏览器访问 http://server_ip,进行初始化的设置。
账号和密码区分大小写,初始账号:Admin,初始密码:zabbix