You can also specify a daily compaction trigger time to trigger tenant compaction.
Prerequisites
Before triggering compaction, ensure that the global compaction switch is enabled. The global compaction switch is controlled by the cluster-level configuration item enable_major_freeze, which defaults to
True, indicating that the compaction switch is enabled.If the global compaction switch is not enabled for the current cluster, follow these steps to enable it.
Log in to the
systenant of the cluster as therootuser.Check whether the global compaction switch is enabled.
obclient(root@sys)[(none)]> SHOW PARAMETERS LIKE 'enable_major_freeze';If the switch is not enabled, execute the following statement to enable it.
obclient(root@sys)[(none)]> ALTER SYSTEM SET enable_major_freeze='True';
If you want to trigger daily tenant compaction, ensure that the tenant-level configuration item enable_window_compaction is set to
False, indicating that window compaction is disabled.Here are the steps:
Log in to the MySQL or Oracle tenant of the cluster as the tenant administrator.
Check the value of the tenant-level configuration item
enable_window_compaction.obclient> SHOW PARAMETERS LIKE 'enable_window_compaction';If the value is
True, execute the following statement to disable window compaction.obclient> ALTER SYSTEM SET enable_window_compaction = False;In the system tenant, you can specify the tenant name to set this parameter, for example:
ALTER SYSTEM SET enable_window_compaction = False TENANT = tenant_name;.
Conditions for triggering daily tenant compaction
After enabling the global compaction switch and disabling window compaction, daily tenant compaction is triggered automatically at the specified time. The time for daily tenant compaction is controlled by the major_freeze_duty_time parameter. You can also modify this time in OCP, which defaults to 02:00 daily.
For more information about the major_freeze_duty_time parameter and other compaction-related parameters, see Modify compaction configurations.
Specify the trigger time for daily tenant compaction
Log in to the
systenant of the cluster as therootuser.Execute the following statement to modify the trigger time for daily compaction.
Modify the trigger time for daily compaction of the current tenant
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00';Modify the trigger time for daily compaction of all user tenants
In scenarios with a large number of tenants, if all user tenants have the same trigger time for daily compaction, the CPU utilization may suddenly increase. If this occurs, we recommend that you set different trigger times for each user tenant.
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = all_user;or
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = all;Note
Starting from OceanBase Database V4.2.1,
TENANT = all_userandTENANT = allhave the same semantics. When you need to specify all user tenants, we recommend that you useTENANT = all_user. TheTENANT = alloption will be deprecated in the future.Modify the trigger time for daily compaction of all Meta tenants
In scenarios with a large number of tenants, if all Meta tenants have the same trigger time for daily compaction, the CPU utilization may suddenly increase. If this occurs, we recommend that you set different trigger times for each Meta tenant.
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = all_meta;Modify the trigger time for daily compaction of a specified tenant
The following statement supports specifying only one tenant at a time. To modify multiple tenants, you need to execute this statement repeatedly.
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = tenant1;
