Prometheus+Grafana监控Greenplum

2022-06-08 00:00:00 专区 服务 配置 启动 安装

安装Prometheus

下载地址

https://prometheus.io/download/

安装过程

[root@yejf]~# useradd prometheus
[root@yejf]~# passwd prometheus

[root@yejf]/opt# tar -zxvf prometheus-2.28.0.linux-amd64.tar.gz --directory=/usr/local/    prometheus-2.28.0.linux-amd64/
prometheus-2.28.0.linux-amd64/consoles/
prometheus-2.28.0.linux-amd64/consoles/index.html.example
prometheus-2.28.0.linux-amd64/consoles/node-cpu.html
prometheus-2.28.0.linux-amd64/consoles/node-disk.html
prometheus-2.28.0.linux-amd64/consoles/node-overview.html
prometheus-2.28.0.linux-amd64/consoles/node.html
prometheus-2.28.0.linux-amd64/consoles/prometheus-overview.html
prometheus-2.28.0.linux-amd64/consoles/prometheus.html
prometheus-2.28.0.linux-amd64/console_libraries/
prometheus-2.28.0.linux-amd64/console_libraries/menu.lib
prometheus-2.28.0.linux-amd64/console_libraries/prom.lib
prometheus-2.28.0.linux-amd64/prometheus.yml
prometheus-2.28.0.linux-amd64/LICENSE
prometheus-2.28.0.linux-amd64/NOTICE
prometheus-2.28.0.linux-amd64/prometheus
prometheus-2.28.0.linux-amd64/promtool

[root@yejf]/opt# ln -s /usr/local/prometheus-2.28.0.linux-amd64 /usr/local/prometheus
[root@yejf]/usr/local# chown -R prometheus:prometheus /usr/local/prometheus*

使用配置文件启动服务

[prometheus@yejf ~]$ /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
level=info ts=2021-07-01T08:05:05.459Z caller=main.go:388 msg="No time or size retention was set so using the default time retention" duration=15d
level=info ts=2021-07-01T08:05:05.459Z caller=main.go:426 msg="Starting Prometheus" version="(version=2.28.0, branch=HEAD, revision=ff58416a0b0224bab1f38f949f7d7c2a0f658940)"
level=info ts=2021-07-01T08:05:05.459Z caller=main.go:431 build_context="(go=go1.16.5, user=root@32b9079a2740, date=20210621-15:45:36)"
level=info ts=2021-07-01T08:05:05.459Z caller=main.go:432 host_details="(Linux 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 yejf (none))"
level=info ts=2021-07-01T08:05:05.459Z caller=main.go:433 fd_limits="(soft=1024, hard=4096)"
level=info ts=2021-07-01T08:05:05.459Z caller=main.go:434 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2021-07-01T08:05:05.463Z caller=web.go:541 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2021-07-01T08:05:05.464Z caller=main.go:807 msg="Starting TSDB ..."
ts=2021-07-01T08:05:05.468Z caller=log.go:124 component=web level=info msg="TLS is disabled." http2=false
level=info ts=2021-07-01T08:05:05.475Z caller=head.go:780 component=tsdb msg="Replaying on-disk memory mappable chunks if any"
level=info ts=2021-07-01T08:05:05.475Z caller=head.go:794 component=tsdb msg="On-disk memory mappable chunks replay completed" duration=7.168µs
level=info ts=2021-07-01T08:05:05.475Z caller=head.go:800 component=tsdb msg="Replaying WAL, this may take a while"
level=info ts=2021-07-01T08:05:05.476Z caller=head.go:854 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
level=info ts=2021-07-01T08:05:05.476Z caller=head.go:860 component=tsdb msg="WAL replay completed" checkpoint_replay_duration=27.771µs wal_replay_duration=1.259861ms total_replay_duration=1.312914ms
level=info ts=2021-07-01T08:05:05.481Z caller=main.go:834 fs_type=XFS_SUPER_MAGIC
level=info ts=2021-07-01T08:05:05.481Z caller=main.go:837 msg="TSDB started"
level=info ts=2021-07-01T08:05:05.481Z caller=main.go:964 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2021-07-01T08:05:05.483Z caller=main.go:995 msg="Completed loading of configuration file" filename=prometheus.yml totalDuration=2.251157ms remote_storage=11.277µs web_handler=503ns query_engine=1.402µs scrape=1.197804ms scrape_sd=67.338µs notify=37.164µs notify_sd=13.305µs rules=3.581µs
level=info ts=2021-07-01T08:05:05.483Z caller=main.go:779 msg="Server is ready to receive web requests."

Prometheus启动后,可以通过IP:9090端口查看是否正常启动并提供服务

