Purpose
The ALTER SYSTEM SET LOG_ARCHIVE_DEST statement specifies the destination for archiving logs for a user tenant. When you configure a log archive destination, you specify the LOCATION, BINDING, and PIECE_SWITCH_INTERVAL parameters.
Limitations and considerations
The system tenant and meta tenant do not support backup and restore, so you do not need to configure an archive destination.
At present, OceanBase Database supports only NFS, Alibaba Cloud Object Storage Service (OSS), Azure Blob Storage (For OceanBase Database V4.3.5, supported starting from V4.3.5 BP3), Amazon Simple Storage Service (S3), and object storage services that are compatible with the S3 protocol, such as Huawei Cloud Object Storage Service (OBS), Google Cloud Storage (GCS), and Tencent Cloud Object Storage (COS). To use some backup media, you may need to meet some basic requirements. For more information about the requirements for each backup media, see the Backup media requirements section in Overview of physical backup and restore.
When you specify
LOCATION,BINDING, andPIECE_SWITCH_INTERVAL, separate the parameters with spaces and do not add spaces before or after the equal sign (=) when you specify the parameter values.After you configure an archive destination, you cannot configure it incrementally. That is, you must specify all parameter values in the
ALTER SYSTEM SET LOG_ARCHIVE_DESTstatement each time you execute it. Otherwise, the default value will be used for any unspecified parameter.
Privileges required
The root user of the sys tenant or the administrator of each tenant must perform this operation. Note that:
- The default administrator in MySQL mode is the
rootuser. - The default administrator in Oracle mode is the
SYSuser.
Syntax
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=archive_path [BINDING=archive_mode] [PIECE_SWITCH_INTERVAL=piece_switch_interval]' [TENANT = tenant_name];
Parameters
| Parameter | Description |
|---|---|
| archive_path | The path where the archive is stored. For more information about this parameter, see archive_path. |
| archive_mode | The mode that gives the priority to archiving or business. This parameter is optional. Currently, Optional and Mandatory are supported. If this parameter is not specified, the default value Optional is used.
|
| piece_switch_interval | The interval for switching pieces. This parameter is optional. The value range is [1d, 7d]. If this parameter is not specified, the default value 1d is used. For more information about pieces, see Overview of log archiving. |
| tenant_name | The name of the tenant to which the destination for archiving is configured.
NoticeOnly the sys tenant needs to use the |
archive_path
Specifies the path for storing the archive files. The following sections describe the archive_path format for different media types.
NFS
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file://your-nfs-server-path/your-archive-path';
Here, file://your-nfs-server-path/your-archive-path specifies the NFS server path and the archive path.
Object storage
# Alibaba Cloud OSS
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://your-bucket-name/your-archive-path?host=oss-your-region.aliyuncs.com&access_id=your-access-id&access_key=your-access-key[&delete_mode={delete | tagging}][&checksum_type={md5 | no_checksum}][&enable_worm={true | false}]';
# AWS S3
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://your-bucket-name/your-archive-path?host=s3.your-region.amazonaws.com&access_id=your-access-id&access_key=your-access-key&s3_region=your-s3-region[&delete_mode={delete | tagging}][&checksum_type={md5 | crc32}]';
# Object storage compatible with the S3 protocol
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://your-bucket-name/your-archive-path?host=host=your-service.com&access_id=your-access-id&access_key=your-access-key[&addressing_model={virtual_hosted_style | path_style}][&checksum_type=md5]';
# Azure Blob Storage
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=azblob:////your-bucket-name/your-archive-path?host=host=your-service.com&access_id=your-access-id&access_key=your-access-key[&delete_mode={delete | tagging}][&checksum_type=md5]';
The parameters in the object storage path are separated by the & character. Make sure that the characters in the parameter values are uppercase or lowercase letters, numbers, and characters in the /-_$+= set, or the asterisk (*) and question mark (?). If you use other characters, the setting may fail.
Notice
When you use object storage as the archive media, separate the parameters in the object storage path by using the & character. Make sure that the characters in the parameter values are uppercase or lowercase letters, numbers, and characters in the /-_$+= set, or the asterisk (*) and question mark (?). If you use other characters, the setting may fail.
host: the access domain name of the object storage service.For Azure Blob Storage, the value of the
hostparameter can be obtained by concatenating the container name and the storage account connection string. The prefix must be set tohttp://orhttps://. By default, secure transfer is enabled for Azure Blob Storage, and it useshttps://for access. If secure transfer needs to be disabled and HTTP is to be used, follow the instructions in Azure Blob Storage documentation.access_id: the access key ID of the object storage.access_key: the access key of the object storage.delete_mode: the archive cleanup mode. Valid only for Alibaba Cloud OSS, AWS S3, Tencent Cloud COS (for S3 protocol access), and Azure Blob Storage. The value of this parameter is connected to other parameters by using the&character. This parameter supports the following values:delete: specifies to directly delete archives that meet the cleanup criteria.When you configure this mode, when you automatically clean up archives, the system directly deletes the archives that meet the cleanup criteria.
tagging: specifies to tag archives that meet the cleanup criteria withTag. The archives are retained.When you configure this mode, when you automatically clean up archives, the system tags the archives that meet the cleanup criteria with the
keyvalue of"delete_mode"and thevalueof"tagging". This way, users can manage the lifecycles of these archives in the object storage service by using the tags.
checksum_type: the check algorithm for checking the integrity of the archive file. This parameter is used to check the integrity of the archive file. If this parameter is not specified, MD5 check is performed by default for all object storage types. The following values are supported based on the object storage type:md5: specifies to use the MD5 algorithm to check the integrity of the archive file.Notice
The MD5 check does not take effect for the
GetObjectinterface.no_checksum: specifies not to check the integrity of the archive file. This value is supported only for Alibaba Cloud OSS and Azure Blob Storage. For object storage services that use the S3 protocol, including AWS S3, OBS, GCS, and Tencent Cloud COS, this value is not supported due to the limitations of the S3 SDK.crc32: specifies to use the CRC32 algorithm to check the integrity of the archive file. This value is supported only for AWS S3.
enable_worm: specifies whether to enable compliance retention for the destination bucket of the archive. This parameter is required when the destination of the archive is an Alibaba Cloud OSS bucket that has a compliance retention (WORM) policy configured for the destination bucket.The retention policy of Alibaba Cloud OSS has the WORM (Write Once Read Many) characteristic, which enables you to save and use data in an irreversible and unalterable manner. When you configure a retention policy for a bucket and lock the policy, for the objects whose retention period is not expired as specified in the retention policy, you can only upload and read objects in this bucket. Once the retention period of an object expires, you can modify or delete the object.
Notice
- In V4.3.5, the
enable_wormparameter is supported starting from V4.3.5 BP2. - At present, OceanBase Database does not replace the compliance retention policy that you set. Therefore, make sure that the destination bucket has a correctly configured and locked retention policy (WORM policy) before you set the backup path.
- If the path to be set corresponds to a bucket that has a WORM policy configured and locked, and if you do not specify
enable_worm=truewhen you set the destination of the archive, the system returns an error after the statement is executed, indicating that you must setenable_worm=true. - The
enable_wormparameter, once specified, cannot be modified. - After you set the archive path, if you configure a WORM policy for the destination bucket of the path, the archive may fail with error code
-9140and the error messagethe object is locked by wormbecause the destination path does not support append write. In this case, you need to configure a new archive path and setenable_worm=true.
The following values are supported for the
enable_wormparameter:true: specifies to enable the WORM specification for write and delete operations on the path. If you set this parameter totrue, you must explicitly setchecksum_type=md5.false: specifies not to enable the WORM specification. If this parameter is not specified, the default valuefalsetakes effect.
- In V4.3.5, the
s3_region: the region in which the Amazon S3 bucket resides. This parameter is required when the archive media is AWS S3.addressing_model: the URL format for accessing object storage. This parameter is optional for object storage services that use the S3 protocol, for example, OBS, GCS, and Tencent Cloud COS. The value of this parameter is connected to other parameters by using the&character. This parameter supports the following values:virtual_hosted_style: specifies to access object storage in the virtual-hosted-style URL format. This is the default value.path_style: specifies to access object storage in the path-style URL format.
For example, a user sets OBS as the archive media for the current tenant and specifies to access OBS in the virtual-hosted-style URL format. The sample statement is as follows:
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****&addressing_model=virtual_hosted_style';
Examples
System tenant
Configure the archive path for the
mysql_tenanttenant, set the archive media to NFS, select the user business priority mode, and set the Piece split cycle to every other day.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to OSS, set the archive file cleanup mode todelete, and verify the integrity of archive files using the MD5 algorithm.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://oceanbase-test-bucket/backup/archive?host=***.aliyun-inc.com&access_id=***&access_key=***&delete_mode=delete&checksum_type=md5' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to OSS, set the archive file cleanup mode todelete, and do not verify the integrity of archive files.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://oceanbase-test-bucket/backup/archive?host=***.aliyun-inc.com&access_id=***&access_key=***&delete_mode=delete&checksum_type=no_checksum' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to OSS, set the archive file cleanup mode todelete, and verify the integrity of archive files using the MD5 algorithm. When the path is configured withenable_worm=true, the system will perform write and delete operations on this path according to the WORM specifications.Notice
At present, OceanBase Database does not replace the compliance retention policies you set. Before you configure the archive path, make sure that the OSS bucket has correctly set the retention policy (WORM policy) and locked it.
obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://oceanbase-test-bucket/backup/archive?host=***.aliyun-inc.com&access_id=***&access_key=***&delete_mode=delete&checksum_type=md5&enable_worm=true' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to AWS S3, set the archive file cleanup mode todelete, select the user business priority mode, and set the Piece split cycle to every other day.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=s3.<region>.amazonaws.com&access_id=******&access_key=******&s3_region=******&delete_mode=delete BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to AWS S3, set the archive file cleanup mode totagging, and verify the integrity of archive files using the CRC32 algorithm.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=s3.<region>.amazonaws.com&access_id=***&access_key=***&s3_region=***&delete_mode=tagging&checksum_type=crc32' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to OBS, and access it through the S3 protocol.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to GCS, and access it through the S3 protocol.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=https://storage.googleapis.com&access_id=****&access_key=****' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant, set the archive media to COS, set the archive file cleanup mode todelete, and access it through the S3 protocol.Notice
When COS is used as the archive media, you must first set the cluster-level parameter ob_storage_s3_url_encode_type. For more information, see Prepare for log archiving.
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test/backup/archive?host=cos.ap-***.myqcloud.com&access_id=***&access_key=***&delete_mode=delete' TENANT = mysql_tenant;Configure the archive path for the
mysql_tenanttenant in the system tenant, set the archive media to Azure Blob Storage, set the cleanup mode todelete, set the checksum algorithm tomd5, select the user business priority mode, and set the Piece split cycle to every other day.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=azblob://oceanbase-test-bucket/backup/archive?host=http://****.blob.core.windows.net&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5 BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant;
User tenant
Configure the archive path for the
mysql_tenanttenant, set the archive media to NFS, select the user business priority mode, and set the Piece split cycle to every other day.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d';Configure the archive path for the
mysql_tenanttenant, set the archive media to OSS, set the archive file cleanup mode totagging, and verify the integrity of archive files using the MD5 algorithm.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://oceanbase-test-bucket/backup/archive?host=***.aliyun-inc.com&access_id=***&access_key=***&delete_mode=tagging&checksum_type=md5';Configure the archive path for the
mysql_tenanttenant, set the archive media to OSS, set the archive file cleanup mode totagging, and do not verify the integrity of archive files.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://oceanbase-test-bucket/backup/archive?host=***.aliyun-inc.com&access_id=***&access_key=***&delete_mode=tagging&checksum_type=no_checksum';Configure the archive path for the
mysql_tenanttenant, set the archive media to OSS, set the archive file cleanup mode totagging, and verify the integrity of archive files using the MD5 algorithm. When the path is configured withenable_worm=true, the system will perform write and delete operations on this path according to the WORM specifications.Notice
At present, OceanBase Database does not replace the compliance retention policies you set. Before you configure the archive path, make sure that the OSS bucket has correctly set the retention policy (WORM policy) and locked it.
obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=oss://oceanbase-test-bucket/backup/archive?host=***.aliyun-inc.com&access_id=***&access_key=***&delete_mode=tagging&checksum_type=md5&enable_worm=true';Configure the archive path for the
mysql_tenanttenant, set the archive media to AWS S3, set the archive file cleanup mode todelete, select the user business priority mode, and set the Piece split cycle to every other day.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=s3.<region>.amazonaws.com&access_id=******&access_key=******&s3_region=******&delete_mode=delete BINDING=Optional PIECE_SWITCH_INTERVAL=1d';Configure the archive path for the
mysql_tenanttenant, set the archive media to AWS S3, set the archive file cleanup mode totagging, and verify the integrity of archive files using the CRC32 algorithm.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=s3.<region>.amazonaws.com&access_id=***&access_key=***&s3_region=***&delete_mode=tagging&checksum_type=crc32';Configure the archive path for the
mysql_tenanttenant, set the archive media to OBS, and access it through the S3 protocol.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****';Configure the archive path for the
mysql_tenanttenant, set the archive media to GCS, and access it through the S3 protocol.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=https://storage.googleapis.com&access_id=****&access_key=****';Configure the archive path for the
mysql_tenanttenant, set the archive media to COS, set the archive file cleanup mode todelete, and access it through the S3 protocol.Notice
When COS is used as the archive media, you must first set the cluster-level parameter ob_storage_s3_url_encode_type. For more information, see Prepare for log archiving.
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test/backup/archive?host=cos.ap-***.myqcloud.com&access_id=***&access_key=***&delete_mode=delete';Configure the archive path for the tenant
mysql_tenant, set the archive media to Azure Blob Storage, the cleanup mode todelete, the checksum algorithm tomd5, the business priority mode, and set the interval to one day for each piece.obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=azblob://oceanbase-test-bucket/backup/archive?host=http://****.blob.core.windows.net&access_id=****&access_key=****&delete_mode=delete&checksum_type=md5 BINDING=Optional PIECE_SWITCH_INTERVAL=1d';
## References