构建监控系统-1-zabbix部署
创始人
2025-05-30 05:57:29
0

优化的点??

  • zabbix 宏定义???
  • 查看历史区间数据,自动加监控???
  • 批量添加主机???
  • 安装客户端自动化???
  • 网络程序交付,变更发布系统???
  • 网络排查链路公告割接故障诊断系统?预警系统?

监控项

配置告警声音

在这里插入图片描述

⭐️ 自定义监控

1️⃣脚本获取值
2️⃣ zbx格式,配置文件、创建键值: 键值key获取客户端数据
3️⃣ 重启客户端,服务端测试键值可用
4️⃣ web键值关联

监控脚本插件

[root@bzy2c8nnb0dtlnbi plugins.d]# grep -i include= /etc/zabbix/zabbix_agent2.conf
# Include=
Include=/etc/zabbix/zabbix_agent2.d/*.conf
# Include=/usr/local/etc/zabbix_agent2.userparams.conf
# Include=/usr/local/etc/zabbix_agent2.conf.d/
# Include=/usr/local/etc/zabbix_agent2.conf.d/*.conf
Include=./zabbix_agent2.d/plugins.d/*.conf

编写:

vi /etc/zabbix/zabbix_agent2.d/web.conf
#UserParameter=key,cmd
#UserParameter=check.django,ps -ef | grep /usr/local/bin/python3 | grep 80 | wc -l
UserParameter=check.django,ss -lntup| grep -w *:80  | wc -l
重启客户端
systemctl restart zabbix-agent2
客户端本地测试
[root@bzy2c8nnb0dtlnbi zabbix_agent2.d]# zabbix_agent2 -t check.django
check.django                                  [s|3]

agent 监控项

在这里插入图片描述

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

Server=192.168.3.101 #被动模式,指定zabbix-server服务端的ip地址,多个ip的话使用逗号分隔

ServerActive=192.168.3.101 #主动模式,指定zabbix-server的ip地址,使用逗号分隔多IP,如果注释这个选项,那么当前服务器的主动监控就被禁用了

Hostname=itops-server #当使用主动模式时,这个名称的设置必须与zabbix-web监控页面创建的主机名称保持一致

修改完后重启zabbix agent使服务生效

service zabbix_agent restart

配置

在这里插入图片描述
zbx 不绿,客户端配置server 是否配置,本地10050端口是否启动
在这里插入图片描述

制作镜像

docker commit -m 'zabbix6.0登录' -a="haogeoyes" zabbix1 zabbix:v1

问题

登录语言

参考文档
Locale for language “en_US” is not found on the web server. Tried to set: en_US, en_US.utf8,

语言选择:
You are not able to choose some of the languages, because locales for them are not installed on the web server.
配置中文:
dnf install langpacks-zh_CN.noarch
dnf install glibc-common
locale -a | grep zh_CN

字体设置

在这里插入图片描述
mac 参考文档

scp /Library/Fonts/Songti.ttc   root@xx:/tmp
cp /tmp/Songti.ttc /root/zabbix/
cd /usr/share/zabbix/assets/fonts/
mv graphfont.ttf  graphfontbak.ttf
cp /root/zabbix/Songti.ttc
mv Songti.ttc  graphfont.ttf

zabbix 启动未就绪

查看日志 /var/log/zabbix/zabbix_server.log

"vm.memory.size[total]" on host "Zabbix server" failed: first network 

centos8 安装zabbix6.0

docker pull centos:centos8
6.0 centos8 官方安装文档
docker run --name zabbix1 -t -d -p 8100-8199:8100-8199 -v /root/zabbix:/root/zabbix --privileged=true centos:centos8 /usr/sbin/init

7000-8000:7000-8000

yum 安装

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpmcurl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repomv *repo /bak/dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent不行,需要使用官方源
vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.5/centos8-amd64/
gpgkey = http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDb
gpgcheck = 1
enabled = 1官方源
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1[root@b87815deda95 yum.repos.d]# systemctl start mariadb
[root@b87815deda95 yum.repos.d]# systemctl enable mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@b87815deda95 yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.19-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.000 sec)MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> quit;
Bye
[root@b87815deda95 yum.repos.d]# ls /usr/share/zabbix-sql-scripts/mysql/server.sql.gz
/usr/share/zabbix-sql-scripts/mysql/server.sql.gz
[root@b87815deda95 yum.repos.d]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password:[root@b87815deda95 yum.repos.d]# mysql -uroot -p
MariaDB [(none)]> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> quit;

centos8 安装mariadb 10.5参考文档

修改 /etc/zabbix/zabbix_server.conf

vi /etc/zabbix/zabbix_server.conf
DBPassword=zabbix

修改 /etc/nginx/conf.d/zabbix.conf

listen 8180;
server_name zabbix;

启动

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

页面初始化 http://14.29.251.xx:8180/

在这里插入图片描述
web登录默认用户名 Admin 密码 zabbix

清理缓存参考


更新缓存
dnf clean all  
dnf makecache  
dnf repolistdnf search mariadb
查看版本
dnf search mariadb-server --showduplicates  --disablerepo=AppStream
dnf -y install MariaDB-server-debuginfo-10.5.17-1.el8.x86_64rpm -qa | grep -i mariadb
systemctl enable mariadb
systemctl start mariadb

从新部署

http://mirrors.aliyun.com/
阿里yum源检索
zabbix 6.0在centos7里只能按客户端
nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/releasever/releasever/releasever/basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release.noarch -y
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php72w-cli php72w-fpm php72w-gd php72w-mbstring php72w-bcmath php72w-xml php72w-ldap php72w-mysqlnd
yum install -y nginx

rpm -qa | egrep ‘nginx|php’
rpm -qa | egrep ‘nginx|php’ | wc -l
11
配置
vi /etc/nginx/conf.d/nginx.conf
server {
listen 80;
server_name nginx;
root /root/zabbix;
location / {
index index.php;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /app/code/zbx$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME documentrootdocument_rootdocumentr​ootfastcgi_script_name;
include fastcgi_params;
}
}

修改php配置
匹配 user/group开头的apache替换为nginx
sed -ri ‘/^(user|group)/s#apache#nginx#g’ /etc/php-fpm.d/www.conf
egrep ‘^(user|group)’ /etc/php-fpm.d/www.conf

/root/zabbix/info.php

systemctl start nginx php-fpm
systemctl enable nginx php-fpm

访问测试

http://xx/info.php
curl http://127.0.0.1/info.php

工具测试

yum provides */netstat

