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 tablet level.
Procedure
Log on 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 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 sys tenant
obclient> ALTER SYSTEM MINOR FREEZE;Initiate a minor compaction for all user tenants from the sys tenant
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_user;or
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all;Note
In OceanBase Database V4.2.1 and later, the
TENANT = all_userandTENANT = allsettings express the same semantics. If you want an operation to take effect on all tenants, we recommend that you useTENANT = all_user.TENANT = allwill be deprecated.Initiate a minor compaction for all meta tenants from the sys tenant
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_meta;Initiate a minor compaction for a specified tenant from the sys tenant
obclient> 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 syntax:
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 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');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; Query OK, 0 rows affectedAfter 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 tablet level
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 = tid;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 = tid;In the syntax,
tenant_namespecifies the name of a tenant,ls_idspecifies the ID of a log stream in the tenant, andtidspecifies the ID of a tablet in the log stream. You can query theoceanbase.CDB_OB_TABLET_TO_LSview for the IDs of log streams and tablets.Here is an example:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = t1 tablet_id = 200001; Query OK, 0 rows affected obclient> ALTER SYSTEM MINOR FREEZE TENANT = t1 LS = 1001 tablet_id = 200001; Query OK, 0 rows affected
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.