Archiving mode controls the log archiving feature for a tenant. Log archiving tasks can be initiated only when archiving mode is enabled for the tenant. If an archive destination has been configured for a tenant before archiving mode is enabled and the destination is in the ENABLE state, the system automatically initiates log archiving tasks after archiving mode is enabled.
Background information
Assume there are currently three tenants in the cluster: sys, mysql_tenant, and mysql_tenant1. Neither tenant mysql_tenant nor mysql_tenant1 has archiving mode enabled. You can enable archiving mode for tenants using the following three methods.
System tenant enables archiving mode for other tenants
The sys tenant can enable archiving mode for all or specific tenants in the cluster.
Log in to the
systenant of the cluster as therootuser.Execute the following statements to enable archiving mode.
Enable archiving mode for all tenants in the cluster
This method enables archiving mode for all tenants in the cluster.
Notice
This operation takes effect only for existing tenants in the cluster. The system does not automatically enable archiving mode for tenants created after this operation.
obclient [(none)]> ALTER SYSTEM ARCHIVELOG [TENANT = ALL];After you execute this statement, archiving mode is enabled for the
mysql_tenantandmysql_tenant1tenants in this example. You can query theoceanbase.DBA_OB_TENANTSview in thesystenant for the archiving modes of all tenants in the cluster.Here is an example:
obclient [(none)]> SELECT TENANT_NAME, LOG_MODE FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_TYPE = 'USER'\G *************************** 1. row *************************** TENANT_NAME: mysql_tenant LOG_MODE: ARCHIVELOG *************************** 2. row *************************** TENANT_NAME: mysql_tenant1 LOG_MODE: ARCHIVELOG 2 rows in setEnable archiving mode for specified tenants
You can enable archiving mode for a specified tenant without affecting other tenants in the cluster.
To enable archiving mode for the
mysql_tenanttenant, execute the following statement:obclient [(none)]> ALTER SYSTEM ARCHIVELOG TENANT = mysql_tenant;Note
When specifying multiple tenants, separate the tenant names with commas (`,`).
After you execute this statement, only the
mysql_tenanttenant enters archiving mode in this example. You can query theoceanbase.DBA_OB_TENANTSview in thesystenant for the archiving modes of all tenants in the cluster.obclient [(none)]> SELECT TENANT_NAME, LOG_MODE FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_TYPE = 'USER'\G *************************** 1. row *************************** TENANT_NAME: mysql_tenant LOG_MODE: ARCHIVELOG *************************** 2. row *************************** TENANT_NAME: mysql_tenant1 LOG_MODE: NOARCHIVELOG 2 rows in set
Enable archiving mode for the current tenant
You can also directly enable archiving mode for the current tenant without affecting other tenants.
Log in to the database as a tenant administrator.
In this example, you can log in to the
mysql_tenantormysql_tenant1tenant as therootuser.Execute the following statement to enable archiving mode for the current tenant. After the archiving service is enabled, the data dictionary of the current user tenant will also be archived.
obclient [xxx]> ALTER SYSTEM ARCHIVELOG;After the command is successfully executed, you can directly view the archiving mode of the tenant through the
DBA_OB_TENANTSview under this tenant.obclient [SYS]> SELECT TENANT_NAME, LOG_MODE FROM DBA_OB_TENANTS\G *************************** 1. row *************************** TENANT_NAME: mysql_tenant1 LOG_MODE: ARCHIVELOG 1 rows in set