报错nginx 403

检查日志

检查日志
/var/log/nginx/error.log
023/03/18 00:02:04 [error] 1413#1413: *1 open() “/root/zabbix/favicon.ico” failed (13: Permission denied), client: 125.121.41.124, server: nginx, request: “GET /faviconn
.ico HTTP/1.1”, host: “14.29.251.27:8051”, referrer: “http://14.29.251.27:8051/info.php”
增加权限xxx
注意:修改权限为root
vi /etc/nginx/nginx.conf
user root

报错

File not found.

部署数据库

zabbix 6.0 不支持mariadb 5.5 默认源10.5以上
马瑞亚db

配置源

vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.5/centos7-amd64/
gpgkey = http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDb
gpgcheck = 1
enabled = 1

yum install mariadb-server -y

rpm -qa | grep -i mariadb
systemctl enable mariadb
systemctl start mariadb

配置

数据库初始化
mysql_secure_installation
回车
n
其他全y
修改密码 root
在这里插入图片描述

创建用户

  • 指定字符集中文乱码
    create database zabbix charset utf8 collate utf8_bin;
  • 创建用户密码zabbix
    grant all on zabbix.* to ‘zabbix’@‘localhost’ identified by ‘zabbix’;
    授权其他地址
    grant all on zabbix.* to ‘zabbix’@‘xx.xx.xx.%’ identified by ‘zabbix’;
    向数据库导入数据
    ⚠️ 导入顺序

在这里插入图片描述

在这里插入图片描述

下载源码

