---
title: OceanBase 数据库中删除 OBServer 问题排查方法-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于OceanBase 数据库中删除 OBServer 问题排查方法相关的常见问题和使用技巧，帮助您快速解决OceanBase 数据库中删除 OBServer 问题排查方法的难题。
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

划线反馈

# OceanBase 数据库中删除 OBServer 问题排查方法

更新时间：2026-06-04 01:56

适用版本： V2.1.x、V2.2.x、V3.1.x、V3.2.x 内容类型：TechNote  

本文介绍了 OceanBase 数据库中 OBServer 删除的逻辑以及出现问题时的排查方法。

## 适用版本

OceanBase 数据库所有版本

## 前提条件

删除 OBServer 需要进行 Unit 迁移等操作，因此需要将 `enable_rebalance` 配置项设置为 `True`。

系统配置项 `enable_rebalance` 用于设置是否开启自动负载均衡的功能，默认为 `True`，表示开启。

有关该配置项的详细信息，请参见《OceanBase 数据库 参考指南》中的 **系统配置项** 章节。

```unknow
obclient> alter system set enable_rebalance = true;

```

## 删除 OBServer 的阶段

OceanBase 数据库执行删除 OBServer 操作包含两个阶段：

- 第一阶段：

     - 检查被删除的 OBServer上所有的 Partition 是否有足够多的 F 副本、副本数量是否满足 Paxos 组等信息
     - 预检查该 OBServer 上的 Unit 是否能够迁移到其他的 OBServer上，查看其他机器上是否有充足的资源来存放该 OBServer 上的 Unit
     - 将 `__all_server` 表中对应的 status 状态置为 `deleting`，同时在 `__all_rootservice_job` 表中记录一条 `job_type` 为 `DELETE_SERVER`，`job_status` 为 `INPROGRESS` 的记录。

  该阶段检查完成后，会返回语句执行成功，此时查询 `__all_server` 与 `__all_rootservice_job` 表的结果如下。

  ```unknow
  obclient> SELECT * FROM __all_server WHERE svr_ip = '$DELETE_SERVER_IP' AND svr_port = '$DELETE_SERVER_PORT';
  +----------------------------+----------------------------+----------------+----------+----+------+------------+-----------------+----------+-----------------------+-------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+
  | gmt_create                 | gmt_modified               | svr_ip         | svr_port | id | zone | inner_port | with_rootserver | status   | block_migrate_in_time | build_version                                                           | stop_time | start_service_time | first_sessid | with_partition | last_offline_time |
  | 2021-03-18 20:35:46.550891 | 2021-03-18 21:47:44.682902 | xx.xxx.xxx.xxx |    xxxxx |  6 | z2   |      34486 |               0 | deleting |                     0 | 2.2.77_1-3002b6578cf1a91a3a2a95a3b5e1df761f3bda5d(Mar 18 2021 12:00:15) |         0 |   1616070959230656 |            0 |              1 |                 0 |
  +----------------------------+----------------------------+----------------+----------+----+------+------------+-----------------+----------+-----------------------+-------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+

  obclient> SELECT * FROM __all_rootservice_job WHERE job_type = 'DELETE_SERVER';
  +----------------------------+----------------------------+--------+-------------------------------+------------+-------------+----------+-----------+-------------+-------------+---------------+----------+------------+--------------+----------------+----------+---------+-----------------+-------------+----------+-----------------+------------------+---------------+-----------------+
  | gmt_create                 | gmt_modified               | job_id | job_type                      | job_status | return_code | progress | tenant_id | tenant_name | database_id | database_name | table_id | table_name | partition_id | svr_ip         | svr_port | unit_id | rs_svr_ip       | rs_svr_port | sql_text | extra_info      | resource_pool_id | tablegroup_id | tablegroup_name |
  | 2021-03-18 21:47:46.669400 | 2021-03-18 21:47:46.669400 |      4 | DELETE_SERVER                 | INPROGRESS |        NULL |        0 |      NULL | NULL        |        NULL | NULL          |     NULL | NULL       |         NULL | xx.xxx.xxx.xxx |    xxxxx |    NULL | xxx.xxx.xxx.xxx |       34447 | NULL     | NULL            |             NULL |          NULL | NULL            |
  +----------------------------+----------------------------+--------+-------------------------------+------------+-------------+----------+-----------+-------------+-------------+---------------+----------+------------+--------------+----------------+----------+---------+-----------------+-------------+----------+-----------------+------------------+---------------+-----------------+

  ```
 - 第二阶段：

     - 语句执行成功后，负载均衡会调度 OBServer 上的 Unit，将该 OBServer 上的 Unit 迁移到同 Zone的其他 OBServer上。
     - 当 OBServer 上的全部 Unit 被迁移完成后，会将该 OBServer 信息从 `__all_server` 表中清除，同时 `__all_rootservice_job` 中 `job_status` 的状态置为 `SUCCESS`。

  此时查询 `__all_rootservice_job` 表的结果如下。

  ```unknow
  obclient> SELECT * FROM __all_rootservice_job WHERE job_type = 'DELETE_SERVER';
  +----------------------------+----------------------------+--------+-------------------------------+------------+-------------+----------+-----------+-------------+-------------+---------------+----------+------------+--------------+----------------+----------+---------+-----------------+-------------+----------+-----------------+------------------+---------------+-----------------+
  | gmt_create                 | gmt_modified               | job_id | job_type                      | job_status | return_code | progress | tenant_id | tenant_name | database_id | database_name | table_id | table_name | partition_id | svr_ip         | svr_port | unit_id | rs_svr_ip       | rs_svr_port | sql_text | extra_info      | resource_pool_id | tablegroup_id | tablegroup_name |
  | 2021-03-18 21:47:46.669400 | 2021-03-18 21:50:00.958066 |      4 | DELETE_SERVER                 | SUCCESS    |           0 |      100 |      NULL | NULL        |        NULL | NULL          |     NULL | NULL       |         NULL | xx.xxx.xxx.xxx |    xxxxx |    NULL | xxx.xxx.xxx.xxx |       34447 | NULL     | NULL            |             NULL |          NULL | NULL            |
  +----------------------------+----------------------------+--------+-------------------------------+------------+-------------+----------+-----------+-------------+-------------+---------------+----------+------------+--------------+----------------+----------+---------+-----------------+-------------+----------+-----------------+------------------+---------------+-----------------+

  ```

