CentOS8 搭建zabbix监控系统
哈喽,有些时间没有更新公众号。今日更新一下。
安装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服务
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示