MatrixDB适配Zabbix安装文档

一、Zabbix server安装

安装准备

操作系统

cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)

selinux

cat /etc/selinux/config 
SELINUX=disabled

安装repo

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

安装zabbix server

目前仅支持5.0和5.4版本

yum install -y zabbix-server-pgsql zabbix-agent

查看安装的包

rpm -qa|grep zabbix

zabbix-agent-5.0.7-1.el7.x86_64
zabbix-server-pgsql-5.0.7-1.el7.x86_64
zabbix-release-5.0-1.el7.noarch

开启运行zabbix界面

yum install -y centos-release-scl

编辑repo配置文件

vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
enabled=1

安装web

yum install -y zabbix-web-pgsql-scl zabbix-nginx-conf-scl

安装MatrixDB,参考MatrixDB安装文档

创建用户及库

create user zabbix with encrypted password '123456';
create database zabbix; 

导入元数据到MatrixDB

5.0版本

psql zabbix < matrixdb_zabbix--1.0_5.0.sql

sql文件链接在这里

5.4版本

psql zabbix < matrixdb_zabbix--1.0_5.4.sql

sql文件链接在这里

Zabbix server配置

cat /etc/zabbix/zabbix_server.conf|grep -v "^#"|grep -v "^$"
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=three      # 数据库主机ip或主机名
DBName=zabbix     # 数据库名
DBUser=zabbix     # 连接用户
DBPassword=123456 # 连接密码
DBPort=5432       # 连接端口
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

编辑配置文件

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
listen.acl_users = apache,nginx
php_value[date.timezone] = Asia/Shanghai

拷贝zabbix web文档至站点位置

cp -r /usr/share/zabbix /opt/rh/rh-nginx116/root/usr/share/nginx/html/

nginx配置

vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /opt/rh/rh-nginx116/root/usr/share/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }

php参数修改

vim /etc/opt/rh/rh-php72/php.ini
soap.wsdl_cache_enabled=1
max_input_time = 600
max_execution_time = 300
date.timezone = Asia/Shanghai
post_max_size = 32M
memory_limit = 128M
mbstring.func_overload = 1

启动Zabbix server和agent进程

systemctl start zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

配置Zabbix

连接到新安装的Zabbix前端: http://server_ip_or_name

打开http:IP/zabbix

例:http://192.168.174.129/zabbix/zabbix.php zabbix1

查看php检测相关参数 zabbix2

填写MatrixDB的参数 zabbix3

填写zabbix server的ip和端口 zabbix4

安装参数汇总 zabbix5

安装成功 zabbix6

登陆zabbix,默认的账户密码:Admin/zabbix zabbix7

主界面如下: zabbix8

二、yum安装agent安装

agent repo安装

sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpmRetrieving https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.yO9bsD: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]

安装agent

sudo yum install -y zabbix-agent

编辑zabbix agent配置文件

vim /etc/zabbix/zabbix_agentd.conf  
Server=192.168.174.129
ListenPort=10050
StartAgents=0 
ServerActive=192.168.174.129
Hostname=three

说明

Server: 被动模式访问的zabbix-server的ip

ServerActive: 主动模式访问的zabbix-server的ip

StartAgents :zabbix_agentd用来处理被动检查的实例数量,如果设置为0,则禁用被动模式检查而且agent不再监听任何tcp端口

三,其它数据源配置

修改web连接db源

vim /etc/zabbix/web/zabbix.conf.php

$DB['TYPE']                     = 'POSTGRESQL';
$DB['SERVER']                   = 'sdw5';
$DB['PORT']                     = '5433';
$DB['DATABASE']                 = 'zabbix';
$DB['USER']                     = 'zabbix';
$DB['PASSWORD']                 = '123456';

zabbix server更改数据源

vim /etc/zabbix/zabbix_server.conf

DBHost=sdw5
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=5433