安装Zabbix
安装MariaDB
这里用MariaDB演示
https://mariadb.org/download/?t=repo-config&d=Red+Hat+Enterprise+Linux+9&v=10.11&r_m=neusoft
通过这个网址获得连接
选择对应的repo
根据系统版本和要安装的版本选择对应的repo
安装
新建一个repo文件,例如/etc/yum.repos.d/MariaDB.repo, 然后把网站上提供的内容复制进去,例如
# MariaDB 10.11 RedHatEnterpriseLinux repository list - created 2024-02-29 09:14 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.11/rhel/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.11/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
然后就是安装步骤
sudo dnf install MariaDB-server
## 可选步骤,现在mariadb的命令不会自动绑定mysql命令了,所以你现在用mysql -uxxx -p之类的会跟你说命令不存在
sudo ln -s /usr/bin/mariadb /usr/bin/mysql
## 启动并设置自动启动
sudo systemctl start mysql
sudo systemctl enable mysql
至此,MariaD的安装就结束了
安装Zabbix Server
跟着这个网页的命令走,基本不会出什么问题
由于今天我们主要讲Rocky的安装,所以我们这么选
接下来的步骤由于官网写的很详细,我就直接抄下来了,各位可以看一下
Install Zabbix repository
Disable Zabbix packages provided by EPEL, if you have it installed. Edit file /etc/yum.repos.d/epel.repo and add the following statement.
[epel]
...
excludepkgs=zabbix*
Proceed with installing zabbix repository.
# rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm
# dnf clean all
Install Zabbix server, frontend, agent2
# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2
Install Zabbix agent 2 plugins
You may want to install Zabbix agent 2 plugins.
# dnf install zabbix-agent2-plugin-mongodb zabbix-agent2-plugin-mssql zabbix-agent2-plugin-postgresql
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;
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;
Configure the database for Zabbix server
Edit file /etc/zabbix/zabbix_server.conf
DBPassword=password
Start Zabbix server and agent processes
Start Zabbix server and agent processes and make it start at system boot.
# systemctl restart zabbix-server zabbix-agent2 nginx php-fpm
# systemctl enable zabbix-server zabbix-agent2 nginx php-fpm
Open Zabbix UI web page
在Nginx的配置中,zabbix默认使用80端口,但是由于政策限制,其实我们不能使用,所以这边改成8090
vi /etc/nginx/conf.d/zabbix.conf
server {
## 把下面这两句的注释去掉,再修改一下端口
listen 8090;
server_name example.com;
## 重载一下nginx
systemctl reload nginx
然后就可以通过IP:8090 的形式访问到zabbix console了