安装Greenplum-Expoter

1、程序同时支持GP5和GP6;
2、数据膨胀数据采集;
3、数据倾斜信息采集;

安装过程

[root@yejf]/opt# rpm -ivh greenplum_exporter-1.1-rhel7.x86_64.rpm 
准备中...                          ################################# []
正在升级/安装...
   1:greenplum_exporter-1.1-rhel7     ###
############################## [100%]

软件默认安装在/usr/local/greenplum_exporter目录下,修改目录属性

[root@yejf]~# chown -R prometheus:prometheus /usr/local/greenplum_exporter 

修改数据库连接配置文件(这配置感觉没用上)

# vi /usr/local/greenplum_exporter/etc/greenplum.conf
GPDB_DATA_SOURCE_URL=postgres://gpadmin6:gpadmin6@192.168.43.100:5432/postgres?sslmode=disable

启动服务

启动前需要export一下环境变量,不然会有问题

[prometheus@yejf ~]$ export GPDB_DATA_SOURCE_URL=postgres://yejf:yejf@127.0.0.1:5432/postgres?sslmode=disable

因为使用连接的用户是普通用户,所以有些视图会没权限,需要一个个赋权,例如:

grant select on gp_toolkit.gp_disk_free to yejf;

正式启动服务

[prometheus@yejf ~]$ /usr/local/greenplum_exporter/bin/greenplum_exporter --web.listen-address="0.0.0.0:9297" --web.telemetry-path="/metrics" --log.level=error
WARN[0000] Greenplum exporter is starting and will listening on : 0.0.0.0:9297  source="main.go:57"

访问如下地址以检测验证成功安装

在Prometheus中配置Greenplum Exporter

在配置prometheus.yml
文件添加配置信息

# vi /usr/local/prometheus/prometheus.yml
- job_name: 'greenplum'
    static_configs:
    - targets: ['192.168.43.100:9297']


重启prometheus服务,在http://192.168.43.100:9090/target
查看到正常获取指标

安装Grafana

下载地址

https://grafana.com/grafana/download

安装过程

[root@yejf]/opt# tar -xvf grafana-8.0.3.linux-amd64.tar --directory=/usr/local/
[root@yejf]/opt# ln -s /usr/local/grafana-8.0.3 /usr/local/grafana
[root@yejf]/opt# chown -R prometheus:prometheus /usr/local/grafana* 

启动服务

[prometheus@yejf ~]$ /usr/local/grafana/bin/grafana-server -homepath /usr/local/grafana -config /usr/local/grafana/conf/defaults.ini
INFO[07-01|16:29:54] Starting Grafana                         logger=server version=8.0.3 commit=cae5c5e46b branch=HEAD compiled=2021-06-18T16:56:02+0800
INFO[07-01|16:29:54] Config loaded from                       logger=settings file=/usr/local/grafana/conf/defaults.ini
INFO[07-01|16:29:54] Config loaded from                       logger=settings file=/usr/local/grafana/conf/defaults.ini
INFO[07-01|16:29:54Path Home                                logger=settings path=/usr/local/grafana
INFO[07-01|16:29:54Path Data                                logger=settings path=/usr/local/grafana/data
INFO[07-01|16:29:54Path Logs                                logger=settings path=/usr/local/grafana/data/log
INFO[07-01|16:29:54Path Plugins                             logger=settings path=/usr/local/grafana/data/plugins
INFO[07-01|16:29:54Path Provisioning                        logger=settings path=/usr/local/grafana/conf/provisioning
INFO[07-01|16:29:54] App mode production                      logger=settings
INFO[07-01|16:29:54] Connecting to DB                         logger=sqlstore dbtype=sqlite3
INFO[07-01|16:29:54Starting DB migrations                   logger=migrator
INFO[07-01|16:29:54] migrations completed                     logger=migrator performed= skipped=330 duration=1.093141ms
INFO[07-01|16:29:54Starting plugin search                   logger=plugins
INFO[07-01|16:29:54] Registering plugin                       logger=plugins id=input
INFO[07-01|16:29:54] Registering plugin                       logger=plugins id=grafana-plugin-admin-app
INFO[07-01|16:29:54] Live Push Gateway initialization         logger=live.push_http
INFO[07-01|16:29:54HTTP Server Listen                       logger=http.server address=[::]:3000 protocol=http subUrl= socket=

Grafana启动后,可以通过IP:3000端口查看是否正常启动并提供服务

默认用户和密码是admin

添加promethus数据源


配置greenplum状态图

导入json配置

后可以查看到监控的界面

来源 https://www.modb.pro/db/106854

相关文章