---
title: 集群参数 enable_rereplication 介绍-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于集群参数 enable_rereplication 介绍相关的常见问题和使用技巧，帮助您快速解决集群参数 enable_rereplication 介绍的难题。
---
切换语言

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

划线反馈

# 集群参数 enable_rereplication 介绍

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

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

多副本 OceanBase 集群中，通过 `enable_rereplication` 可以控制是否自动补全分区副本。

## 适用版本

OceanBase 数据库 V2.x、V3.x 版本。

## 参数介绍

在扩缩容场景或者发生宕机恢复后，如果集群参数 `enable_rereplication = true`，OceanBase 集群会自动补充缺失的副本。

| 属性 | 描述 |
| --- | --- |
| 参数类型 | 布尔类型 |
| 默认值 | True |
| 取值范围 | 1. True 2. False |
| 是否重启 OBServer 生效 | 否 |

## 使用示例

我们使用以下测试案例来验证 `enable_rereplication` 对补副本操作的影响。

## 参数 enable_rereplication = True 的测试

集群会自动补充缺失的副本。

1. 查询 `enable_rereplication` 设置为 true。

   ```shell
   obclient [CHUER]> show parameters like 'enable_rereplication';

   ```

   ```
   +-------+----------+-------------+----------+----------------------+-----------+-------+----------------------------------------------------------------------------------------------------------+--------------+---------+---------+-------------------+
   | ZONE  | SVR_TYPE | SVR_IP      | SVR_PORT | NAME                 | DATA_TYPE | VALUE | INFO                                                                                                     | SECTION      | SCOPE   | SOURCE  | EDIT_LEVEL        |
   +-------+----------+-------------+----------+----------------------+-----------+-------+----------------------------------------------------------------------------------------------------------+--------------+---------+---------+-------------------+
   | zone2 | observer | 172.xx.x.xx |     2882 | enable_rereplication | NULL      | True  | specifies whether the partition auto-replication is turned on. Value:  True:turned on  False: turned off | LOAD_BALANCE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
   | zone1 | observer | 172.xx.x.xx |     2882 | enable_rereplication | NULL      | True  | specifies whether the partition auto-replication is turned on. Value:  True:turned on  False: turned off | LOAD_BALANCE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
   | zone3 | observer | 172.xx.x.xx |     2882 | enable_rereplication | NULL      | True  | specifies whether the partition auto-replication is turned on. Value:  True:turned on  False: turned off | LOAD_BALANCE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
   +-------+----------+-------------+----------+----------------------+-----------+-------+----------------------------------------------------------------------------------------------------------+--------------+---------+---------+-------------------+
   3 rows in set (0.108 sec)

   ```

   ```shell
   obclient [oceanbase]> select zone,name,value,info from __all_zone where name in ('status','zone_type');

   ```

   ```
   +-------+-----------+-------+-----------+
   | zone  | name      | value | info      |
   +-------+-----------+-------+-----------+
   | zone1 | status    |     2 | ACTIVE    |
   | zone1 | zone_type |     0 | ReadWrite |
   | zone2 | status    |     2 | ACTIVE    |
   | zone2 | zone_type |     0 | ReadWrite |
   | zone3 | status    |     1 | INACTIVE  |
   | zone3 | zone_type |     0 | ReadWrite |
   +-------+-----------+-------+-----------+
   6 rows in set (0.09 sec)

   ```

   ```shell
   obclient [CHUER]> create table t1 (id int ,col varchar2(10));
   Query OK, 0 rows affected (0.276 sec)

   ```
 2. 查询表分区副本情况。

   ```shell
   obclient [oceanbase]> select t.tenant_name,db.database_name ,tb.table_name, p.partition_id ,p.zone  
       from gv$partition p,__all_virtual_table tb,__all_virtual_database db,__all_tenant t
       where t.tenant_id=db.tenant_id and t.tenant_id=tb.tenant_id and t.tenant_id=p.tenant_id
           and db.database_id=tb.database_id and tb.table_id=p.table_id
       and tenant_name='t_oracle'
       and database_name='CHUER'
       and tb.table_name='T1'
       ;

   ```

   ```
   +-------------+---------------+------------+--------------+-------+
   | tenant_name | database_name | table_name | partition_id | zone  |
   +-------------+---------------+------------+--------------+-------+
   | t_oracle    | CHUER         | T1         |            0 | zone2 |
   | t_oracle    | CHUER         | T1         |            0 | zone1 |
   +-------------+---------------+------------+--------------+-------+
   2 rows in set (0.29 sec)

   ```
 3. 启动 zone 后。

   ```

   ```shell
   +-------+-----------+-------+-----------+
   | zone  | name      | value | info      |
   +-------+-----------+-------+-----------+
   | zone1 | status    |     2 | ACTIVE    |
   | zone1 | zone_type |     0 | ReadWrite |
   | zone2 | status    |     2 | ACTIVE    |
   | zone2 | zone_type |     0 | ReadWrite |
   | zone3 | status    |     2 | ACTIVE    |
   | zone3 | zone_type |     0 | ReadWrite |
   +-------+-----------+-------+-----------+
   6 rows in set (0.00 sec)

   ```

   ```shell
   obclient [oceanbase]> select gmt_create,gmt_modified,svr_ip,zone,with_rootserver,status from   __all_server;

   ```

   ```shell
   +----------------------------+----------------------------+-------------+-------+-----------------+--------+
   | gmt_create                 | gmt_modified               | svr_ip      | zone  | with_rootserver | status |
   +----------------------------+----------------------------+-------------+-------+-----------------+--------+
   | 2023-06-15 01:55:17.788504 | 2023-07-03 16:01:57.250198 | 172.xx.x.xx | zone1 |               1 | active |
   | 2023-06-15 01:55:17.722023 | 2023-07-03 16:01:57.260188 | 172.xx.x.xx | zone2 |               0 | active |
   | 2023-06-15 01:55:17.712516 | 2023-07-21 12:58:20.312848 | 172.xx.x.xx | zone3 |               0 | active |
   +----------------------------+----------------------------+-------------+-------+-----------------+--------+
   3 rows in set (0.01 sec)

   ```
 4. 查询 zone 恢复后的副本情况，副本自动补全。

   ```shell
   obclient [oceanbase]> select t.tenant_name,db.database_name ,tb.table_name, p.partition_id ,p.zone  
       -> from gv$partition p,__all_virtual_table tb,__all_virtual_database db,__all_tenant t
       ->   where t.tenant_id=db.tenant_id and t.tenant_id=tb.tenant_id and t.tenant_id=p.tenant_id
       ->     and db.database_id=tb.database_id and tb.table_id=p.table_id
       -> and tenant_name='t_oracle'
       -> and database_name='CHUER'
       -> and tb.table_name='T1'
       -> ;

   ```

   ```shell
   +-------------+---------------+------------+--------------+-------+
   | tenant_name | database_name | table_name | partition_id | zone  |
   +-------------+---------------+------------+--------------+-------+
   | t_oracle    | CHUER         | T1         |            0 | zone3 |
   | t_oracle    | CHUER         | T1         |            0 | zone2 |
   | t_oracle    | CHUER         | T1         |            0 | zone1 |
   +-------------+---------------+------------+--------------+-------+
   3 rows in set (0.32 sec)

   ```

### 参数 enable_rereplication = False 的测试

集群不会自动补充副本。重新设置为 true 后，副本自动补全。

1. 查询 `enable_rereplication` 设置为 false。

   ```

   ```shell
   +-------+----------+-------------+----------+----------------------+-----------+-------+----------------------------------------------------------------------------------------------------------+--------------+---------+---------+-------------------+
   | ZONE  | SVR_TYPE | SVR_IP      | SVR_PORT | NAME                 | DATA_TYPE | VALUE | INFO                                                                                                     | SECTION      | SCOPE   | SOURCE  | EDIT_LEVEL        |
   +-------+----------+-------------+----------+----------------------+-----------+-------+----------------------------------------------------------------------------------------------------------+--------------+---------+---------+-------------------+
   | zone2 | observer | 172.xx.x.xx |     2882 | enable_rereplication | NULL      | False | specifies whether the partition auto-replication is turned on. Value:  True:turned on  False: turned off | LOAD_BALANCE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
   | zone3 | observer | 172.xx.x.xx |     2882 | enable_rereplication | NULL      | False | specifies whether the partition auto-replication is turned on. Value:  True:turned on  False: turned off | LOAD_BALANCE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
   | zone1 | observer | 172.xx.x.xx |     2882 | enable_rereplication | NULL      | False | specifies whether the partition auto-replication is turned on. Value:  True:turned on  False: turned off | LOAD_BALANCE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
   +-------+----------+-------------+----------+----------------------+-----------+-------+----------------------------------------------------------------------------------------------------------+--------------+---------+---------+-------------------+
   3 rows in set (0.049 sec)

   ```
 2. 停止 zone。

   ```

   ```
   +-------+-----------+-------+-----------+
   | zone  | name      | value | info      |
   +-------+-----------+-------+-----------+
   | zone1 | status    |     2 | ACTIVE    |
   | zone1 | zone_type |     0 | ReadWrite |
   | zone2 | status    |     2 | ACTIVE    |
   | zone2 | zone_type |     0 | ReadWrite |
   | zone3 | status    |     1 | INACTIVE  |
   | zone3 | zone_type |     0 | ReadWrite |
   +-------+-----------+-------+-----------+
   6 rows in set (0.00 sec)

   ```
 3. 查询副本情况。

   ```shell
   obclient [oceanbase]> select t.tenant_name,db.database_name ,tb.table_name, p.partition_id ,p.zone  
       ->      from gv$partition p,__all_virtual_table tb,__all_virtual_database db,__all_tenant t
       ->      where t.tenant_id=db.tenant_id and t.tenant_id=tb.tenant_id and t.tenant_id=p.tenant_id
       ->      and db.database_id=tb.database_id and tb.table_id=p.table_id
       ->      and tenant_name='t_oracle'
       ->      and database_name='CHUER'
       ->      and tb.table_name='T2'
       ->      ;

   ```

   ```shell
   +-------------+---------------+------------+--------------+-------+
   | tenant_name | database_name | table_name | partition_id | zone  |
   +-------------+---------------+------------+--------------+-------+
   | t_oracle    | CHUER         | T2         |            0 | zone2 |
   | t_oracle    | CHUER         | T2         |            0 | zone1 |
   +-------------+---------------+------------+--------------+-------+
   2 rows in set (0.31 sec)

   ```
 4. 启用 zone。

   ```

   ```shell
   +----------------------------+----------------------------+-------------+-------+-----------------+--------+
   | gmt_create                 | gmt_modified               | svr_ip      | zone  | with_rootserver | status |
   +----------------------------+----------------------------+-------------+-------+-----------------+--------+
   | 2023-06-15 01:55:17.788504 | 2023-07-03 16:01:57.250198 | 172.xx.x.xx | zone1 |               1 | active |
   | 2023-06-15 01:55:17.722023 | 2023-07-03 16:01:57.260188 | 172.xx.x.xx | zone2 |               0 | active |
   | 2023-06-15 01:55:17.712516 | 2023-07-21 14:21:56.645521 | 172.xx.x.xx | zone3 |               0 | active |
   +----------------------------+----------------------------+-------------+-------+-----------------+--------+
   3 rows in set (0.01 sec)

   ```

   ```

   ```shell
   +-------+-----------+-------+-----------+
   | zone  | name      | value | info      |
   +-------+-----------+-------+-----------+
   | zone1 | status    |     2 | ACTIVE    |
   | zone1 | zone_type |     0 | ReadWrite |
   | zone2 | status    |     2 | ACTIVE    |
   | zone2 | zone_type |     0 | ReadWrite |
   | zone3 | status    |     2 | ACTIVE    |
   | zone3 | zone_type |     0 | ReadWrite |
   +-------+-----------+-------+-----------+
   6 rows in set (0.01 sec)

   ```
 5. 查询 zone 恢复后的副本情况，副本不会补全。

   ```

   ```shell
   +-------------+---------------+------------+--------------+-------+
   | tenant_name | database_name | table_name | partition_id | zone  |
   +-------------+---------------+------------+--------------+-------+
   | t_oracle    | CHUER         | T2         |            0 | zone2 |
   | t_oracle    | CHUER         | T2         |            0 | zone1 |
   +-------------+---------------+------------+--------------+-------+
   2 rows in set (0.29 sec)

   ```
 6. 重新设置为 true 后，副本自动补全。

   ```shell
   obclient [oceanbase]>  alter system set enable_rereplication=true;
   Query OK, 0 rows affected (0.08 sec)

   ```

   ```shell
   obclient [oceanbase]> select t.tenant_name,db.database_name ,tb.table_name, p.partition_id ,p.zone from gv$partition p,__all_virtual_table tb,__all_virtual_database db,__all_tenant t where t.tenant_id=db.tenant_id and t.tenant_id=tb.tenant_id and t.tenant_id=p.tenant_id and db.database_id=tb.database_id and tb.table_id=p.table_id and tenant_name='t_oracle' and database_name='CHUER' and tb.table_name='T2';

   ```

   ```shell
   +-------------+---------------+------------+--------------+-------+
   | tenant_name | database_name | table_name | partition_id | zone  |
   +-------------+---------------+------------+--------------+-------+
   | t_oracle    | CHUER         | T2         |            0 | zone3 |
   | t_oracle    | CHUER         | T2         |            0 | zone2 |
   | t_oracle    | CHUER         | T2         |            0 | zone1 |
   +-------------+---------------+------------+--------------+-------+
   3 rows in set (0.35 sec)

   ```

上一篇

[__all_server 视图中 block_migrate_in_time 存在值的原因](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000207635)

下一篇

[日志型副本 migrate unit 为什么慢](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000262235) ![有帮助](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) 咨询热线
