[root@zabbix ~]# dnf install epel-release -y
Last metadata expiration check: 0:22:44 ago on Tue 08 Oct 2024 08:48:47 AM CST.
Package epel-release-9-8.el9.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
二、安装zabbix
2.1、添加zabbix仓库
[root@zabbix ~]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
warning: /var/tmp/rpm-tmp.6UZdaU: Header V4 RSA/SHA512 Signature, key ID 08efa7dd: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-6.0-4.el9 ################################# [100%][root@zabbix ~]# dnf clean all39 files removed
# 这条命令是跳过一些无法安装的依赖进行下一步安装[root@zabbix ~]# sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-agent -y --allowerasing --skip-broken
Last metadata expiration check: 0:03:48 ago on Tue 08 Oct 2024 09:15:10 AM CST.
Dependencies resolved.
Problem: package zabbix-web-deps-6.0.34-release2.el9.noarch from zabbix requires zabbix-web =6.0.34-release2.el9, but none of the providers can be installed
- cannot install both zabbix-web-6.0.34-release2.el9.noarch from zabbix and zabbix-web-1:6.0.33-2.el9.noarch from epel
- package zabbix-apache-conf-6.0.34-release2.el9.noarch from zabbix requires zabbix-web-deps =6.0.34-release2.el9, but none of the providers can be installed
- package zabbix-web-mysql-1:6.0.33-2.el9.noarch from epel requires zabbix-web =1:6.0.33-2.el9, but none of the providers can be installed
- cannot install the best candidate for the job
[root@zabbix ~]# dnf install zabbix-web-deps -y --allowerasing
Last metadata expiration check: 0:16:28 ago on Tue 08 Oct 2024 09:15:10 AM CST.
Dependencies resolved.
2.2、配置数据库
[root@zabbix ~]# dnf install mariadb-server -y
Last metadata expiration check: 0:18:31 ago on Tue 08 Oct 2024 09:15:10 AM CST.
Dependencies resolved.
[root@zabbix ~]# systemctl enable --now mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@zabbix ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB![root@zabbix ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.5.22-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)]>
MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'yuan3128..';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
2.3、配置zabbix服务器
[root@zabbix /]# vi etc/zabbix_server.conf[root@zabbix /]# cat etc/zabbix_server.conf# This is a configuration file for Zabbix server daemon# To get more information about Zabbix, visit http://www.zabbix.com############ GENERAL PARAMETERS #################### Option: ListenPort# Listen port for trapper.## Mandatory: no# Range: 1024-32767# Default:# ListenPort=10051### Option: SourceIP# Source IP address for outgoing connections.## Mandatory: no# Default:# SourceIP=### Option: LogType# Specifies where log messages are written to:# system - syslog# file - file specified with LogFile parameter# console - standard output## Mandatory: no# Default:# LogType=file### Option: LogFile# Log file name for LogType 'file' parameter.## Mandatory: yes, if LogType is set to file, otherwise no# Default:# LogFile=LogFile=/var/log/zabbixsrv/zabbix_server.log
### Option: LogFileSize# Maximum size of log file in MB.# 0 - disable automatic log rotation.## Mandatory: no# Range: 0-1024# Default:# LogFileSize=1LogFileSize=0### Option: DebugLevel# Specifies debug level:# 0 - basic information about starting and stopping of Zabbix processes# 1 - critical information# 2 - error information# 3 - warnings# 4 - for debugging (produces lots of information)# 5 - extended debugging (produces even more information)## Mandatory: no# Range: 0-5# Default:# DebugLevel=3### Option: PidFile# Name of PID file.## Mandatory: no# Default:# PidFile=/tmp/zabbix_server.pidPidFile=/run/zabbixsrv/zabbix_server.pid
### Option: SocketDir# IPC socket directory.# Directory to store IPC sockets used by internal Zabbix services.## Mandatory: no# Default:# SocketDir=/tmp### Option: DBHost# Database host name.# If set to localhost, socket is used for MySQL.# If set to empty string, socket is used for PostgreSQL.# If set to empty string, the Net Service Name connection method is used to connect to Oracle database; also see# the TNS_ADMIN environment variable to specify the directory where the tnsnames.ora file is located.## Mandatory: no# Default:# DBHost=localhost### Option: DBName# Database name.# If the Net Service Name connection method is used to connect to Oracle database, specify the service name from# the tnsnames.ora file or set to empty string; also see the TWO_TASK environment variable if DBName is set to# empty string.## Mandatory: yes# Default:# DBName=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=DBPassword=yuan3128..