Zabbix-6.4.4部署及监控配置

一、目标

对zabbix-6.4.4版本进行调研。了解并测试zabbix-6.4.4部署以及监控配置。

二、过程

前言:最新版本的zabbix-6.4.4的要求有所增加,配置要求如下:
MySQL版本:8.0.X

PHP版本:7.4.X

libXML:2.6.15以上

具体要求可访问官网:​​​​​​2 安装要求 (zabbix.com)

1、下载安装包
https://www.zabbix.com/cn/download_sources

2、上传安装到相应服务器的文件中并解压
cd /opt/software
tar -zxvf zabbix-6.4.4.tar.gz

3、创建zabbix用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

4、创建zabbix文件夹
mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
chown zabbix:zabbix /usr/lib/zabbix
# mv /opt/software/zabbix-6.4.4 /usr/lib/zabbix

5、创建Zabbix数据库
## 1)创建和配置数据库和用户。
mysql -uroot -p
 
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user 'zabbix'@'localhost' identified by '';
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
mysql> SET GLOBAL log_bin_trust_function_creators = 1;
mysql> quit;

## 2)将数据导入数据库,并将 utf8mb4 字符集设置为默认值。对于Zabbix代理数据库,只应导入schema.sql
cd database/mysql
mysql -uzabbix -p zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
mysql -uzabbix -p zabbix < images.sql
mysql -uzabbix -p --default-character-set=utf8mb4 zabbix < data.sql

cd /opt/software/zabbix-6.4.4/database/mysql

## log_bin_trust_function_creators可以在成功导入架构后禁用:
mysql -uroot -p

mysql> SET GLOBAL log_bin_trust_function_creators = 0;
mysql> quit;
6、编译安装
## 构建Zabbix服务器,Zabbix代理或Zabbix代理需要带有GNU扩展的C99。可以通过设置 CFLAGS=“-std=gnu99”来显式指定此版本:
export CFLAGS="-std=gnu99"
### 要指定与 /usr/local 不同的位置,
### 在之前配置源的步骤中使用 --prefix 键,例如 --prefix=/home/zabbix。
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
make install
# 仅安装 zabbix-agent
./configure --enable-agent
make install

7、查看和编辑配置文件
vim /usr/local/etc/zabbix_server.conf
#指定数据库名称、用户和密码
DBPassword=123321

8、前提是安装了PHP
mkdir /var/www/html/zabbix
sudo cp -r /opt/software/zabbix-6.4.4/ui/* /var/www/html/zabbix

9、启动php、zabbix_server守护进程
sudo systemctl restart httpd
zabbix_server

10、开机自启
1)复制源码启动文件: 
cp /opt/software/zabbix-6.4.4/misc/init.d/tru64/* /etc/init.d/
注意,该文件是源码文件,在解压目录下,不是make install 安装后的启动文件。
2)修改 /etc/init.d/zabbix_service和zabbix_aggentd,修改文件路径为make install路径。
DAEMON=/usr/local/sbin/zabbix_XXX
chmod 775 /etc/init.d/zabbix_*
3) 开机自启动
chkconfig --add zabbix_agentd
chkconfig --add zabbix_server

chkconfig --level 345 zabbix_server on
chkconfig --level 345 zabbix_agentd on
如无法添加成功:修改启动脚本使其支持 redhat 的 chkconfig,
分别在两个脚本的 #!/bin/sh 后加入如下两行注释,注意要行前要加“#” .
# chkconfig: 2345 10 90

11、使用浏览器访问http://192.168.3.246/zabbix,并按提示进行安装

12、登录
Zabbix 前端已准备就绪! 默认用户名是Admin,密码zabbix。
---------------------------------------------------------------------
13、配置zabbix_agentd.conf
注意:其中,我们的设置LogFile=/var/log/zabbix/zabbix_agentd_1.log,
仅为测试而设置,可按具体需求修改
---------------------- 以下为zabbix4.6.6的配置设置:-------------------------
vim /usr/local/etc/zabbix_agentd.conf

PidFile=/tmp/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd_1.log
LogFileSize=0
Server=192.168.3.246
ServerActive=192.168.3.246
Hostname=192.168.3.245
#Include=/etc/zabbix/zabbix_agentd.d/
Include=/usr/local/etc/zabbix_agentd.conf.d/
UnsafeUserParameters=1

---------------------- 以下为zabbix3.0的配置设置:-------------------------
vim /etc/zabbix/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.3.246
ServerActive=192.168.3.246
Hostname=192.168.3.246
Include=/etc/zabbix/zabbix_agentd.d/
UnsafeUserParameters=1

注意:查看agentd日志:cat /var/log/zabbix/zabbix_agentd.log
14、启动zabbix_agent
zabbix_agent -c /usr/local/etc/zabbix_agentd.conf

三、常见问题

# error 1:
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing libxml-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'libxml-2.0' found Package libxml-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
checking for xmlReadMemory in -lxml2... no
configure: error: Not found libxml2 library

# solution1:
sudo yum install libxml2-devel

# error 2:
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
# solution2:
sudo yum install net-snmp-devel
# error 3:
checking for OPENIPMI support... no
configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
# solution3:
yum install OpenIPMI-devel

# error 4: 
configure: error: Unable to use libevent (libevent check failed)
# solution4:
sudo yum install libevent-devel

# error 5:
checking for curl-config... no
configure: error: Curl library not found
# solution 5:
sudo yum install libcurl libcurl-devel

# error 6:
Minimum required PHP version is 7.4.0.
# solution 6:
sudo yum install epel-release
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php74
sudo yum install php
php -v

# error 7:
前端页面显示:PHP ldap Warning
# solusion7:
yum -y install php-ldap
sudo systemctl restart httpd

你可能感兴趣的:(数据库,大数据,zabbix,adb,android)