ARCHIVELOG is used to control the log archiving feature for a tenant. Log archiving jobs can be initiated only when ARCHIVELOG is enabled for the tenant. If an archive destination has been configured and archiving is enabled at the archive destination before ARCHIVELOG is enabled for the tenant, the system automatically triggers a log archiving job after ARCHIVELOG is enabled.
Background information
Assume that the current cluster has three tenants: sys, mysql_tenant, and oracle_tenant, and that ARCHIVELOG is disabled for the mysql_tenant and oracle_tenant tenants. You can enable ARCHIVELOG for a user tenant in the following ways.
Enable ARCHIVELOG for a user tenant from the sys tenant
You can enable ARCHIVELOG for all tenants or a specified tenant in the cluster from the sys tenant.
Log on to the
systenant of the cluster as therootuser.Execute the following statement to enable
ARCHIVELOG.Enable
ARCHIVELOGfor all tenants in the clusterTo enable
ARCHIVELOGfor all tenants in the cluster, execute the following statement:Note
This operation takes effect only for existing tenants in the cluster. The system will not automatically enable
ARCHIVELOGfor tenants created after this operation.obclient [(none)]> ALTER SYSTEM ARCHIVELOG [TENANT = ALL];In this example, after you execute this statement,
ARCHIVELOGis enabled for themysql_tenantandoracle_tenanttenants. 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: oracle_tenant LOG_MODE: ARCHIVELOG 2 rows in setEnable
ARCHIVELOGfor a specified tenantYou can enable
ARCHIVELOGfor a specified tenant without affecting other tenants in the cluster.To enable
ARCHIVELOGfor themysql_tenanttenant, execute the following statement:obclient [(none)]> ALTER SYSTEM ARCHIVELOG TENANT = mysql_tenant;Note
If you specify multiple tenants, separate the tenant names with commas (,).
After you execute this statement, only the
mysql_tenanttenant enters theARCHIVELOGmode 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: oracle_tenant LOG_MODE: NOARCHIVELOG 2 rows in set
Enable ARCHIVELOG for a user tenant from the current tenant
You can enable ARCHIVELOG for a user tenant from the current tenant without affecting other tenants.
Log on to the database as a tenant administrator.
In this example, you can log on to the
mysql_tenanttenant as therootuser, or log on to theoracle_tenanttenant as theSYSuser.Execute the following statement to enable
ARCHIVELOGfor the tenant:obclient [xxx]> ALTER SYSTEM ARCHIVELOG;After the statement is executed, you can query the
DBA_OB_TENANTSview in this tenant for its archiving mode.obclient [SYS]> SELECT TENANT_NAME, LOG_MODE FROM DBA_OB_TENANTS\G *************************** 1. row *************************** TENANT_NAME: oracle_tenant LOG_MODE: ARCHIVELOG 1 rows in set