You can specify parameters to manage memory usage in OceanBase Database.
Note
For more information about the parameters mentioned in this topic, see Parameters and system variables.
Total memory of OBServer nodes
The total memory of OBServer nodes indicates the upper limit of memory for all OBServer nodes. It is specified by the following two parameters:
memory_limit_percentage: the percentage of the physical memory of the physical machine or container.memory_limit: an absolute value.
If the value of the memory_limit parameter is not 0M, the parameter specifies the upper limit of total memory. Otherwise, the value calculated based on the memory_limit_percentage parameter specifies the upper limit of total memory.
High priority reserved memory
The memory space reserved for some critical underlying modules.
To set the reserved size, you can specify the memory_reserved parameter.
Memory for the SYS500 tenant
The memory space reserved for the SYS500 tenant. To set the reserved size, you can specify the system_memory parameter.
Note that the system_memory parameter does not limit the reserved memory size. In fact, the memory size available to the SYS500 tenant may exceed system_memory. However, the memory size available to other tenants does not exceed the value of memory_limit - system_memory.
Business tenant memory
The business tenant memory is specified by the tenant when the unit is created. The following example shows the sample commands that you can use to specify the tenant memory:
create resource unit if not exists sp_trans_test MAX_CPU=1, MEMORY_SIZE='5G', MAX_IOPS=128000, MIN_IOPS=128000, LOG_DISK_SIZE='2G';
create resource pool if not exists sp_trans_test unit='sp_trans_test', unit_num=1;
create tenant if not exists sp_trans_test RESOURCE_POOL_LIST=('sp_trans_test') set ob_tcp_invited_nodes='%';
OceanBase Database supports dynamic adjustment of unit specifications. However, make sure that you proceed with caution when you reduce the unit specifications.
alter RESOURCE UNIT sp_trans_test MAX_CPU=1, MEMORY_SIZE='6G';
You can query the unit specifications of the sys tenant from views.
obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS\G
*************************** 1. row ***************************
UNIT_CONFIG_ID: 1
NAME: sys_unit_config
MAX_CPU: 2.5
MIN_CPU: 2.5
MEMORY_SIZE: 17179869184
LOG_DISK_SIZE: 17179869184
MAX_IOPS: 25000
MIN_IOPS: 25000
IOPS_WEIGHT: 2
*************************** 2. row ***************************
UNIT_CONFIG_ID: 1001
NAME: unit001
MAX_CPU: 2
MIN_CPU: 2
MEMORY_SIZE: 6442450944
LOG_DISK_SIZE: 19327352832
MAX_IOPS: 20000
MIN_IOPS: 20000
IOPS_WEIGHT: 2
*************************** 3. row ***************************
UNIT_CONFIG_ID: 1004
NAME: sp_trans_test
MAX_CPU: 1
MIN_CPU: 1
MEMORY_SIZE: 5368709120
LOG_DISK_SIZE: 2147483648
MAX_IOPS: 128000
MIN_IOPS: 128000
IOPS_WEIGHT: 0
3 rows in set
Tenant memory classification
Tenant memory is divided into MemStore and SQL execution memory.
MemStore
A MemStore stores the incremental data of an OceanBase database. The upper limit of the MemStore is specified by the
memstore_limit_percentageparameter. This parameter indicates the maximum percentage of the total memory that can be occupied by the MemStore. Thefreeze_trigger_percentageparameter indicates the percentage that triggers a minor compaction when the MemStore memory reaches the specified value. To view the MemStore usage of the tenant, you can query internal tables.MySQL [oceanbase]> select * From GV$OB_MEMSTORE; +-----------+----------------+-------+-----------+-----------+---------------------+---------------------+------------+ | TENANT_ID | IP | PORT | ACTIVE | TOTAL | FREEZE_TRIGGER | MEM_LIMIT | FREEZE_CNT | +-----------+----------------+-------+-----------+-----------+---------------------+---------------------+------------+ | 1 | xx.xx.xx.xx | 46824 | 169792200 | 171966464 | 5153960700 | 10307921440 | 0 | | 500 | xx.xx.xx.xx | 46824 | 0 | 0 | 3689348814741910300 | 7378697629483820640 | 0 | | 1001 | xx.xx.xx.xx | 46824 | 33539200 | 35651584 | 382730200 | 858993440 | 0 | | 1002 | xx.xx.xx.xx | 46824 | 0 | 228589568 | 34359738350 | 68719476720 | 0 | +-----------+----------------+-------+-----------+-----------+---------------------+---------------------+------------+SQL execution memory
The memory required for SQL execution and the cache allocated to improve the throughput of SQL execution plans.
The
ob_sql_work_area_percentageparameter indicates the memory required by the blocking operators in the SQL statements that may consume a lot of memory.
Memory for the sys tenant
The sys tenant is a physical tenant. It is managed by the same mechanism as that for business tenants.