Skip to main content

2.5 View the resource usage of an OceanBase cluster

Before business development, the DBA must create a database instance (tenant) in the OceanBase cluster. An OceanBase cluster supports multiple tenants. This architecture is called multitenancy.

Working mechanism of multitenancy

OceanBase Database is deployed and run as a cluster and provides tenants in the cluster for business systems. In a sense, tenants are comparable to "instances" in a conventional database system. In OceanBase Database, tenants are totally isolated. In terms of data security, OceanBase Database forbids cross-tenant access to prevent data assets of a tenant from being stolen by other tenants. In terms of resource usage, OceanBase Database ensures that tenants "exclusively" occupy their allocated resource quotas. In summary, a tenant can be seen as a container for database objects and resources such as CPU, memory, and I/O resources.

OceanBase Database is a single-process software solution. Its process is named observer. By default, the observer process will occupy most of the CPU, memory, and disk resources in the operating system after it is started. You can use cluster startup parameters to specify the amount of resources that you want to allocate to the process.

As shown in the following figure, an OceanBase cluster can manage all resources allocated to the observer process in a centralized manner and allocate the resources to tenants. You can define the resource specifications for a tenant and adjust the resource specifications online.

Resource allocation

The resources for an OceanBase Database tenant include CPU, memory, and IOPS. At present, OceanBase Database supports the isolation of these resources. We recommend that you set the resource parameters based on the actual situation when you create resources. For example, the value of the parameter related to the disk space should not exceed the actual available disk space. Otherwise, load balancing is affected.

Note

Among the resources allocated to the observer process, the number of CPU cores is declaratory, and the memory and disk resources are exclusive (preallocated).

View available resources of a cluster

To ensure sufficient resources when you create user tenants, you must calculate the remaining available resources of the cluster. Each OceanBase cluster has a default tenant named sys. You can view and manage the resources in a cluster from the sys tenant. You can log on to the sys tenant of a cluster as the root user and execute the following statement to view the available resources of the cluster.

View available resources of the cluster

SELECT ZONE,SVR_IP,SVR_PORT,
CPU_CAPACITY,
CPU_ASSIGNED,
CPU_CAPACITY-CPU_ASSIGNED AS CPU_MIN_FREE,
CPU_CAPACITY_MAX,
CPU_ASSIGNED_MAX,
CPU_CAPACITY_MAX-CPU_ASSIGNED_MAX AS CPU_MAX_FREE,
ROUND(MEMORY_LIMIT/1024/1024/1024,2) AS MEMORY_TOTAL_GB,
ROUND((MEMORY_LIMIT-MEM_CAPACITY)/1024/1024/1024,2) AS SYSTEM_MEMORY_GB,
ROUND(MEM_ASSIGNED/1024/1024/1024,2) AS MEM_ASSIGNED_GB,
ROUND((MEM_CAPACITY-MEM_ASSIGNED)/1024/1024/1024,2) AS MEMORY_FREE_GB,
ROUND(LOG_DISK_CAPACITY/1024/1024/1024,2) AS LOG_DISK_CAPACITY_GB,
ROUND(LOG_DISK_ASSIGNED/1024/1024/1024,2) AS LOG_DISK_ASSIGNED_GB,
ROUND((LOG_DISK_CAPACITY-LOG_DISK_ASSIGNED)/1024/1024/1024,2) AS LOG_DISK_FREE_GB,
ROUND((DATA_DISK_CAPACITY/1024/1024/1024),2) AS DATA_DISK_GB,
ROUND((DATA_DISK_IN_USE/1024/1024/1024),2) AS DATA_DISK_USED_GB,
ROUND((DATA_DISK_CAPACITY-DATA_DISK_IN_USE)/1024/1024/1024,2) AS DATA_DISK_FREE_GB
FROM oceanbase.GV$OB_SERVERS;

The output is as follows:

