centos 7下如何安装zabbix 5.0
环境:
OS:Centos 7
zabbix:5.0.47
1.关闭防火墙
[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
修改安全配置
vi /etc/selinux/config
修改SELINUX=disabled修改配置文件永久关闭。
setenforce 0:临时关闭SELINUX。
2.备份当前的yum源
[root@localhost yum.repos.d]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo ./bak/
3.获取Zabbix 的下载源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
更换成阿里云
sed -i 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
4.安装其他yum源
准备yum源
[root@zabbix-agent yum.repos.d]# cd /etc/yum.repos.d
[root@zabbix-agent yum.repos.d]# more CentOS-7-Aliyun.repo
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[root@zabbix-agent yum.repos.d]# more CentOS-SCLo.repo
[centos-sclo-rh]
name=CentOS-$releasever - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-sclo]
name=CentOS-$releasever - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/sclo/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
# 下载SCLo SIG密钥
curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-SCLo
# 导入rpm密钥库
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
我这里只有这几个yum
[root@zabbix-agent yum.repos.d]# ls
bak CentOS-7-Aliyun.repo CentOS-SCLo.repo zabbix.repo
5.安装zabbix服务端
[root@localhost yum.repos.d]#yum clean all && yum makecache
#下载zabbix连接的服务
[root@localhost yum.repos.d]#yum install zabbix-server-mysql zabbix-agent -y
6.修改zabbix-front前端源参数,把enabled=0改为enabled=1
vi /etc/yum.repos.d/zabbix.repo
7.安装zabbix前端环境,且是安装到scl环境下
[root@localhost yum.repos.d]#yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
8.安装zabbix所需要的数据库,mariadb
[root@zabbix-agent yum.repos.d]# yum install mariadb-server -y
[root@zabbix-agent yum.repos.d]# systemctl enable --now mariadb
[root@zabbix-agent yum.repos.d]# systemctl status mariadb
9.初始化数据库,设置密码
密码设置为 zabbix
[root@zabbix-agent yum.repos.d]# /usr/bin/mysql_secure_installation
10.添加数据库用户,以及zabbix所需要的数据库信息
[root@zabbix-agent yum.repos.d]# mysql -uroot -pzabbix
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
11.使用zabbix-mysql命令,导入数据库信息
[root@zabbix-agent zabbix-server-mysql-5.0.47]#zcat /usr/share/doc/zabbix-server-mysql-5.0.47/create.sql.gz | mysql -uzabbix -pzabbix -D zabbix
12.修改zabbix server 配置文件,修改数据库的密码
vi /etc/zabbix/zabbix_server.conf
DBName=zabbix
### Option: DBSchema
# Schema name. Used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBSchema=
### Option: DBUser
# Database user.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zabbix
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=zabbix
13.为zabbix fronted配置php
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
[root@zabbix-agent zabbix-server-mysql-5.0.47]# more /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
[zabbix]
user = apache
group = apache
listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200
php_value[session.save_handler] = files
php_value[session.save_path] = /var/opt/rh/rh-php72/lib/php/session/
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[date.timezone] = Asia/Shanghai ##修改这里
14.启动zabbix相关服务器
systemctl restart zabbix-server
systemctl restart zabbix-agent
systemctl restart httpd
systemctl restart rh-php72-php-fpm
systemctl restart mariadb
systemctl enable zabbix-server
systemctl enable zabbix-agent
systemctl enable httpd
systemctl enable rh-php72-php-fpm
systemctl enable mariadb
systemctl status zabbix-server
systemctl status zabbix-agent
systemctl status httpd
systemctl status rh-php72-php-fpm
systemctl status mariadb
httpd 80端口被占用的情况下需要进行修改
vi /etc/httpd/conf/httpd.conf
Listen 80
15.浏览器访问
http://192.168.1.108:80/zabbix
默认的账号密码是 Admin/zabbix





设置语言

浙公网安备 33010602011771号