This topic describes how to migrate a resource unit from an OceanBase Database tenant.
Scenarios
You can migrate resource units from one OBServer node to another within the same zone to control resource allocation and replica distribution across OBServer nodes.
You can manually migrate resource units or enable automatic migration by using RootService. When automatic migration is enabled, RootService automatically migrates resource units based on the distribution of resources. This ensures a resource balance among OBServer nodes. This feature is easy to use and does not require manual interruptions. For more information, see the Technical principles section in this topic.
You can disable automatic migration in the following scenarios:
You want to control the resource allocation of specific OBServer nodes.
You want to control the timing for complementing the replica of a faulty OBServer node.
You want to prevent resource unit migration from affecting the traffic of applications.
Note
If you want to manually migrate resource units all the time, you can perform the following operations to disable automatic migration.
- If you use OceanBase Cloud Platform (OCP) V4.2.0 or later, choose Clusters > Resource Management > Unit Distribution and disable Automatic Migration.
- If you use OCP of a version earlier than V4.2.0, choose Clusters > Parameter Management and change the value of the
enable_rebalanceparameter tofalse.
Technical principles
When RootService detects an imbalance of resources, such as CPU and memory resources, it automatically initiates resource unit migration to maintain resource balancing. RootService first calculates the resource usage of each OBServer node based on a predefined resource usage algorithm, and then keeps migrating resource units, so that the resource usage of each OBServer node is lower than that before the resource unit migration.
The resource unit balancing strategy is controlled by the server_balance_cpu_mem_tolerance_percent parameter, which specifies the maximum difference between the unit load of an OBServer node and the average unit load. When the specified threshold is exceeded, RootService starts scheduling unit balancing, until the difference between the unit load of every OBServer node and the average unit load reduces to below the specified threshold.
Procedure
You can perform the following steps to manually initiate a unit migration task.
Initiate a unit migration task.
Choose Clusters > Resource Management > Unit Distribution, click the resource unit that you want to migrate, and specify the migration destination in the dialog box that appears.
Notice
The migration destination must be located in the same zone as the source and have sufficient resources.
Wait until the unit migration is complete.
The Unit Distribution page displays the resource units that are being migrated.
You can execute the following statement to query the tasks of RootService and view the unit migration progress:
SELECT * FROM oceanbase.DBA_OB_UNIT_JOBS WHERE JOB_TYPE = 'MIGRATE_UNIT';