OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.3

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.3
    iconOceanBase Database
    SQL - V 4.3.3
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Migrate replicas

    Last Updated:2025-11-27 02:38:06  Updated
    Share
    What is on this page
    Migrate units
    Manually migrate a replica
    Limitations
    Prerequisites
    Procedure
    References

    folded

    Share

    This topic describes how to migrate replicas. After you migrate replicas within a zone, the locations of the replicas change, but the number of replicas and the types of replicas in the zone remain unchanged. This feature is applicable to OBServer node failure scenarios and load balancing scenarios.

    Migrate units

    This section describes how to migrate units between OBServer nodes within a single zone. You can migrate log stream replicas of a tenant by migrating units of the tenant.

    The following example describes how to migrate the unit with the ID of 1006 in the mq_t1 tenant to another OBServer node in the same zone.

    1. Log in to the sys tenant of the cluster as the root user.

      obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -A
      
    2. Access the database named oceanbase.

      obclient>use oceanbase;
      
    3. Query the tenant ID of the mq_t1 tenant.

      In this example, the tenant ID of the mq_t1 tenant is 1004.

      obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';
      +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+
      | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME                | MODIFY_TIME                | PRIMARY_ZONE                           | LOCALITY                                                         | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN            | REPLAYABLE_SCN      | READABLE_SCN        | RECOVERY_UNTIL_SCN  | LOG_MODE     | ARBITRATION_SERVICE_STATUS |
      +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+
      |      1004 | mq_t1       | USER        | 2023-01-04 11:57:11.384141 | 2023-01-04 11:57:37.866707 | sa128_obv4_1;sa128_obv4_2              | FULL{1}@sa128_obv4_1, FULL{1}@sa128_obv4_2                       | NULL              | MYSQL              | NORMAL | NO            | NO     | PRIMARY     | NORMAL            |                0 | 1684396167132057328 | 1684396167132057328 | 1684396167051160964 | 4611686018427387903 | NOARCHIVELOG | DISABLED                   |
      +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+
      1 row in set
      
    4. Query units of the mq_t1 tenant.

      In this example, the unit with the ID of 1006 is located on the OBServer node with the IP address of xx.xx.xx.19 in the sa128_obv4_3 zone.

      obclient> SELECT * FROM oceanbase.DBA_OB_UNITS WHERE TENANT_ID = 1004;
      +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
      | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME                | MODIFY_TIME                | ZONE         | SVR_IP     | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
      +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
      |    1004 |      1004 | ACTIVE |             1005 |          1002 | 2023-01-04 11:48:36.582413 | 2023-01-04 11:57:11.387383 | sa128_obv4_1 | xx.xx.xx.47  |     2882 | NULL                |                  NULL | NULL           |           1006 |       3 |       3 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
      |    1005 |      1004 | ACTIVE |             1005 |          1002 | 2023-01-04 11:48:36.591414 | 2023-01-04 11:57:11.388449 | sa128_obv4_2 | xx.xx.xx.81 |     2882 | NULL                |                  NULL | NULL           |           1006 |       3 |       3 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
      |    1006 |      1004 | ACTIVE |             1005 |          1002 | 2023-01-04 14:13:36.980799 | 2023-01-04 14:13:36.980799 | sa128_obv4_3 | xx.xx.xx.19 |     2882 | NULL                |                  NULL | NULL           |           1006 |       3 |       3 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
      +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
      3 rows in set
      
    5. Query the IP addresses of OBServer nodes in the zone where the unit to be migrated resides.

      In this example, the sa128_obv4_3 zone contains two OBServer nodes with the IP addresses of xx.xx.xx.19 and xx.xx.xx.158.

      obclient> SELECT * FROM oceanbase.DBA_OB_SERVERS;
      +-------------+----------+----+--------------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
      | SVR_IP      | SVR_PORT | ID | ZONE         | SQL_PORT | WITH_ROOTSERVER | STATUS | START_SERVICE_TIME         | STOP_TIME | BLOCK_MIGRATE_IN_TIME | CREATE_TIME                | MODIFY_TIME                | BUILD_VERSION                                                                             |
      +-------------+----------+----+--------------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
      | xx.xx.xx.81  |     2882 |  6 | sa128_obv4_2 |     2881 | NO              | ACTIVE | 2022-12-30 16:17:03.173519 | NULL      | NULL                  | 2022-12-30 16:08:04.749100 | 2023-01-04 11:48:36.589270 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec  7 2022 16:22:15) |
      | xx.xx.xx.19  |     2882 |  4 | sa128_obv4_3 |     2881 | NO              | ACTIVE | 2022-12-30 16:36:35.567437 | NULL      | NULL                  | 2022-12-30 16:08:02.755200 | 2023-01-04 14:13:36.976548 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec  7 2022 16:22:15) |
      | xx.xx.xx.158 |     2882 |  3 | sa128_obv4_3 |     2881 | NO              | ACTIVE | 2022-12-12 12:42:00.054759 | NULL      | NULL                  | 2022-11-03 15:37:09.530894 | 2022-12-22 14:43:26.717736 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec  7 2022 16:22:15) |
      | xx.xx.xx.43   |     2882 |  1 | sa128_obv4_1 |     2881 | NO              | ACTIVE | 2022-12-12 12:25:17.555651 | NULL      | NULL                  | 2022-11-03 15:37:08.990683 | 2022-12-12 12:25:18.553763 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec  7 2022 16:22:15) |
      | xx.xx.xx.106  |     2882 |  2 | sa128_obv4_2 |     2881 | YES             | ACTIVE | 2022-12-12 11:46:37.222980 | NULL      | NULL                  | 2022-11-03 15:37:09.490511 | 2022-12-12 11:47:31.075335 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec  7 2022 16:22:15) |
      | xx.xx.xx.47   |     2882 |  5 | sa128_obv4_1 |     2881 | NO              | ACTIVE | 2022-12-30 16:25:45.420996 | NULL      | NULL                  | 2022-12-30 16:08:03.928478 | 2023-01-04 11:48:36.578231 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec  7 2022 16:22:15) |
      +-------------+----------+----+--------------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
      6 rows in set
      
    6. Migrate the unit with the ID of 1006 in the mq_t1 tenant to another OBServer node in the same zone.

      obclient> ALTER SYSTEM migrate unit = 1006 destination = 'xx.xx.xx.158:2882';
      Query OK, 0 rows affected 
      
    7. Query the status of the unit migration job.

      obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_JOBS WHERE JOB_TYPE = 'MIGRATE_UNIT';
      +--------+--------------+------------+-------------+----------+----------------------------+----------------------------+-----------+---------+----------+------------+------------+-------------+
      | JOB_ID | JOB_TYPE     | JOB_STATUS | RESULT_CODE | PROGRESS | START_TIME                 | MODIFY_TIME                | TENANT_ID | UNIT_ID | SQL_TEXT | EXTRA_INFO | RS_SVR_IP  | RS_SVR_PORT |
      +--------+--------------+------------+-------------+----------+----------------------------+----------------------------+-----------+---------+----------+------------+------------+-------------+
      |      4 | MIGRATE_UNIT | INPROGRESS |        NULL |        0 | 2023-01-04 17:22:02.208219 | 2023-01-04 17:22:02.208219 |      1004 |    1006 | NULL     | NULL       | xx.xx.xx.106 |        2882 |
      +--------+--------------+------------+-------------+----------+----------------------------+----------------------------+-----------+---------+----------+------------+------------+-------------+
      1 row in set
      

      The value of JOB_STATUS in the query result indicates the job status. INPROGRESS indicates that the migration job is in progress, and SUCCESS indicates that the migration job is successful.

    8. Query the information of the migrated unit.

      obclient> SELECT * FROM oceanbase.DBA_OB_UNITS WHERE UNIT_ID = 1006;
      +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
      | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME                | MODIFY_TIME                | ZONE         | SVR_IP      | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
      +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
      |    1006 |      1004 | ACTIVE |             1005 |          1002 | 2023-01-04 14:13:36.980799 | 2023-01-04 17:22:02.210245 | sa128_obv4_3 | xx.xx.xx.158 |     2882 | xx.xx.xx.19          |                  2882 | YES            |           1006 |       3 |       3 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
      +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
      3 rows in set
      

      The query result shows that the unit with the ID of 1006 has been migrated from the OBServer node with the IP address of xx.xx.xx.19 to the OBServer node with the IP address of xx.xx.xx.158.

    Manually migrate a replica

    After you migrate the unit of a replica, the replica position may be different from the unit position. In this case, you can execute the ALTER SYSTEM MIGRATE REPLICA statement to migrate the replica to the specified position.

    Limitations

    • You can migrate log stream replicas of all tenants in the sys tenant but migrate only log stream replicas of the current tenant in a user tenant.

    • One log stream of a tenant supports only one replica task at a time, such as a task to add replicas, remove replicas, convert the type of a replica, modify the number of Paxos replicas of a log stream, or migrate replicas.

      You can query ongoing replica tasks from the CDB_OB_LS_REPLICA_TASKS view in the sys tenant or from the DBA_OB_LS_REPLICA_TASKS view in a user tenant.

    • You can migrate replicas only within the same zone.

    Prerequisites

    • You have the ALTER SYSTEM privilege.

    • You have the SELECT privilege on the following views:

      • DBA_OB_TENANTS

      • DBA_OB_LS/CDB_OB_LS

      • GV$OB_UNITS

      • DBA_OB_LS_LOCATIONS/CDB_OB_LS_LOCATIONS

    • The destination OBServer node has an available unit that does not contain replicas of the log stream.

    Procedure

    Assume that you have executed the ALTER SYSTEM MIGRATE UNIT = 1003 DESTINATION = '100.xx.xx.002:5072'; statement in a tenant named tenant1 to migrate its unit with the ID of 1003 to OBServer node 100.xx.xxx.002:5072, but the system has not properly migrated the replica due to exceptions. To manually migrate the replica to OBServer node 100.xx.xxx.002:5072, perform the following steps:

    1. Log in to the target tenant.

      Here is an example:

      obclient -h172.30.xxx.xxx -P2883 -uroot@tenant1#obdemo -pxxxx -A
      

      For more information about how to connect to a database, see Overview (MySQL mode) or Overview (Oracle mode).

    2. Query the tenant ID of the target tenant.

      • sys tenant

        obclient [oceanbase]> SELECT TENANT_NAME,TENANT_ID FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME='tenant1';
        
      • User tenant

        MySQL mode
        Oracle mode

        Execute the following statement in MySQL mode:

        obclient [oceanbase]> SELECT TENANT_NAME,TENANT_ID FROM oceanbase.DBA_OB_TENANTS;
        

        Execute the following statement in Oracle mode:

        obclient [SYS]> SELECT TENANT_NAME,TENANT_ID FROM SYS.DBA_OB_TENANTS;
        

        A sample query result is as follows:

        +-------------+-----------+
        | TENANT_NAME | TENANT_ID |
        +-------------+-----------+
        | tenant1     |      1002 |
        +-------------+-----------+
        1 row in set
        

        The query result shows that the tenant ID is 1002.

        For more information about the fields in the DBA_OB_TENANTS view, see DBA_OB_TENANTS.

    3. Query all log streams of the target tenant.

      • sys tenant

        obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS WHERE TENANT_ID=1002;
        

        For more information about the fields in the CDB_OB_LS view, see CDB_OB_LS.

      • User tenant

        MySQL mode
        Oracle mode

        Execute the following statement in MySQL mode:

        obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS;
        

        Execute the following statement in Oracle mode:

        obclient [SYS]> SELECT * FROM SYS.DBA_OB_LS;
        

        A sample query result is as follows:

        +-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+
        | LS_ID | STATUS | PRIMARY_ZONE | UNIT_GROUP_ID | LS_GROUP_ID | CREATE_SCN          | DROP_SCN | SYNC_SCN            | READABLE_SCN        | FLAG      |
        +-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+
        |     1 | NORMAL | z1;z2        |             0 |           0 |                NULL |     NULL | 1712455113896017202 | 1712455113896017202 |           |
        |  1001 | NORMAL | z1;z2        |          1001 |        1001 | 1712125812893680165 |     NULL | 1712455113896017202 | 1712455113896017202 |           |
        |  1002 | NORMAL | z1;z2        |          1002 |        1002 | 1712125812908098857 |     NULL | 1712455114041323052 | 1712455113540551113 |           |
        |  1003 | NORMAL | z1;z2        |             0 |           0 | 1712125828880850585 |     NULL | 1712455113896017202 | 1712455113896017202 | DUPLICATE |
        +-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+
        4 rows in set
        

        The query result shows that the tenant1 tenant has log streams 1, 1001, and 1002, as well as broadcast log stream 1003.

        For more information about the fields in the DBA_OB_LS view, see DBA_OB_LS.

    4. Query units of the target tenant.

      • sys tenant

        obclient [oceanbase]> SELECT * FROM oceanbase.GV$OB_UNITS WHERE TENANT_ID=1002;
        
      • User tenant

        MySQL mode
        Oracle mode

        Execute the following statement in MySQL mode:

        obclient [oceanbase]> SELECT * FROM oceanbase.GV$OB_UNITS;
        

        Execute the following statement in Oracle mode:

        obclient [SYS]> SELECT * FROM SYS.GV$OB_UNITS;
        

        A sample query result is as follows:

        +----------------+----------+---------+-----------+------+-----------+----------------+---------+---------+-------------+---------------------+---------------------+-------------+---------------+-----------------+------------------+--------+----------------------------+
        | SVR_IP         | SVR_PORT | UNIT_ID | TENANT_ID | ZONE | ZONE_TYPE | REGION         | MAX_CPU | MIN_CPU | MEMORY_SIZE | MAX_IOPS            | MIN_IOPS            | IOPS_WEIGHT | LOG_DISK_SIZE | LOG_DISK_IN_USE | DATA_DISK_IN_USE | STATUS | CREATE_TIME                |
        +----------------+----------+---------+-----------+------+-----------+----------------+---------+---------+-------------+---------------------+---------------------+-------------+---------------+-----------------+------------------+--------+----------------------------+
        | 100.xx.xxx.012 |     5070 |    1002 |      1002 | z1   | ReadWrite | default_region |       2 |       2 |  1073741824 | 9223372036854775807 | 9223372036854775807 |           2 |    5798205850 |        75552460 |                0 | NORMAL | 2023-11-05 22:03:30.630137 |
        | 100.xx.xxx.002 |     5072 |    1004 |      1002 | z2   | ReadWrite | default_region |       2 |       2 |  1073741824 | 9223372036854775807 | 9223372036854775807 |           2 |    5798205850 |        75552460 |                0 | NORMAL | 2023-11-05 22:03:30.634915 |
        | 100.xx.xxx.003 |     5073 |    1003 |      1002 | z2   | ReadWrite | default_region |       2 |       2 |  1073741824 | 9223372036854775807 | 9223372036854775807 |           2 |    5798205850 |       169443835 |         12582912 | NORMAL | 2023-11-05 22:03:30.633004 |
        | 100.xx.xxx.001 |     5071 |    1001 |      1002 | z1   | ReadWrite | default_region |       2 |       2 |  1073741824 | 9223372036854775807 | 9223372036854775807 |           2 |    5798205850 |       169443835 |         14680064 | NORMAL | 2023-11-05 22:03:30.627247 |
        | 100.xx.xxx.004 |     5074 |    1006 |      1002 | z3   | ReadWrite | default_region |       2 |       2 |  1073741824 | 9223372036854775807 | 9223372036854775807 |           2 |    5798205850 |       151021679 |                0 | NORMAL | 2023-11-05 22:03:30.638615 |
        | 100.xx.xxx.005 |     5075 |    1005 |      1002 | z3   | ReadWrite | default_region |       2 |       2 |  1073741824 | 9223372036854775807 | 9223372036854775807 |           2 |    5798205850 |               0 |                0 | NORMAL | 2023-11-05 22:03:30.636885 |
        +----------------+----------+---------+-----------+------+-----------+----------------+---------+---------+-------------+---------------------+---------------------+-------------+---------------+-----------------+------------------+--------+----------------------------+
        6 rows in set
        

        The query result shows that the tenant has available units on OBServer nodes 100.xx.xxx.012:5070, 100.xx.xxx.002:5072, 100.xx.xxx.003:5073, 100.xx.xxx.001:5071, 100.xx.xxx.004:5074, and 100.xx.xxx.005:5075, and the unit with the ID of 1003 resides on OBServer node 100.xx.xxx.003:5073.

        For more information about the fields in the GV$OB_UNITS view, see GV$OB_UNITS.

    5. Query the replica distribution of log stream 1002 based on the obtained log stream information.

      • sys tenant

        obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_LOCATIONS WHERE LS_ID=1002 AND TENANT_ID=1002;
        

        For more information about the fields in the CDB_OB_LS_LOCATIONS view, see CDB_OB_LS_LOCATIONS.

      • User tenant

        MySQL mode
        Oracle mode

        Execute the following statement in MySQL mode:

        obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;
        

        Execute the following statement in Oracle mode:

        obclient [SYS]> SELECT * FROM SYS.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;
        

        A sample query result is as follows:

        +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+
        | CREATE_TIME                | MODIFY_TIME                | LS_ID | SVR_IP         | SVR_PORT | SQL_PORT | ZONE | ROLE     | MEMBER_LIST                                                                                     | PAXOS_REPLICA_NUMBER | REPLICA_TYPE | LEARNER_LIST | REBUILD |
        +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+
        | 2023-11-05 23:52:15.716363 | 2023-11-05 23:52:24.212243 |  1002 | 100.xx.xxx.003 |     5073 |     5107 | z2   | LEADER   | 100.xx.xxx.003:5073:1699199535653021,100.xx.xxx.012:5070:1,100.xx.xxx.004:5074:1699194477097063 |                    3 | FULL         |              | FALSE   |
        | 2023-11-05 22:05:20.420160 | 2023-11-05 23:52:24.807711 |  1002 | 100.xx.xxx.012 |     5070 |     5105 | z1   | FOLLOWER | NULL                                                                                            |                 NULL | FULL         |              | FALSE   |
        | 2023-11-05 22:27:57.157395 | 2023-11-05 23:52:24.361105 |  1002 | 100.xx.xxx.004 |     5074 |     5109 | z3   | FOLLOWER | NULL                                                                                            |                 NULL | FULL         |              | FALSE   |
        +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+
        3 rows in set
        

        The query result shows that the replica on OBServer node 100.xx.xxx.003:5073 needs to be migrated and that the replica resides in zone z2. You can find an available unit in the same zone based on the units queried in the previous step. In this example, you can migrate the replica to OBServer node 100.xx.xxx.002:5072.

    6. Execute the ALTER SYSTEM MIGRATE REPLICA statement to migrate the replica.

      The syntax is as follows:

      ALTER SYSTEM MIGRATE REPLICA LS [=] ls_id SOURCE [=] 'svr_ip:svr_port' DESTINATION [=] 'destination_ip:destination_port' [DATA_SOURCE [=] 'data_source'] [TENANT [=] 'tenant_name']
      

      The parameters in the syntax are described as follows:

      • ls_id: the ID of the log stream for which you want to migrate the replica.

      • svr_ip:svr_port: the IP address and port number of the OBServer node from which you want to migrate the replica, for example, 100.xx.xxx.003:5073.

      • destination_ip:destination_port: the IP address and port number of the OBServer node to which you want to migrate the replica, for example, 100.xx.xxx.002:5072.

      • data_source: the data source of the replica that you want to migrate. You can select any other replica of the log stream as the data source based on your business needs, for example, 100.xx.xxx.004:5074.

        If the specified data source is unavailable, the system will return an error. If this parameter is not specified, the system automatically selects an available data source.

      • tenant_name: the name of the target tenant. You can specify another tenant in the sys tenant and specify only the current tenant in a user tenant. If this parameter is not specified, the name of the current tenant is used. You cannot use the all, all_user, or all_meta option in this statement to specify all tenants, all user tenants, or all meta tenants.

      • This statement migrates only one replica at a time. To migrate multiple replicas, you must execute this statement multiple times.

      Here is an example:

      obclient> ALTER SYSTEM MIGRATE REPLICA LS = 1002 SOURCE='100.xx.xxx.003:5073' DESTINATION = '100.xx.xxx.002:5072'
      
    7. Query the replica distribution of the log stream again.

      • sys tenant

        obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_LOCATIONS WHERE LS_ID=1002 AND TENANT_ID=1002;
        
      • User tenant

        MySQL mode
        Oracle mode

        Execute the following statement in MySQL mode:

        obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;
        

        Execute the following statement in Oracle mode:

        obclient [SYS]> SELECT * FROM SYS.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;
        

        A sample query result is as follows:

        +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+
        | CREATE_TIME                | MODIFY_TIME                | LS_ID | SVR_IP         | SVR_PORT | SQL_PORT | ZONE | ROLE     | MEMBER_LIST                                                                                     | PAXOS_REPLICA_NUMBER | REPLICA_TYPE | LEARNER_LIST | REBUILD |
        +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+
        | 2023-11-06 00:05:39.520972 | 2023-11-06 00:05:49.101503 |  1002 | 100.xx.xxx.002 |     5072 |     5106 | z2   | LEADER   | 100.xx.xxx.002:5072:1699200339454143,100.xx.xxx.012:5070:1,100.xx.xxx.004:5074:1699194477097063 |                    3 | FULL         |              | FALSE   |
        | 2023-11-05 22:05:20.420160 | 2023-11-06 00:05:50.037494 |  1002 | 100.xx.xxx.012 |     5070 |     5105 | z1   | FOLLOWER | NULL                                                                                            |                 NULL | FULL         |              | FALSE   |
        | 2023-11-05 22:27:57.157395 | 2023-11-06 00:05:49.484669 |  1002 | 100.xx.xxx.004 |     5074 |     5109 | z3   | FOLLOWER | NULL                                                                                            |                 NULL | FULL         |              | FALSE   |
        +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+
        3 rows in set
        

        The query result shows that the replica of log stream 1002 on OBServer node 100.xx.xxx.003:5073 has been migrated to OBServer node 100.xx.xxx.002:5072.

    References

    • Add replicas

    • Remove replicas

    • Convert the type of a replica

    • Modify the number of Paxos replicas of a log stream

    • Cancel a replica task

    Previous topic

    View the locality change history
    Last

    Next topic

    Modify the number of Paxos replicas of a log stream
    Next
    What is on this page
    Migrate units
    Manually migrate a replica
    Limitations
    Prerequisites
    Procedure
    References