https://www.zabbix.com/download_sources#60LTS

curl -O https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.14.tar.gz zabbix-6.0.14.tar.gz
tar zxvf  zabbix-6.0.14.tar.gz
cd zabbix-6.0.14/database/mysql/
[root@857cd8bba2b3 mysql]# ls
Makefile.am  Makefile.in  data.sql  double.sql  history_pk_prepare.sql  images.sql  schema.sql
[root@857cd8bba2b3 mysql]# mysql -uroot -proot zabbix < schema.sql
[root@857cd8bba2b3 mysql]# mysql -uroot -proot zabbix < images.sql
[root@857cd8bba2b3 mysql]# mysql -uroot -proot zabbix < data.sql
[root@857cd8bba2b3 mysql]# mysql -uroot -proot zabbix < double.sql
[root@857cd8bba2b3 mysql]# mysql -uroot -proot zabbix < history_pk_prepare.sql

编译安装

cd zabbix*
yum install -y mysql-devel pcre-devel openssl-devel zlib-devel libxml2-devel net-snmp-devel net-snmp libssh2-devel OpenIPMI-devel libevent-devel openldap-devel libcurl-devel./configure
make install ./configure  --sysconfdir=/etc/zabbix/ --enable-server --with-mysql --with-net-snmp --with-libxml2 --with-libxml2 --with-ssh2 --with-openipmi --with-zlib --with-libpthread --with-libevent --with-openssl --with-ldap --with-libcurl --with-libpcremake install
echo $?
  • 报错 configure: error: no acceptable C compiler found in $PATH
    yum -y install gcc.x86_64
./configure  默认/usr/local下
--sysconfdir=/etc/zabbix/  指定配置文件目录
--enable-server  安装服务端 -client
--with-mysql  开启对mysql的支持
依赖功能
--with-net-snmp --with-libxml2 --with-libxml2 --with-ssh2 --with-openimpi --with-zlib --with-libpthread --with-libevent --with-openssl --with-ldap --with-libcurl --with-libpcre
Configuration:Detected OS:           linux-gnuInstall path:          /usr/localCompilation arch:      linuxCompiler:              ccCompiler flags:         -g -O2Library-specific flags:database:              -I/usr/include/mysql -I/usr/include/mysql/mysqllibpcre:libXML2:               -I/usr/include/libxml2Net-SNMP:               -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/includeOpenIPMI:              -I/usr/includelibssh2:               -I/usr/includeTLS:                   -I/usr/includeLDAP:                  -I/usr/includelibevent:              -I/usr/includeEnable server:         yesServer details:With database:         MySQLWEB Monitoring:        cURLSSL certificates:      /usr/local/share/zabbix/ssl/certsSSL keys:              /usr/local/share/zabbix/ssl/keysSNMP:                  yesIPMI:                  yesSSH:                   yes (libssh2)TLS:                   OpenSSLODBC:                  noLinker flags:           -L/usr/lib64   -L/usr/lib64/      -L/usr/lib  -L/usr/lib -L/usr/lib -L/usr/lib -L/usr/lib -L/usr/lib -L/usr/lib  -rdynamicLibraries:              -lmariadb     -lxml2    -lnetsnmp -lssh2  -lOpenIPMI -lOpenIPMIposix -lz -lpthread -levent -lssl -lcrypto -lldap -llber   -lcurl -lm -ldl  -lresolv -lpcreConfiguration file:    /etc/zabbix/zabbix_server.confExternal scripts:      /usr/local/share/zabbix/externalscriptsAlert scripts:         /usr/local/share/zabbix/alertscriptsModules:               /usr/local/lib/modulesEnable proxy:          noEnable agent:          noEnable agent 2:        noEnable web service:    noEnable Java gateway:   noLDAP support:          yesIPv6 support:          no***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*                                  *
***********************************************************

依赖不通过

