Purpose
You can use statements in this topic to configure the log archive destination, enable log archiving, and disable log archiving. Both the sys tenant and user tenants support log archiving operations. For more information about log archiving operations in OceanBase Database, see Backup and restore in Manage.
Syntax
Configure the log archive destination
/* Configure the log archive destination for a specified user tenant in the sys tenant. */
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=archive_path [PIECE_SWITCH_INTERVAL=piece_switch_interval] [BINDING=archive_mode]' TENANT = tenant_name;
/* Configure the log archive destination for the current user tenant. */
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=archive_path [PIECE_SWITCH_INTERVAL=piece_switch_interval] [BINDING=archive_mode]';
Enable log archiving
/* Enable log archiving for all tenants in the cluster in the sys tenant. The sys tenant and meta tenants do not have the log archiving feature. */
ALTER SYSTEM ARCHIVELOG [TENANT = all];
/* Enable log archiving for a specified tenant in the sys tenant. */
ALTER SYSTEM ARCHIVELOG TENANT = tenant_name;
/* Enable log archiving for the current user tenant. */
ALTER SYSTEM ARCHIVELOG;
Disable log archiving
/* Disable log archiving for all tenants in the cluster in the sys tenant. The sys tenant and meta tenants do not have the log archiving feature. */
ALTER SYSTEM NOARCHIVELOG [TENANT = all];
/* Disable log archiving for a specified tenant in the sys tenant. */
ALTER SYSTEM NOARCHIVELOG TENANT = tenant_name;
/* Disable log archiving for the current user tenant. */
ALTER SYSTEM NOARCHIVELOG;
Parameters
| Parameter | Description |
|---|---|
| LOG_ARCHIVE_DEST | Configures the log archive destination. |
| archive_path | The path of the log archive destination. Currently, Network File System (NFS) paths, Alibaba Cloud Object Storage Service (OSS) paths, and Tencent Cloud Object Storage (COS) paths are supported. |
| archive_mode | The prioritizing mode for archiving and business. This parameter has two values: Optional and Mandatory. If you do not specify this parameter, the default value Optional takes effect.
|
| piece_switch_interval | The interval for generating a new log piece. Value range: [1d, 7d]. If you do not specify this parameter, the default value 1d takes effect. |
| tenant_name | The name of the tenant. |
Examples
In the sys tenant, configure the log archive destination for the
mysql_tenanttenant. Specifically, set the destination path to an NFS path, specify to prioritize user business, and set the interval for generating a new log piece to1d.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant;In the sys tenant, configure the log archive destination for the
mysql_tenanttenant. Specifically, set the destination path to an OSS path and specify the archive deletion mode.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://oceanbase-test-bucket/backup/archive?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx&delete_mode=tagging' TENANT = mysql_tenant;In the sys tenant, configure the log archive destination for the
mysql_tenanttenant. Specifically, set the destination path to a COS path and specify the archive deletion mode.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST = 'LOCATION=cos://oceanbase-test-bucket/archive?host=cos.ap-xxx.myqcloud.com&access_id=xxx&access_key=xxx&appid=xxx&delete_mode=delete BINDING=Mandatory PIECE_SWITCH_INTERVAL=2d' TENANT = mysql_tenant;In the sys tenant, enable log archiving for the
mysql_tenanttenant only.obclient> ALTER SYSTEM ARCHIVELOG TENANT = mysql_tenant;In the sys tenant, disable log archiving for the
mysql_tenanttenant only.obclient> ALTER SYSTEM NOARCHIVELOG TENANT = mysql_tenant;