---
title: github-fill
description: 分布式数据库OceanBase 社区版文档中心，提供关于手动部署 OBAgent的相关内容，方便用户更好的应用分布式数据库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 社区版

# 手动部署 OBAgent

更新时间：2026-06-05 14:21:44

[编辑](https://github.com/oceanbase/oceanbase-doc/edit/V3.1.5/zh-CN/1800.supporting-tools/200.ob-agent/300.install-and-deploy-obagent/200.manually-deploy-obagent.md)  

OBAgent 提供使用 OBD 部署和手动部署。若要手动部署 OBAgent，您要配置 OBAgent、Prometheus 和 Prometheus Alertmanager（可选）。本文将介绍如何手动部署 OBAgent。

## 前提条件

在部署 OBAgent 之前，您需要确认以下信息：

- OceanBase 数据库服务已经部署并启动。
 - OBAgent 已经安装。详细信息，请参考 [安装 OBAgent](https://github.com/oceanbase/obagent/blob/master/docs/install-and-deploy/install-obagent.md)。
 - OBAgent 的默认端口 8088、8089 未占用。您也可以自定义端口。

## 操作步骤

按以下步骤部署 OBAgent：

### 步骤1：部署 monagent

1. 修改配置文件，详细信息，请参考 [monagent 配置文件说明](https://www.oceanbase.com/docs/community-observer-cn-10000000001879800) 和 [KV 配置文件说明](https://www.oceanbase.com/docs/community-observer-cn-10000000001879799)。
 2. 启动 monagent 进程。推荐您使用 Supervisor 启动 monagent 进程。

   ```shell
   # 将当前目录切换至 OBAgent 的安装目录
   cd /home/admin/obagent
   # 启动 monagent 进程
   nohup ./bin/monagent -c conf/monagent.yaml >> ./log/monagent_stdout.log 2>&1 &

   # Supervisor 配置样例
   [program:monagent]
   command=./bin/monagent -c conf/monagent.yaml
   directory=/home/admin/obagent
   autostart=true
   autorestart=true
   redirect_stderr=true
   priority=10
   stdout_logfile=log/monagent_stdout.log

   ```

### （可选）步骤2：部署 Prometheus

> **说明**
>
>  
>
> 您需要安装 Prometheus。

1. 配置 Prometheus，详细信息，请参考 [Prometheus 配置文件说明](https://www.oceanbase.com/docs/community-observer-cn-10000000001879801)。
 2. 将配置好的 Prometheus 配置文件复制到部署 Prometheus 的主机上，然后使用如下命令启动 Prometheus。

   ```shell
   ./prometheus --config.file=./prometheus.yaml

   ```

### （可选）步骤3：部署 Prometheus Alertmanager

1. 下载并解压 Prometheus Alertmanager。
 2. 启动 Prometheus Alertmanager。
 3. 配置 Prometheus Alertmanager。更多信息，请参考 [Prometheus 文档](https://www.prometheus.io/docs/alerting/latest/configuration/)。

OBAgent 提供默认的报警项，配置文件位于 `conf/prometheus_config/rules`。其中，`host_rules.yaml` 存储机器报警项，`ob_rules.yaml` 存储 OceanBase 数据库报警项。如果默认报警项不能满足您的需求，按照以下方式自定义报警项：

```shell
#在 Prometheus 的配置文件中增加报警相关的配置。报警相关的配置文件需放在 rules 目录，且命名满足 *rule.yaml。

groups:
- name: node-alert
    rules:
    - alert: disk-full
    expr: 100 - ((node_filesystem_avail_bytes{mountpoint="/",fstype=~"ext4|xfs"} * 100) / node_filesystem_size_bytes {mountpoint="/",fstype=~"ext4|xfs"}) > 80
    for: 1m
    labels:
        serverity: page
    annotations:
        summary: "{{ $labels.instance }} disk full "
        description: "{{ $labels.instance }} disk > {{ $value }}  "

```

## （可选）步骤4：部署与配置 Grafana

- 下载并解压 Grafana。
 - 启动 Grafana。

  ```shell
  ./bin/grafana-server

  ```
 - 登陆 grafana 并且修改密码，第一次登陆默认账号和密码都是 `admin`。
 - 配置 prometheus 为数据源, 添加数据源的方式请参考 [grafana 文档](https://grafana.com/docs/grafana/v7.5/datasources/add-a-data-source/)。
 - 导入 dashboard，针对 OceanBase 和主机指标的配置已经发布到 grafana，id 分别为 `15215`、`15216`，导入 dashboard 的方式请参考 [grafana 文档](https://grafana.com/docs/grafana/v7.5/dashboards/export-import/)。

## （可选）更新 KV 配置

OBAgent 提供了更新配置的接口。您可以通过 HTTP 服务更新 KV 配置项：

```shell
# 您可以同时更新多个 KV 的配置项，写多组 key 和 value 即可。

curl --user user:pass -H "Content-Type:application/json" -d '{"configs":[{"key":"monagent.pipeline.ob.status", "value":"active"}]}' -L 'http://ip:port/api/v1/module/config/update'

```

 上一篇 下一篇 ![有帮助](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) 咨询
