AlimaLinux 9.4 安装Zabbix 7.0LTS_zabbix

Alma Linux 9+Marridb + Nginx 平台

0.初始化配置

替换阿里源

  sed -e 's|^mirrorlist=|#mirrorlist=|g' \
      -e 's|^# baseurl=https://repo.almalinux.org|baseurl=https://mirrors.aliyun.com|g' \
      -i.bak \
      /etc/yum.repos.d/almalinux*.repo
      
      
dnf makecache  

0.1 关闭防火墙

systemctl stop firewalld.service     
systemctl disable firewalld.service   

0.2 关闭selinux

getenforce    
vi /etc/sysconfig/selinux    
     SELINUX=disabled

0.3 更新系统

yum update -y
1.Install and configure Zabbix for your platform
a. Install Zabbix repository 安装zabbix源
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/alma/9/x86_64/zabbix-release-7.0-4.el9.noarch.rpm
dnf clean all


b. Install Zabbix server, frontend, agent 安装zabbix服务端、web前端和agent
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent


c. 安装 Marridb(官网未提及的必须步骤)

vim /etc/yum.repos.d/mariadb.repo

# MariaDB 11.4 RedHatEnterpriseLinux repository list - created 2024-07-18 00:57 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/11.4/rhel/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/11.4/rhel/$releasever/$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
------------------------------------------------------------------
# MariaDB 11.0 RedHatEnterpriseLinux repository list - created 2024-07-18 03:24 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/11.0/rhel/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/11.0/rhel/$releasever/$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
_______________________________________________________________________________________________________
# MariaDB 10.6 RedHatEnterpriseLinux repository list - created 2024-07-18 00:28 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/10.6/rhel/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.6/rhel/$releasever/$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1

dnf makecache

yum -y install mariadb-server mariadb 
#yum remove mariadb-server mariadb 
systemctl start mariadb.service
systemctl enable mariadb.service
netstat -natp | grep 3306
或   ss -natp | grep 3306

注:数据库目录/var/lib/mysql/

d. Create initial database 创建数据库

Make sure you have database server up and running.

Run the following on your database host.

mysql -uroot -p
password 
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;

#查询用户 select * from mysql.user;
#删除用户 drop user zabbix@localhost;

On Zabbix server host import initial schema and data. You will be prompted to enter your newly created password.

导入初始架构和数据

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

Disable log_bin_trust_function_creators option after importing database schema.


mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
e. Configure the database for Zabbix server 为zabbix配置数据库

vim /etc/zabbix/zabbix_server.conf

  1. DBPassword=password
f. Configure PHP for Zabbix frontend 为 zabbix前端配置PHP

vim /etc/nginx/conf.d/zabbix.conf      uncomment and set 'listen' and 'server_name' directives.

取消这两行的注释

  1. # listen 8080;
    # server_name example.com;
g. Start Zabbix server and agent processes

Start Zabbix server and agent processes and make it start at system boot.

systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm
启动zabbix-server报错

The unit zabbix-server.service has entered the 'failed' state with result 'protocol'.

tail -f /var/log/zabbix/zabbix_server.log

 42321:20240718:112327.753 Unable to start Zabbix server due to unsupported MariaDB database version (11.04.02).
 42321:20240718:112327.753 Must not be higher than (11.03.xx).
h. Open Zabbix UI web page

The URL for Zabbix UI when using Nginx depends on the configuration changes you should have made.

http://10.100.1.10:8080/setup.php

配置数据库连接,然后开始使用zabbix。

默认用户名 Admin  密码zabbix


Start using Zabbix

AlimaLinux 9.4 安装Zabbix 7.0LTS_zabbix_02