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 node
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
Business tenant memory is specified when the tenant creates a Unit. Example commands:
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 (exercise caution when scaling down).
alter RESOURCE UNIT sp_trans_test MAX_CPU=1, MEMORY_SIZE='6G';
The sys tenant can query Unit specifications 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
MemStore is mainly used to store incremental data of the database. The MemStore upper limit is controlled by the
memstore_limit_percentageparameter, which indicates the maximum percentage of the tenant's total memory that can be used by MemStore. Thefreeze_trigger_percentageparameter controls when dump is triggered. It indicates the percentage of the MemStore limit at which dump is triggered when MemStore memory reaches that level. Tenant MemStore usage can be viewed through 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 caches used to improve throughput, such as SQL execution plans.
ob_sql_work_area_percentageis the SQL work area memory parameter. It indicates the memory used by blocking operators in SQL that may consume a large amount of memory.
sys tenant memory
As mentioned earlier, the sys tenant is a physical tenant. Its management mechanism is the same as that for business tenants.