## 问题排查

删除 OBServer 的常见错误有以下几类：

### 错误码 4179

该错误通常是由于 OBServer 上对应的 Partition 副本数不足多数派或 F 副本数为 0 导致。另外一种情况是其他 Zone 上存在宕机的 OBServer，导致副本数少于多数派。

对于此类问题，可以按以下步骤进行排查：

1. 获取删除失败的 OBServer 上对应的租户列表。

   如果查询的结果不为空，则表示此时还在进行 Unit 以及副本的迁移。

   ```unknow
   obclient> SELECT tenant_id FROM __all_resource_pool WHERE resource_pool_id IN (SELECT resource_pool_id FROM  __all_unit WHERE svr_ip = xxx.xxx.xx.xxx AND svr_port = xxxx);

   ```
 2. 查询是否存在补副本任务。

   若返回值不为 `0`，那么证明还存在着补副本任务，需要等待补副本完成。

   ```unknow
   obclient> SELECT count(*) FROM __all_virtual_rebalance_task_stat WHERE task_type = 'ADD_REPLICA' AND tenant_id IN '$tenant_list';

   ```

典型的错误码 4179 的故障排查方法请参见 [OBServer 停止错误，错误代码 4179](https://www.oceanbase.com/knowledge-base/oceanbase-database-20000000115)。

### 错误码 4624

通常是没有足够的资源放置该 OBServer 上 Unit导致。 由于机器状态是动态变化的，该阶段的检查并不一定准确，如果不属于下面的原因，可以尝试重试操作。

- 该 Zone 上只有一台 OBServer，此时不允许删除该 OBServer。
 - 该 Zone 上没有空闲机器。

  此时可以将该 OBServer上对应的资源池的 `unit_num` 调小，然后再执行删除操作。

### 错误码 4018

该问题仅存在于 OceanBase 数据库 V2.2.30 BP10 前的版本，将 OceanBase 数据库升级到 V2.2.30 BP10 以及以后版本即可解决。有关 OceanBase 数据库升级的方法，请参见《OceanBase 数据库 升级指南》。

### Unit 迁移慢的问题

对于 Unit 迁移慢的问题，首先查询 `__all_virtual_rebalance_task_stat` 表，如果若返回值不为 `0`，那么证明还存在着迁移任务。

有关提升迁移速度的推荐配置，请参见 [Unit 迁移问题的排查方法](https://www.oceanbase.com/knowledge-base/oceanbase-database-20000000136)中的 **迁移过慢问题排查。**

### Unit 一直被占用不能被删除

对于此类问题，通过以下步骤排查。

1. 通过以下语句查询 OBServer 上的副本数量，如果为 `0`，则可能是该 OBServer 上的 Unit 仍被其他的资源池引用。

   ```javascript
   obclient> SELECT count(*) FROM __all_virtual_partition_info WHERE svr_ip = '$DELETE_SERVER_IP' AND svr_port = '$DELETE_SERVER_PORT';

   ```
 2. 查询资源所属的租户 ID。

   此时 `tenant_id` 为 `-1`，表示该资源池没有分配给任何租户.

   ```unknow
   obclient>  SELECT * FROM __all_resource_pool WHERE resource_pool_id IN (SELECT unit_id FROM __all_unit WHERE svr_ip = 'xxx.xx.xxx.xxx' AND svr_port = 'xxxx');
    +----------------------------+----------------------------+------------------+-------+------------+----------------+-----------+-----------+--------------+--------------------+
   | gmt_create                 | gmt_modified               | resource_pool_id | name  | unit_count | unit_config_id | zone_list | tenant_id | replica_type | is_tenant_sys_pool |
   +----------------------------+----------------------------+------------------+-------+------------+----------------+-----------+-----------+--------------+--------------------+
   | 2021-03-19 09:51:32.228242 | 2021-03-19 09:51:32.315968 |             1001 | pool1 |          3 |           1001 | z1;z2;z3  |        -1 |            0 |                  0 |
   +----------------------------+----------------------------+------------------+-------+------------+----------------+-----------+-----------+--------------+--------------------+

   ```
 3. 直接删除该资源池。

   ```unknow
   obclient> DROP RESOURCE POOL <pool_name>;

   ```

上一篇

[DELETE SERVER 成功的条件](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000210135)

下一篇

[删除服务器错误，错误代码 4018](https://www.oceanbase.com/knowledge-base/oceanbase-database-20000000122) ![有帮助](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)[AI](https://www.oceanbase.com/obi) 咨询热线