[root@857cd8bba2b3 zabbix-6.0.14]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
configure: Configuring Zabbix 6.0.14
checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for cc... no
checking for c99... no
checking for gcc... no
checking for clang... no
configure: error: in `/zabbix/zabbix-6.0.14':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

部署测试

docker 构建

docker-compose.yml
docker-compose up -d

安装zabbix测试

docker run --name zabbix -t -d -p 8051:10051 -p 8001:80   -v /root/zabbix:/root/zabbix --privileged=true centos:7 /usr/sbin/initdocker exec -it zabbix /bin/bashyum 源
rpm -ivh  https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpmyum install -y zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agentrpm -ivh http://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-1.el7.noarch.rpm
生成缓存
yum makecache
更新
yum -y updaterpm -ivh http://repo.zabbix.com/zabbix/6.2/rhel/7/x86_64/zabbix-release-6.2-1.el7.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX删除所有zabbix依赖
rpm -e --nodeps `rpm -qa | grep zabbix`create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@'%' identified by 'zabbix';
grant all privileges on zabbix.* to zabbix@'%';
set global log_bin_trust_function_creators = 1;报错
No package zabbix-server-mysql available
解决
yum install epel-release报错:
Error downloading packages:fping-3.16-1.el7.x86_64: [Errno 256] No more mirrors to try.
解决
安装6.2版本zabbix

mysql 文件挂载?

本机安装
http://14.29.251.27:8889/zabbix/setup.php

报错
Transaction check error:
file /usr/bin/zabbix_get from install of zabbix-get-6.0.14-release1.el7.x86_64 conflicts with file from package zabbix6.0-6.0.13-1.el7.x86_64

rpm -qa | grep zabbix
强制卸载
rpm -e zabbix6.0-6.0.13-1.el7.x86_64 --nodeps
http://:8889/

Minimum required PHP version is 7.2.5.

升级php

]# php -v
PHP 5.4.16 (cli) (built: Apr 1 2020 04:07:17)

删除 yum remove php*

[root@bzy2c8nnb0dtlnbi zabbix]# yum search php7
已加载插件:fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile

  • base: mirrors.ustc.edu.cn
  • epel: mirrors.bfsu.edu.cn
  • extras: mirrors.ustc.edu.cn
  • updates: ftp.sjtu.edu.cn
    警告:没有匹配 php7 的软件包
    No matches found

错误:
yum-config-manager
-bash: yum-config-manager: 未找到命令
解决:
[root@bzy2c8nnb0dtlnbi zabbix]# yum -y install yum-utils

加载插件
yum-config-manager --enable remi-php72

不行重整:
yum install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum search php72w
yum -y install php72w php72w-mysql

没有php命令

重装

sudo yum install epel-release
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php72
sudo yum update
sudo yum install php72 php72-php-mysqlnd
php72-mysql

yum install php php-mysql php-mysqlnd --skip-broken

错误:
The requested URL /zabbix/setup.php was not found on this server

相关内容

热门资讯

前端-session、jwt 目录:   (1)session (2&#x...
linux入门---制作进度条 了解缓冲区 我们首先来看看下面的操作: 我们首先创建了一个文件并在这个文件里面添加了...
关于测试,我发现了哪些新大陆 关于测试 平常也只是听说过一些关于测试的术语,但并没有使用过测试工具。偶然看到编程老师...
前缀和与对数器与二分法 1. 前缀和 假设有一个数组,我们想大量频繁的去访问L到R这个区间的和,...
nodejs:本地安装nvm实... 一、背景-使用不同版本node的原因 vue3+ts、nuxt3版本,node...
JAVA集合知识整理 Java集合知识整理 HashMap相关 HashMap的底层数据结构:jdk1.8之...
无刷直流电机介绍及单片机控制实... 无刷直流电机介绍及单片机控制实例前言基本概念优势与劣势使用寿命基本结构使用单片机控制实例电子调速器&...
fwdiary(2) dp2 1.传纸条  AcWing 275. 传纸条 - AcWing 走两条路,走一条最大的...
常用的DOS命令 常用的DOS命令 DOS(Disk Operating System,磁...
<C++> 类和对象(下) 1.const成员函数将const修饰的“成员函数”称之为const成员函数,cons...