You can execute the ALTER SYSTEM MINOR FREEZE statement in the sys tenant or a user tenant to manually initiate a minor compaction at the tenant, zone, server, log stream, or partition level.
Initiate a minor compaction from the sys tenant
You can initiate a minor compaction at the tenant, zone, server, log stream, or tablet level from the sys tenant.
Log on to the
systenant of the cluster as therootuser.Select a proper minor compaction type as needed.
Initiate a minor compaction at the tenant level
You can initiate a minor compaction for one or more tenants by using the following SQL syntax:
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
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;
Initiate a minor compaction at the zone level
You can initiate a minor compaction for a specified zone by using the following SQL syntax:
obclient> ALTER SYSTEM MINOR FREEZE ZONE [=] zone_name;Here is an example:
obclient> ALTER SYSTEM MINOR FREEZE ZONE = zone1;Initiate a minor compaction at the server level
You can initiate a minor compaction for one or more specified OBServer nodes by using the following SQL syntax:
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');Initiate a 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 syntax:
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name LS [=] ls_id;In the syntax,
tenant_namespecifies the name of a tenant andls_idspecifies the ID of a log stream in the tenant. You can query theoceanbase.CDB_OB_TABLET_TO_LSview 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.
Initiate a 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 syntax:
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name TABLET_ID = tablet_id;Alternatively, you can initiate a minor compaction for a specified tablet in a specified log stream of a specified tenant by using the following SQL syntax:
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name LS [=] ls_id TABLET_ID = tablet_id;In the syntax,
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 theCDB_OB_TABLE_LOCATIONSview for IDs of log streams and tablets. For more information about columns in theCDB_OB_TABLE_LOCATIONSview, see oceanbase.CDB_OB_TABLE_LOCATIONS.The following example shows how to initiate a minor compaction for a specified tablet in a specified tenant:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1 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 = tenant1 LS = 1001 TABLET_ID = 200001;
Initiate a minor compaction from a user tenant
You can initiate a minor compaction only for the current tenant at the tenant level or partition level from a user tenant.
Log on to a MySQL or Oracle tenant of the cluster as the administrator of the tenant.
Select a proper minor compaction type as needed.
Initiate a minor compaction at the tenant level
obclient> ALTER SYSTEM MINOR FREEZE;Initiate a 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 the current tenant by using the following SQL syntax:
ALTER SYSTEM MINOR FREEZE TABLET_ID = tablet_id;In the syntax,
tablet_idcan be queried from theDBA_OB_TABLE_LOCATIONSview. For more information about columns in theDBA_OB_TABLE_LOCATIONSview, see DBA_OB_TABLE_LOCATIONS.Here is an example:
obclient> ALTER SYSTEM MINOR FREEZE TABLET_ID = 200001;
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.