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 | tenant_name [, tenant_name ...];Here are some examples:
obclient> ALTER SYSTEM MINOR FREEZE TENANT =ALL; Query OK, 0 rows affected obclient> ALTER SYSTEM MINOR FREEZE tenant = tenant1; Query OK, 0 rows affected obclient> ALTER SYSTEM MINOR FREEZE TENANT =tenant1,tenant2; Query OK, 0 rows affectedNote
If no tenant is specified when executing the
ALTER SYSTEM MINOR FREEZEstatement, the minor compaction is performed on the sys tenant itself.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.