centos搭建zabbix

2022-03-29  本文已影响0人  GeekRabbit

前言

Zabbix 是一个企业级分布式开源监控解决方案。Zabbix 软件能够监控众多网络参数和服务器的健康度、完整性。Zabbix 使用灵活的告警机制,允许用户为几乎任何事件配置基于邮件的告警。这样用户可以快速响应服务器问题。Zabbix 基于存储的数据提供出色的报表和数据可视化功能。这些功能使得 Zabbix 成为容量规划的理想选择。

环境

安装MySQL
安装php
安装httpd
安装zabbix

步骤

更新yum源

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

yum clean all

安装php 安装mysql 安装httpd

yum install -y php72w php72w-opcache php72w-xml php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring  

yum install -y httpd

yum install -y mariadb-server mariadb

启动httpd、mariadb服务,并设置成开机自启

systemctl start httpd       //启动httpd

systemctl enable httpd      //设置开机自启

systemctl start mariadb     //启动mysql

systemctl enable mariadb    //设置开机自启

安装zabbix服务端和客户端

yum install zabbix-server-mysql zabbix-agent

安装软件集合

yum install centos-release-scl

编辑配置文件vim /etc/yum.repos.d/zabbix.repo

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1        //0改成1                                                                                                           gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
image.png

安装zabbix前端软件包

yum install zabbix-web-mysql-scl zabbix-apache-conf-scl

创建初始数据库

mysql -u root -p                   //连接数据库

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;      //创建zabbix库
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix';         //创建用户名和密码
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;        //给来自本地的用户zabbix分配可对所有数据库的所有表进行所有操作的权限
MariaDB [(none)]> quit;            

导入初始架构和数据,系统将提示输入新创建的密码

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix


Enter password:        //输入密码zabbix

为zabbix server配置数据库

vim /etc/zabbix/zabbix_server.conf
例子:
### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=zabbix          //删除#,添加密码
image.png

为zabbix前端配置PHP

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

例子:
php_value[max_input_vars] = 10000
; php_value[date.timezone] = Europe/Riga
php_value[date.timezone] = Asia/Shanghai     //最后一行添加时区
image.png

启动zabbix server和zabbix agent,并将它们设置为开机自动启动

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm              //启动zabbix服务端和客户端

systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm               //设置开机自启

输入 http://ip/zabbix

image.png image.png image.png image.png image.png

恭喜你安装成功

安装中遇到的错误

image.png

yum在锁定状态中。
可以通过强制关掉yum进程:

解决方法

rm -f /var/run/yum.pid

创作不易,转载请注明出处
原文链接:https://qu1u1.cn/archives/centos76%E6%90%AD%E5%BB%BAzabbix%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%92%8C%E5%AE%A2%E6%88%B7%E7%AB%AF

上一篇 下一篇

猜你喜欢

热点阅读