0
点赞
收藏
分享

微信扫一扫

Centos8部署Zabbix6.0(一)

古月无语 2022-04-06 阅读 168

文章目录


前言

手动搭建Zabbix-Server(192.168.137.132)与Zabbix-Agent(192.168.137.134)。

技术版本
CentOS8.0
Zabbix6.0

一、Zabbix-Server安装流程

1.关闭防火墙

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/enforcing/permissive/g" /etc/selinux/config

2.换源

cd /etc/yum.repos.d
rm -rf *
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all
yum makecache

3.安装依赖包

yum install scl-utils-* apr-* rsync lsof perl-DBD-MySQL socat php-bcmath php-xml php-ldap php-json php-gd php-mysqlnd php-mbstring php-fpm php-bcmath OpenIPMI httpd net-snmp-* boost-program-options-* createrepo unzip  -y

3.安装Zabbix存储库

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
dnf clean all

4.安装Zabbix server与Web前端

dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy

5.配置数据库

1.引入mariadb源

cat <<EOF > /etc/yum.repos.d/mariadb.repo
# MariaDB 10.6 CentOS repository list - created 2022-01-16 15:10 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirrors.cloud.tencent.com/mariadb/yum/10.6/centos8-amd64
module_hotfixes=1
gpgkey=https://mirrors.cloud.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

2.安装数据库

dnf -y install mariadb-server

3.启动数据库并设置开机自启

systemctl start mariadb && systemctl enable mariadb

4.初始化数据库

mariadb-secure-installation

5.授权数据库

mysql -uroot -p    #此处我直接回车未定义密码
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password'; #此处我定义密码为password
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;

6.导入初始架构和数据

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
#输入密码:password

此时执行下述命令查看数据库,可见架构与数据均已导入

mysql -u root -p
> use zabbix;
> show tables;

在这里插入图片描述

7.为Zabbix server配置数据库

vim /etc/zabbix/zabbix_server.conf
DBHost=localhost #去掉注释
DBPassword=password #去掉注释并填入password

在这里插入图片描述

6.配置php

vim /etc/php.ini

post_max_size = 16M #由8M改为16M
max_execution_time = 300 #由30改为300
max_input_time = 300 #由60改为300

7.配置nginx

vim /etc/nginx/conf.d/zabbix.conf

listen 80; #去掉注释
server_name example.com; #去掉注释

在这里插入图片描述

cp -r /usr/share/zabbix/ /usr/share/nginx/html/   #复制主目录

8.安装中文包

dnf install langpacks-zh_CN.noarch    # 安装zh_CN语言包
dnf -y install glibc-common # 安装glibc-common实现对语言包的识别
# locale -a | grep zh_CN
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8

9. 启动服务并设置开机自启

systemctl restart zabbix-server nginx php-fpm
systemctl enable zabbix-server nginx php-fpm

10.访问页面

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

密码为password
在这里插入图片描述

在这里插入图片描述
账号:Admin 密码:zabbix
在这里插入图片描述

二、Zabbix-Agent安装流程

1.修改主机名

server: hostnamectl set-hostname zabbix-server
agent: hostnamectl set-hostname zabbix-agent

2.关闭防火墙

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/enforcing/permissive/g" /etc/selinux/config

3.换源

cd /etc/yum.repos.d
rm -rf *
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all
yum makecache

4.安装Zabbix存储库

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
dnf clean all

5.安装Zabbix-Agent

dnf -y install zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
> Server=192.168.137.132 # 更改为当前服务端的ip

systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service

在这里插入图片描述

三、Zabbix-Server配置连接Agent

1.创建新的主机群组

在这里插入图片描述
在这里插入图片描述

2.创建新的模板

在这里插入图片描述
在这里插入图片描述

3.创建新的主机

在这里插入图片描述
在这里插入图片描述


四、报错总结

1.源错误

1.错误表现:yum安装软件包时报错

2.错误原因

源错误,因国内无法访问外网。

3.解决方案

换源,将原先在/etc/yum.repos.d中的源删干净,换成阿里源。具体操作上面有写。

2.aes192错误

1.错误表现:Zabbix启动失败,报错如下:

2.错误原因

由于使用系统镜像中的net-snmp-libs-5.8.14安装包,不支持usmAES192 privacy protocol,所以导致zabbix-server启动失败。
在这里插入图片描述

3.解决方案

提前安装依赖,

yum install net-snmp-* -y

将net-snmp版本提升为5.8.22就不会报错
在这里插入图片描述

3.nginx报错

1.错误表现:zabbix-server启动正常,但前端http://localhost/zabbix不显示zabbix安装页面。

2.错误原因

zabbix找不到主页

3.解决方案

五、待解决问题-server与agent连接问题

在server查看端口号时发现agent呈TIME_WAIT状态
在这里插入图片描述

且监控可用性为灰色在这里插入图片描述
同时在server端测试时连接不上agent
在这里插入图片描述

总结

首先感谢各位师傅的文章:

以下个人两点总结:

2020年12月的Linux服务器课程设计第一次接触Zabbix,一年多后整理并重新做了这个实验。一年前实验的版本是RedHat6.0+Zabbix2.4,这次来了个“全新大升级”。一年过去,不变的是一直在跳坑的路上,希望能彻底搞懂Zabbix,希望自己越来越棒。
2022年4月6日于家中

举报

相关推荐

0 条评论