+-------+----------------+----------+--------------+--------------+--------------+------------------+------------------+--------------+-----------------+------------------+-----------------+----------------+----------------------+----------------------+------------------+--------------+-------------------+-------------------+
| ZONE | SVR_IP | SVR_PORT | CPU_CAPACITY | CPU_ASSIGNED | CPU_MIN_FREE | CPU_CAPACITY_MAX | CPU_ASSIGNED_MAX | CPU_MAX_FREE | MEMORY_TOTAL_GB | SYSTEM_MEMORY_GB | MEM_ASSIGNED_GB | MEMORY_FREE_GB | LOG_DISK_CAPACITY_GB | LOG_DISK_ASSIGNED_GB | LOG_DISK_FREE_GB | DATA_DISK_GB | DATA_DISK_USED_GB | DATA_DISK_FREE_GB |
+-------+----------------+----------+--------------+--------------+--------------+------------------+------------------+--------------+-----------------+------------------+-----------------+----------------+----------------------+----------------------+------------------+--------------+-------------------+-------------------+
| zone1 | 10.10.10.1 | 2882 | 8 | 5 | 3 | 16 | 5 | 11 | 20.00 | 2.00 | 6.00 | 12.00 | 48.00 | 15.00 | 33.00 | 30.00 | 6.82 | 23.18 |
| zone2 | 10.10.10.2 | 2882 | 8 | 5 | 3 | 16 | 5 | 11 | 20.00 | 2.00 | 6.00 | 12.00 | 48.00 | 15.00 | 33.00 | 30.00 | 8.91 | 21.09 |
| zone3 | 10.10.10.3 | 2882 | 8 | 5 | 3 | 16 | 5 | 11 | 20.00 | 2.00 | 6.00 | 12.00 | 48.00 | 15.00 | 33.00 | 30.00 | 8.91 | 21.09 |
+-------+----------------+----------+--------------+--------------+--------------+------------------+------------------+--------------+-----------------+------------------+-----------------+----------------+----------------------+----------------------+------------------+--------------+-------------------+-------------------+

The following table describes the fields.

FieldTypeNullableDescription
ZONEvarchar(128)NOThe name of the zone.
SVR_IPvarchar(46)NOThe IP address of the server.
SVR_PORTbigint(20)NOThe port number of the server.
CPU_CAPACITYbigint(20)NOThe total CPU capacity of the OBServer node.
CPU_CAPACITY_MAXdoubleNOThe overprovisioning value for the total CPU capacity of the OBServer node. It is subject to the resource_hard_limit parameter. The following rule applies: CPU_CAPACITY_MAX = CPU_CAPACITY × resource_hard_limit
CPU_ASSIGNEDdoubleNOThe number of allocated CPU cores for the OBServer node. It is the sum of the MIN_CPU values of all units on the OBServer node. The following rule applies: CPU_ASSIGNED <= CPU_CAPACITY
CPU_ASSIGNED_MAXdoubleNOThe maximum number of allocated CPU cores for the OBServer node. It is the sum of the MAX_CPU values of all units on the OBServer node. The following rule applies: CPU_ASSIGNED_MAX <= CPU_CAPACITY_MAX
MEM_CAPACITYbigint(20)NOThe size of memory available for the observer process.
MEM_ASSIGNEDbigint(20)NOThe size of allocated memory for the OBServer node. It is the sum of the MEMORY_SIZE values of all units on the OBServer node. The following rule applies: MEM_ASSIGNED <= MEM_CAPACITY
LOG_DISK_CAPACITYbigint(20)NOThe total size of the log disk.
LOG_DISK_ASSIGNEDbigint(20)NOThe size of allocated space of the log disk. It is the sum of the MAX_DISK_SIZE values of all units on the OBServer node.
LOG_DISK_IN_USEbigint(20)NOThe size of used space of the log disk.
DATA_DISK_CAPACITYbigint(20)NOThe total size of the data disk.
DATA_DISK_IN_USEbigint(20)NOThe size of used space of the data disk.

View the unit config

SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS;

The output is as follows:


+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
| UNIT_CONFIG_ID | NAME | CREATE_TIME | MODIFY_TIME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
| 1 | sys_unit_config | 2024-02-19 15:33:47.524052 | 2024-02-19 15:33:47.524052 | 2 | 2 | 1073741824 | 3221225472 | 9223372036854775807 | 9223372036854775807 | 2 |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+

