CentOS8 搭建zabbix监控系统

2023-05-18,,

哈喽,有些时间没有更新公众号。今日更新一下。

安装MySQL数据库

# 安装wget
[root@cby ~]# dnf install wget -y
# 下载MySQL源
[root@cby ~]# wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
[root@cby ~]# dnf localinstall mysql80-community-release-el8-1.noarch.rpm -y
# 启用8.0的源
[root@cby ~]# dnf config-manager --enable mysql80-community
[root@cby ~]# dnf install mysql-community-serve
[root@cby ~]# systemctl start mysql
#查看初始密码
[root@cby ~]# sudo grep 'temporary password' /var/log/mysqld.log

登陆数据库并修改密码

[root@cby ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix character set utf8 collate utf8_bin;^C
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Cby123..';
Query OK, 0 rows affected (0.00 sec)

创建用户并授权

mysql> CREATE USER cby IDENTIFIED BY 'Cby123..';
Query OK, 0 rows affected (0.00 sec) mysql> grant all privileges on zabbix.* to 'cby'@'%';
Query OK, 0 rows affected (0.00 sec)

1、安装 Zabbix源信息

[root@cby ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
warning: /var/tmp/rpm-tmp.kiCvdT: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.4-1.el8 ################################# [100%]

2、安装Zabbix server and agent

[root@cby ~]# dnf install zabbix-server-mysql zabbix-agent

3、创建初始数据库

mysql> use zabbix;
Database changed
mysql> source /root/create.sql

4、编辑配置文件 /etc/zabbix/zabbix_server.conf

vim /etc/zabbix/zabbix_server.conf

DBHost=localhost          # 数据主机名
DBName=zabbix            # 数据库实例
DBUser=zabbix              # 用户名
DBPassword=zabbix # 密码

5、编辑配置文件 /etc/httpd/conf.d/zabbix.conf

6、编辑配置文件 /etc/php-fpm.d/zabbix.conf

php_value[date.timezone] = Europe/Riga

7、启动Zabbix server和agent进程,并为它们设置开机自启:

[root@cby ~]# systemctl restart zabbix-server zabbix-agent httpd php-fpm
[root@cby ~]# systemctl enable zabbix-server zabbix-agent httpd php-fpm

8、关闭防火墙

[root@cby ~]#  firewall-cmd --state    #查看默认防火墙状态
not running
[root@cby ~]#  systemctl stop firewalld.service      #临时关闭firewall
[root@cby ~]# systemctl disable firewalld.service   #禁止firewall开机启动

9、编辑Apache的配置文件

[root@cby ~]#  vi /etc/httpd/conf.d/zabbix.conf

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 always_populate_raw_post_data -1

php_value date.timezone Asia/Shanghai

10、设置阿帕奇开机自启

[root@cby ~]# systemctl start httpd     #启动httpd服务
[root@cby ~]# systemctl enable httpd    #设置开机启动httpd服务

CentOS8 搭建zabbix监控系统的相关教程结束。

《CentOS8 搭建zabbix监控系统.doc》

下载本文的Word格式文档,以方便收藏与打印。