---
title: github-fill
description: 分布式数据库OceanBase 社区版文档中心，提供关于通过 Prometheus 监控数据库的相关内容，方便用户更好的应用分布式数据库OceanBaseOceanBase 数据库
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
[OceanBase AI 数据大会](https://www.oceanbase.com/conference2026 "OceanBase AI 数据大会") 文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*P8CuR4UJ_FkAAAAAAAAAAAAADiGDAQ/original) OceanBase 数据库分布式版 - V 3.1.5 社区版

# 通过 Prometheus 监控数据库

更新时间：2026-06-29 11:15:11

[编辑](https://github.com/oceanbase/oceanbase-doc/edit/V3.1.5/zh-CN/100.users-guide/1100.operation-and-maintenance-management/100.administrator-guide-monitoring-and-alerts/200.use-prometheus-to-monitor-databases.md)  

本文介绍如何安装部署并使用 Prometheus 软件。

## Prometheus 安装部署

1. 下载 [Prometheus 软件](https://Prometheus.io/download/)。
 2. 解压并安装 Prometheus 软件。

   ```bash
   sudo tar zxvf Prometheus-2.30.3.linux-amd64.tar.gz -C /usr/local/

   ```
 3. 复制 OBAgent 生成的 Prometheus 配置文件到 Prometheus 安装目录中。

   > **说明**
   >
   >  
   >
   > OBAgent 携带了 Prometheus 配置文件的模版，使用 OBD 部署 OBAgent, 会自动填充模版中的内容。该配置文件被放在 OBAgent 安装目录下，如 `/home/admin/obagent/conf/Prometheus_config/`。这个配置文件可以供 Prometheus 软件直接使用。OBAgent 的安装部署，请参考 [OBAgent](https://www.oceanbase.com/docs/community-observer-cn-10000000001879804)

   ```bash
   sudo mv Prometheus_config/ /usr/local/Prometheus-2.30.3.linux-amd64/

   ```
 4. 新建 Prometheus 服务文件。

   ```bash
   sudo mkdir /var/lib/Prometheus
   sudo vim /etc/systemd/system/Prometheus.service

   [Unit]
   Description=Prometheus Server
   Documentation=https://Prometheus.io/docs/introduction/overview/
   After=network-online.target

   [Service]
   Restart=on-failure
   ExecStart=/usr/local/Prometheus-2.30.3.linux-amd64/Prometheus --config.file=/usr/local/Prometheus-2.30.3.linux-amd64/Prometheus_config/Prometheus.yaml --storage.tsdb.path=/var/lib/Prometheus --web.enable-lifecycle --web.external-url=http://172.20.xx.xx:9090

   [Install]
   WantedBy=multi-user.target

   ```
 5. 启动 Prometheus 服务。

   ```bash
   sudo systemctl daemon-reload

   sudo systemctl start Prometheus

   sudo systemctl status Prometheus

   [admin@**** ~]$ sudo systemctl status Prometheus
   ● Prometheus.service - Prometheus Server
   Loaded: loaded (/etc/systemd/system/Prometheus.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-10-21 15:54:42 CST; 49s ago
   Docs: https://Prometheus.io/docs/introduction/overview/
   Main PID: 902555 (Prometheus)
   Tasks: 13 (limit: 195588)
   Memory: 40.6M
   CGroup: /system.slice/Prometheus.service
           └─902555 /usr/local/Prometheus-2.30.3.linux-amd64/Prometheus --config.file=/usr/local/Prometheus-2.30.3.linux-amd64/Prometheus_config/Prometheus.yaml --storage.tsdb.path=/var/lib/Prometheus --web.enable-lifecycle --web.external-url=http://172.20.xx.xx:9090

   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.275Z caller=head.go:479 component=tsdb msg="Replaying on-disk memory mappable chunks if any"
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.275Z caller=head.go:513 component=tsdb msg="On-disk memory mappable chunks replay completed" duration=2.127µs
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.275Z caller=head.go:519 component=tsdb msg="Replaying WAL, this may take a while"
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.275Z caller=head.go:590 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.275Z caller=head.go:596 component=tsdb msg="WAL replay completed" checkpoint_replay_duration=39.378µs wal_replay_duration=185.207µs total_replay_duration=242.438µs
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.277Z caller=main.go:849 fs_type=XFS_SUPER_MAGIC
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.277Z caller=main.go:852 msg="TSDB started"
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.277Z caller=main.go:979 msg="Loading configuration file" filename=/usr/local/Prometheus-2.30.3.linux-amd64/Prometheus_config/Prometheus.yaml
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.281Z caller=main.go:1016 msg="Completed loading of configuration file" filename=/usr/local/Prometheus-2.30.3.linux-amd64/Prometheus_config/Prometheus.yaml totalDuration=4.630509ms db_storage=1>
   Oct 21 15:54:42 obce00 Prometheus[902555]: level=info ts=2021-10-21T07:54:42.281Z caller=main.go:794 msg="Server is ready to receive web requests."

   ```
 6. 确认 Prometheus 是否启动成功。

   ```bash
   [admin@**** ~]$ sudo netstat -ntlp | grep 9090
   tcp6       0      0 :::9090                 :::*                    LISTEN      902555/Prometheus

   ```

## Prometheus 使用

### 查看数据库告警

使用浏览器访问：`http://172.20.xx.xx:9090/alerts`。

> **说明**
>
>  
>
> 此处链接中的 IP 为示例中配置 Prometheus 的服务器 IP，根据实际情况将其转换为自身配置 Prometheus 的服务器 IP。

![查看告警事件](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/observer/V3.1.3/zh-CN/operation-and-maintenance-management/administrator-guide-monitoring-and-alerts/use-prometheus-to-monitor-databases.md/2.%E6%9F%A5%E7%9C%8B%E5%91%8A%E8%AD%A6%E4%BA%8B%E4%BB%B6.png)

### 查看节点 LOAD

使用浏览器访问：`http://172.20.xx.xx:9090/graph`

![查看节点 LOAD](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/observer/V3.1.3/zh-CN/operation-and-maintenance-management/administrator-guide-monitoring-and-alerts/use-prometheus-to-monitor-databases.md/2.%E6%9F%A5%E7%9C%8B%E8%8A%82%E7%82%B9LOAD.png)

节点中会涉及到很多自定义的指标名，目前支持的主机监控指标名如下：

| 指标名 | Ladel | 描述 | 类型 |
| --- | --- | --- | --- |
| node_cpu_seconds_total | cpu,mode,svr_ip | CPU 时间 | counter |
| node_disk_read_bytes_total | device,svr_ip | 磁盘读取字节数 | counter |
| node_disk_read_time_seconds_total | device,svr_ip | 磁盘读取消耗总时间 | counter |
| node_disk_reads_completed_total | device,svr_ip | 磁盘读取完成次数 | counter |
| node_disk_written_bytes_total | device,svr_ip | 磁盘写入字节数 | counter |
| node_disk_write_time_seconds_total | device,svr_ip | 磁盘写入消耗总时间 | counter |
| node_disk_writes_completed_total | device,svr_ip | 磁盘写入完成次数 | counter |
| node_filesystem_avail_bytes | device,fstype,mountpoint,svr_ip | 文件系统可用大小 | gauge |
| node_filesystem_readonly | device,fstype,mountpoint,svr_ip | 文件系统是否只读 | gauge |
| node_filesystem_size_bytes | device,fstype,mountpoint,svr_ip | 文件系统大小 | gauge |
| node_load1 | svr_ip | 1 分钟平均 load | gauge |
| node_load5 | svr_ip | 5 分钟平均 load | gauge |
| node_load15 | svr_ip | 15 分钟平均 load | gauge |
| node_memory_Buffers_bytes | svr_ip | 内存 buffer 大小 | gauge |
| node_memory_Cached_bytes | svr_ip | 内存 cache 大小 | gauge |
| node_memory_MemFree_bytes | svr_ip | 内存 free 大小 | gauge |
| node_memory_MemTotal_bytes | svr_ip | 内存总大小 | gauge |
| node_network_receive_bytes_total | device,svr_ip | 网络接受总字节数 | counter |
| node_network_transmit_bytes_total | device,svr_ip | 网络发送总字节数 | counter |
| node_ntp_offset_seconds | svr_ip | NTP 时钟偏移 | |

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ) 咨询