The following table describes the fields.

FieldTypeNullableDescription
UNIT_CONFIG_IDbigint(20)NOThe ID of the unit config.
NAMEvarchar(128)NOThe name of the unit config.
CREATE_TIMEtimestamp(6)YESThe time when the unit config was created.
MODIFY_TIMEtimestamp(6)YESThe time when the unit config was last modified.
MAX_CPUdoubleNOThe maximum number of CPU cores.
MIN_CPUdoubleNOThe minimum number of CPU cores.
MEMORY_SIZEbigint(20)NOThe memory size, in bytes.
LOG_DISK_SIZEbigint(20)NOThe log disk size, in bytes.
MAX_IOPSbigint(20)NOThe maximum disk IOPS.
MIN_IOPSbigint(20)NOThe minimum disk IOPS.
IOPS_WEIGHTbigint(20)NOThe IOPS weight.

View the resource allocation details

SELECT T4.TENANT_ID,T4.TENANT_NAME,
T1.NAME RESOURCE_POOL_NAME, T1.UNIT_COUNT,
T2.`NAME` UNIT_CONFIG_NAME,
T2.MAX_CPU, T2.MIN_CPU,
ROUND(T2.MEMORY_SIZE/1024/1024/1024,2) MEM_SIZE_GB,
ROUND(T2.LOG_DISK_SIZE/1024/1024/1024,2) LOG_DISK_SIZE_GB, T2.MAX_IOPS,
T2.MIN_IOPS, T3.UNIT_ID, T3.ZONE, CONCAT(T3.SVR_IP,':' ,T3.`SVR_PORT`) OBSERVER
FROM oceanbase.DBA_OB_RESOURCE_POOLS T1
JOIN oceanbase.DBA_OB_UNIT_CONFIGS T2 ON (T1.UNIT_CONFIG_ID=T2.UNIT_CONFIG_ID)
JOIN oceanbase.DBA_OB_UNITS T3 ON (T1.`RESOURCE_POOL_ID` = T3.`RESOURCE_POOL_ID`)
LEFT JOIN oceanbase.DBA_OB_TENANTS T4 ON (T1.TENANT_ID=T4.TENANT_ID)
ORDER BY T4.TENANT_NAME,T3.ZONE;

The output is as follows. For more information about the views referenced in the statement, see Outline of system views.

+-----------+-------------+--------------------+------------+------------------+---------+---------+-------------+------------------+---------------------+---------------------+---------+-------+--------------------+
| TENANT_ID | TENANT_NAME | RESOURCE_POOL_NAME | UNIT_COUNT | UNIT_CONFIG_NAME | MAX_CPU | MIN_CPU | MEM_SIZE_GB | LOG_DISK_SIZE_GB | MAX_IOPS | MIN_IOPS | UNIT_ID | ZONE | OBSERVER |
+-----------+-------------+--------------------+------------+------------------+---------+---------+-------------+------------------+---------------------+---------------------+---------+-------+--------------------+
| 1 | sys | sys_pool | 1 | sys_unit_config | 2 | 2 | 1.00 | 3.00 | 9223372036854775807 | 9223372036854775807 | 1 | zone1 | 10.10.10.1 :2882 |
| 1 | sys | sys_pool | 1 | sys_unit_config | 2 | 2 | 1.00 | 3.00 | 9223372036854775807 | 9223372036854775807 | 2 | zone2 | 10.10.10.1 :2882 |
| 1 | sys | sys_pool | 1 | sys_unit_config | 2 | 2 | 1.00 | 3.00 | 9223372036854775807 | 9223372036854775807 | 3 | zone3 | 10.10.10.1 :2882 |
+-----------+-------------+--------------------+------------+------------------+---------+---------+-------------+------------------+---------------------+---------------------+---------+-------+--------------------+

As shown in the output, the resource pool of the sys tenant consists of the resource units on nodes in all the zones. The resource units share the same unit config (sys_unit_config).

Loading...