市场上比较的监控方式有两种:zabbix和prometheus架构,对于MogDB/openGauss数据库来说,已经通过grafana prometheus opengauss_exporter的方式完成了监控部署(部署方式:https://www.modb.pro/db/173483)。
那么如何通过zabbix完成对MogDB/openGauss数据库完成监控呢?通过zabbix官网我们知道从zabbix 4.2版本开始支持了Prometheus 数据源,那本篇文章将实现通过zabbix采集prometheus数据,zabbix底层的数据存储采用MogDB数据库。
一.软件信息
OS: CentOS 7.9 on x86
database:MogDB 2.0.1
prometheus:2.31.1 opengauss_exporter: 0.0.9
本环境已经安装好MogDB数据库、prometheus和opengauss_exporter,这里主要介绍zabbix安装及与prometheus适配。
代码语言:javascript复制--安装依赖包
yum -y install gcc gcc-c curl curl-devel net-snmp net-snmp-devel readline.x86_64 readline-devel.x86_64 zlib.x86_64 zlib-devel.x86_64 libevent.x86_64 libevent-devel.x86_64 postgresql-devel.x86_64 golang.x86_64 libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel sqlite-devel.x86_64 sqlite.x86_64 oniguruma-devel oniguruma
二.zabbix安装部署
参考zabbix官网快速部署:(复制链接至浏览器中浏览)
https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=centos&os_version=7&db=postgresql&ws=nginx
1.安装准备:
代码语言:javascript复制--安装zabbix源
# 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 和 agent
# yum install zabbix-server-pgsql zabbix-agent
--配置zabbix前端
# yum install centos-release-scl
--编辑zabbix.repo
vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...
Install Zabbix frontend packages.
--安装PostgreSQL和Nginx
# yum install zabbix-web-pgsql-scl zabbix-nginx-conf-scl
--为zabbix前端配置PHP
vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
listen 80;
server_name 172.16.3.90;
***
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
listen.acl_users = apache,nginx
php_value[date.timezone] = Europe/Riga
2.MogDB数据库配置
代码语言:javascript复制--创建数据库
postgres=# create database zabbix DBCOMPATIBILITY='PG';
--创建用户
postgres=# c zabbix
abbix=# create user zabbix encrypted password 'zabbix@123';create user zabbix encrypted password 'zabbix@123';
--修改pg_hba.conf
host all zabbix 172.16.3.90/32 md5
--导入数据
$ zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | gsql -h 172.16.3.90 -U zabbix zabbix -f
3.启动zabbix server和agent进
代码语言:javascript复制--启动zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
4.展示zabbix前端
连接到新安装的zabbix前端,直接在浏览器输入:172.16.3.90 ,如有下图展示说明zabbix启动成功,配置完前段界面后,zabbix初始账号是:Admin,密码:zabbix
三.zabbix配置prometheus
1.配置监控项
在zabbix界面:Configuration --> Hosts --> Items --> Create Item
2.添加监控项信息
3.查看监控项
墨天轮原文链接:https://www.modb.pro/db/187462?sjhy