You can execute the ALTER SYSTEM MINOR FREEZE statement in the sys tenant to manually initiate a minor compaction at the tenant, zone, server, log stream, or partition level.
Procedure
Log in to the
systenant of the cluster as therootuser.Select a proper minor compaction type as needed.
Minor compaction at the tenant level
You can initiate a minor compaction for one or more tenants by executing the following SQL statement:
obclient> ALTER SYSTEM MINOR FREEZE TENANT [=] all_user | all | all_meta | tenant_name [, tenant_name ...];Here are some examples:
Initiate a minor compaction for the current tenant from the
systenantobclient> ALTER SYSTEM MINOR FREEZE;Initiate a minor compaction for all user tenants from the
systenantobclient> ALTER SYSTEM MINOR FREEZE TENANT = all_user;or
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all;Note
In OceanBase Database V4.2.1 and later,
TENANT = all_userandTENANT = allexpress the same semantics. If you want an operation to take effect on all user tenants, we recommend that you useTENANT = all_user.TENANT = allwill be deprecated.Initiate a minor compaction for all meta tenants from the
systenantobclient> ALTER SYSTEM MINOR FREEZE TENANT = all_meta;Initiate a minor compaction for a specified tenant from the
systenantobclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1;
Minor compaction at the zone level
You can initiate a minor compaction for a specified zone by using the following SQL statement:
obclient> ALTER SYSTEM MINOR FREEZE ZONE [=] zone_name;Here is an example:
obclient> ALTER SYSTEM MINOR FREEZE ZONE = zone1;Minor compaction at the server level
You can initiate a minor compaction for one or more specified OBServer nodes by using the following SQL statement:
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('ip:port' [, 'ip:port'...]);Here is an example:
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('xx.xx.xx.xx:2882','xx.xx.xx.xx:2882');Minor compaction at the log stream level
You can initiate a minor compaction for a specified log stream of a specified tenant by using the following SQL statement:
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name LS [=] ls_id;In the statement,
tenant_namespecifies the name of a tenant andls_idspecifies the ID of a log stream in the tenant. You can query theoceanbase.CDB_OB_TABLE_LOCATIONSview for IDs of log streams.Here is an example:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = t1 LS = 1001;After you execute this statement, the system performs a minor compaction for all tablets in the specified log stream of the specified tenant.
Minor compaction at the partition level
In OceanBase Database, one partition corresponds to one tablet.
You can initiate a minor compaction for a specified tablet in a specified tenant by using the following SQL statement:
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name TABLET_ID = tablet_id;You can also initiate a minor compaction for a specified tablet in a specified log stream of a specified tenant by using the following SQL statement:
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name LS [=] ls_id TABLET_ID = tablet_id;Here,
tenant_namespecifies the name of a tenant,ls_idspecifies the ID of a log stream in the tenant, andtablet_idspecifies the ID of a tablet in the log stream. You can query theoceanbase.CDB_OB_TABLE_LOCATIONSview for log stream IDs and tablet IDs.The following example shows how to initiate a minor compaction for a specified tablet in a specified tenant:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = t1 TABLET_ID = 200001;The following example shows how to initiate a minor compaction for a specified tablet in a specified log stream of a specified tenant:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = t1 LS = 1001 TABLET_ID = 200001;
Initiate a minor compaction from a user tenant
If you are logged in to a user tenant, you can initiate only tenant-level minor compactions for the current tenant.
Log in to a MySQL or Oracle tenant of the cluster as the administrator of the tenant.
Initiate a minor compaction for the current tenant based on your business needs.
obclient> ALTER SYSTEM MINOR FREEZE;
What to do next
After you initiate a minor compaction, you can view the information about it. For more information, see View minor compaction information.