CentOS8部署Zabbix

本文详细介绍了在Linux系统中关闭防火墙和SELinux,安装Zabbix服务器、Web组件和Agent,配置MariaDB数据库,创建用户并导入初始架构数据,以及设置Zabbix服务自启动的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、系统修改
1)永久关闭防火墙.
#systemctl disable --now firewalld
2)关闭selinux
#sed -i s/SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config

二、安装Zabbix
#rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm
#dnf clean all
#dnf module switch-to php:7.4

三、安装Zabbix server,web,agent
#dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

四、安装数据库Mariadb10.5以上(Zabbix6.0所需)
#vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.5/centos8-amd64
module_hotfixes=1
gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
安装数据库.
#dnf install MariaDB-server
启动数据库,加入开机自启
#systemctl start mariadb
#systemctl enable mariadb

五、创建并且初始化数据库
#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

[root@boco201 mysql]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.5.23-MariaDB MariaDB Server

Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> drop database zabbix
-> ;
Query OK, 186 rows affected (2.776 sec)

MariaDB [(none)]> drop user zabbix@localhost;
Query OK, 0 rows affected (0.014 sec)

MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.004 sec)

MariaDB [(none)]> create user zabbix@localhost identified by ‘password’;
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.004 sec)

MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.002 sec)

六、导入初始架构和数据
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

八、为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=password

九、启动Zabbix server和agent进程,设置开机自启
#systemctl restart zabbix-server zabbix-agent httpd php-fpm
#systemctl enable zabbix-server zabbix-agent httpd php-fpm

十、首页
http://host/zabbix

十一、其他
10051是zabbix server的端口,10050是anget的端口,3306是Mariadb的端口,80是http的端口
netstat -lntp
默认用户名是Admin,密码是zabbix

### 部署 Zabbix 监控系统于 CentOS 8 #### 添加必要的仓库 由于 Zabbix 并未包含在 CentOS 的默认软件源内[^2],因此需先加入 EPEL 和官方的 Zabbix 软件库以便顺利安装。 ```bash dnf install https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm dnf clean all ``` #### 安装 MySQL 数据库服务器 (MariaDB) 为了存储配置数据和其他持久化信息,建议设置一个数据库服务。这里选用 MariaDB 来作为后端支持: ```bash dnf module enable mariadb dnf install @mariadb systemctl start mariadb.service systemctl enable mariadb.service mysql_secure_installation ``` 创建用于保存 Zabbix 数据的新数据库实例并赋予相应权限给特定用户访问此数据库: ```sql CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY '<password>'; FLUSH PRIVILEGES; EXIT; ``` 初始化该新建立起来的数据表结构以及填充初始所需记录项: ```bash zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix ``` #### 安装 Zabbix Server 及 Agent 组件 通过命令行工具来完成实际的服务组件下载与本地环境构建工作: ```bash dnf install zabbix-server-mysql zabbix-web-mysql zabbix-agent ``` 编辑 `/etc/httpd/conf.d/zabbix.conf` 文件中的 PHP 设置部分以匹配所使用的时区设定. 修改 `/etc/zabbix/zabbix_server.conf` 中有关连接到之前已准备好的数据库的相关参数: ```properties DBName=zabbix DBUser=zabbix DBPassword=<your_password> ``` 启动 HTTPD Web 服务进程及其关联的日志轮转机制,并将其设为开机自启项目之一;同样处理 Zabbix 主程序本身: ```bash systemctl restart httpd php-fpm zabbix-server zabbix-agent systemctl enable httpd php-fpm zabbix-server zabbix-agent ``` 最后一步则是打开浏览器窗口输入目标主机 IP 地址加上路径 `/zabbix` 进入图形界面引导流程直至结束即可正常使用完整的功能特性集了。 对于插件数据源配置方面,则按照具体需求调整对应的 URL、用户名密码等细节选项[^3].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值