---
title: 如何为服务器添加、删除 OBLB 标签-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于如何为服务器添加、删除 OBLB 标签相关的常见问题和使用技巧，帮助您快速解决如何为服务器添加、删除 OBLB 标签的难题。
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
[OceanBase AI 数据大会](https://www.oceanbase.com/conference2026 "OceanBase AI 数据大会")

## 体验新一代 AI 数据平台

[立即咨询](https://www.oceanbase.com/contactus) [免费试用 免费试用](https://www.oceanbase.com/free-trial)划线反馈

# 如何为服务器添加、删除 OBLB 标签

更新时间：2026-07-08 08:01

适用版本： V4.2.x、V4.3.x 内容类型：How-to  

OCP V4.2.1 支持了 OBLB & OBDNS 的告警能力，共 16 个告警指标，如进程状态、进程连通性等，从而实现 OceanBase 整个架构体系的告警能力。要实现对 OBLB 的监控功能，首先需要为对应服务器添加 OBLB 标签。同时 OAT V4.2.0 实现了为 OBLB 服务器自动添加 OBLB 标签的功能，在为服务器添加标签时，您需满足以下条件：

- OCP 为 V4.2.1 及以上版本。
 - OAT 为 V4.2.0 及以上版本，且在正常运行中。
 - OBLB 为 V1.4.0 以上版本。
 - OBLB 工具需通过 OAT 进行部署，并在部署时打开 **同步至 OCP 监控告警** 开关。

  ![1](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/ocp/%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5/%E5%AE%89%E8%A3%85oblb%E5%B7%A5%E5%85%B7.png)

当您的运行环境不满足以上任一条件时，将无法通过 OAT 自动为服务器添加 OBLB 标签。此时您可通过 OCP 开放的 API 接口，手动为服务器添加、删除 OBLB 标签。

## 适用版本

适用于 OceanBase 云平台（OceanBase Cloud Platform，OCP）V4.2.1 及以上版本。

## 前提条件

待添加 OBLB 标签的服务器，已通过 [添加主机](https://www.oceanbase.com/docs/common-ocp-1000000000826487) 的方式接管至 OCP 平台。

## 操作步骤

### 为服务器添加 OBLB 标签

1. 使用 MySQL/OBClient 客户端工具连接 OCP Meta 数据库，根据服务器的 IP 地址查询对应的 `host_id`：

   ```sql
   [root@ocp147 ~]# mysql -hxxx.xxx.xxx.xxx -uroot@ocp_meta -P2881 -pxxx
   Welcome to the MariaDB monitor.  Commands end with ; or \g.
   Your MySQL connection id is 3221503749
   Server version: 5.7.25 OceanBase 2.2.77 (r117030032023091117-fafe782c53fc2eb70a482e7c0936d5ebfe1ca8a0) (Built Sep 11 2023 19:02:36)

   Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

   MySQL [(none)]> use ocp;
   Reading table information for completion of table and column names
   You can turn off this feature to get a quicker startup with -A

   Database changed
   MySQL [ocp]> select * from compute_host where inner_ip_address='xxx.xxx.xxx.xxx'\G
   *************************** 1. row ***************************
               id: 7000001
               name: oms-119
       description: NULL
   operating_system: 5.10.0-136.12.0.86.oe2203sp1.x86_64
       architecture: x86_64
   inner_ip_address: xxx.xxx.xxx.xxx
           ssh_port: 22
               kind: DEDICATED_PHYSICAL_MACHINE
   publish_ports: NULL
           status: AVAILABLE
           vpc_id: 1
           idc_id: 1
       host_type_id: 1000001
   serial_number: NULL
           alias: ob119
       create_time: 2024-01-29 17:21:40
       update_time: 2024-05-07 10:17:21
   io_performance: NULL
   1 row in set (0.001 sec)

   ```
 2. 通过 OCP 开放的 API 接口，为该服务器添加 OBLB 标签：

   ```sql
   [root@ocp ~]# curl -uadmin:xxx 'http://xxx.xxx.xxx.xxx:8080/api/v2/compute/monitorTargets/batchCreate' \
   > --header 'Content-Type: application/json' \
   > --data '{
   >     "serviceType": "OBLB",
   >     "serviceName": "oblb_service",
   >     "hostMonitorInfos": [
   >         {
   >             "hostId": 7000001,
   >             "monitorInfo": {
   >                 "OBLB_SERVER": "9090",
   >                 "OBLB_ETCD": "2379"
   >             }
   >         }
   >     ]
   > }'
   {"duration":268,"server":"45b956df2a","status":200,"successful":true,"timestamp":"2024-05-07T10:34:35.355+08:00","traceId":"74959cdc29584dbb"}

   ```

   #### 说明

      - `OBLB_SERVER` 为安装 OBLB 服务时用户自定义的 OBLB 服务端口。
      - `OBLB_ETCD` 为安装 OBLB 服务时用户指定的 `etcd client` 端口，默认为 `2379`。
 3. 登录 OCP，查看主机信息。

   添加标签前，主机标签为空：

   ![1](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/ocp/%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5/%E6%B7%BB%E5%8A%A0%E5%89%8D.png)

   添加标签后，主机标签为 OBLB：

   ![1](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/ocp/%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5/%E6%B7%BB%E5%8A%A0%E5%90%8E.png)

### 为服务器删除 OBLB 标签

1. 通过 MySQL/OBClient 客户端工具连接 OCP Meta 数据库，根据服务器的 IP 地址查询对应的 `host_id`、OBLB 服务的 `type`、OBLB 服务的 `name`：

   ```sql
   [root@ocp ~]# mysql -hxxx.xxx.xxx.xxx -uroot@ocp_meta -P2881 -pxxx
   Welcome to the MariaDB monitor.  Commands end with ; or \g.
   Your MySQL connection id is 3221690267
   Server version: 5.7.25 OceanBase 2.2.77 (r117030032023091117-fafe782c53fc2eb70a482e7c0936d5ebfe1ca8a0) (Built Sep 11 2023 19:02:36)

   Database changed
   MySQL [ocp]> select * from compute_host where inner_ip_address='xxx.xxx.xxx.xxx'\G
   *************************** 1. row ***************************
               id: 7000001
               name: oms-119
       description: NULL
   operating_system: 5.10.0-136.12.0.86.oe2203sp1.x86_64
       architecture: x86_64
   inner_ip_address: xxx.xxx.xxx.xxx
           ssh_port: 22
               kind: DEDICATED_PHYSICAL_MACHINE
   publish_ports: NULL
           status: ONLINE
           vpc_id: 1
           idc_id: 1
       host_type_id: 1000001
   serial_number: NULL
           alias: ob119
       create_time: 2024-01-29 17:21:40
       update_time: 2024-05-07 00:19:03
   io_performance: NULL
   1 row in set (0.001 sec)

   MySQL [ocp]> select * from compute_host_service where host_id=7000001\G
   *************************** 1. row ***************************
                   id: 18000001
               host_id: 7000001   <== 对应服务器的 host_id
               type: OBLB      <== OBLB 服务的 type
               name: oblb_service   <== OBLB 服务的 name
               version: NULL
   software_package_id: NULL
           create_time: 2024-04-15 17:22:43
           update_time: 2024-04-15 17:22:43
   1 row in set (0.002 sec)

   ```
 2. 通过 OCP 开放的 API 接口，删除该服务器上的 OBLB 标签：

   ```sql
   [root@ocp ~]# curl -uadmin:xxx 'http://xxx.xxx.xxx.xxx:8080/api/v2/compute/monitorTargets/batchDelete' \
   --header 'Content-Type: application/json' \
   --data '{
       "hostIds": [7000001],
       "serviceType": "OBLB",
       "serviceName": "oblb_service"
   }'
   {"duration":181,"server":"45b956df2a","status":200,"successful":true,"timestamp":"2024-05-07T10:17:21.456+08:00","traceId":"d7ed252428634a07"}

   ```
 3. 登录 OCP，查看主机信息。

   删除标签前，主机标签为 OBLB：

   删除标签后，主机标签为空：

上一篇

[OCP 执行清理主机任务时返回 read timed out](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000346968)

下一篇

[通过 OCP 接管 OBProxy 集群时报错：无法获取 obproxy 可连接集群信息](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000342352) ![有帮助](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) 咨询
