Description
The ALTER SYSTEM SET LOG_ARCHIVE_DEST statement is used to configure the archive destination for a user tenant. The configuration of an archive destination mainly involves attributes such as LOCATION, BINDING, and PIECE_SWITCH_INTERVAL.
Limitations and considerations
Backup and restore are not supported for the sys tenant and Meta tenant, and no archive destination needs to be configured.
OceanBase Database currently supports NFS, Alibaba Cloud OSS, Azure Blob (supported starting from V4.2.5 BP6 in V4.2.5), AWS S3, and S3-compatible object storage such as Huawei OBS, Google GCS, and Tencent Cloud COS as backup media. Some backup media may need to meet basic requirements before use. For the specific requirements of each backup medium, see Backup media requirements in Overview of physical backup and restore.
When configuring the
LOCATION,BINDING, andPIECE_SWITCH_INTERVALattributes, separate the attributes with spaces. Do not add spaces before or after the equals sign (=) in the attribute value.After an archive destination is configured, incremental configuration is not supported. That is, when you execute the
ALTER SYSTEM SET LOG_ARCHIVE_DESTstatement, you must specify the values of all attributes. Otherwise, the attributes not specified will use their default values.
Privilege requirements
The statement must be executed by the root user (root@sys) of the sys tenant or the administrator user of each tenant:
rootin MySQL-compatible mode.SYSin Oracle-compatible mode.
Syntax
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=archive_path [BINDING=archive_mode] [PIECE_SWITCH_INTERVAL=piece_switch_interval]' [TENANT = tenant_name];
Parameter description
Parameter |
Description |
|---|---|
| archive_path | Specifies the archive path and source-side configuration. For more information about this parameter, see archive_path. |
| archive_mode | Configures the priority mode between archiving and business operations. Optional. Currently, Optional mode and Mandatory mode are supported. If this parameter is not set, Optional mode is used by default.
|
| piece_switch_interval | Configures the piece switch interval. Optional. The value range is [1d, 7d]. If this parameter is not set, the default value is 1d. For more information about pieces, see Overview of log archiving. |
| tenant_name | Specifies the tenant for which the sys tenant configures the archive destination.
NoticeOnly the sys tenant must specify the tenant to operate on through the |
archive_path
Specifies the archive path and source-side configuration. The following describes the archive_path format for different media types.
NFS
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file://your-nfs-server-path/your-archive-path[?{zone=zone_name | idc=idc_name | region=region_name}];
Parameter descriptions are as follows:
file://your-nfs-server-path/your-archive-path: specifies the NFS server path and archive path.zone,idc, andregion: specify the source side of the archive path, that is, the range of nodes that can access this path. This parameter is optional and is separated from the archive path by a question mark (?). You can configurezone,idc, orregionat only one level, or leave it unset. By default, it is not set.Note
In OceanBase Database V4.2.5, starting from V4.2.5 BP2, you can configure the source side of an archive path.
If you need to configure the Region or IDC level, run
ALTER SYSTEM MODIFY ZONE zone_name SET REGION=region_name;orALTER SYSTEM MODIFY ZONE zone_name SET IDC=idc_name;first to set the Region or IDC information. We recommend configuring the source side at the IDC level. This allows archive tasks to use an IDC with abundant network bandwidth, gives archive tasks a wider range of candidate nodes, and frees you from tracking zone changes within an IDC in the cluster.If the specified
zone,idc, orregiondoes not exist, an error is returned indicating that the source-side information does not exist (error code-9133).Because all log archiving traffic is written by the leader replica, log archive paths have no access-priority difference. These parameters only limit the range of nodes that can access the archive path. To specify multiple zones, IDCs, or regions, separate values with commas (,) or semicolons (;). For example,
zone=z1,z2;z3specifiesz1,z2, andz3as the source side for archiving.When you configure
zone,idc, orregion, the leader replica must be in the specifiedzone,idc, orregion. Otherwise, archiving cannot proceed.
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}][&{zone=zone_name | idc=idc_name | region=region_name}];
# 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}][&{zone=zone_name | idc=idc_name | region=region_name}];
# S3-compatible object storage
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://your-bucket-name/your-archive-path?host=your-service.com&access_id=your-access-id&access_key=your-access-key[&addressing_model={virtual_hosted_style | path_style}][&checksum_type=md5][&{zone=zone_name | idc=idc_name | region=region_name}];
# Azure Blob
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=azblob:////your-bucket-name/your-archive-path?host=your-service.com&access_id=your-access-id&access_key=your-access-key[&delete_mode={delete | tagging}][&checksum_type=md5][&{zone=zone_name | idc=idc_name | region=region_name}]';
Parameter descriptions are as follows:
Notice
When you use object storage as the archive medium, the parameters in the object storage path are separated by the & symbol. Make sure that the parameter values contain only uppercase and lowercase English letters, digits, /-_$+=, and wildcards. If you enter other characters, the setting may fail.
host: the domain name used to access the object storage service.For Azure Blob, the value of
hostcan be obtained from the container properties or the storage account connection string. The prefix ofhostmust behttp://orhttps://. Because Azure Blob enables secure transfer by default, it is accessed throughhttps://by default. To access it throughhttp://, you must disable the secure transfer option for Azure Blob. For more information, see Azure Blob documentation.access_id: the access key ID of the object storage.access_key: the access key of the object storage.delete_mode: configures the cleanup mode of archive files. This optional parameter is supported for OSS, AWS S3, COS (accessed through the S3 protocol), and Azure Blob. It is connected to other parameters with&. This parameter supports the following values:delete: in this mode, the system directly deletes archive files that meet the cleanup requirements.After this mode is configured, when archive files are cleaned up automatically, the system directly deletes archive files that meet the cleanup requirements.
tagging: in this mode, the system sets tags on archive files that meet the cleanup requirements. The archive files are retained.After this mode is configured, when archive files are cleaned up automatically, the system sets tags on archive files that meet the cleanup requirements. The tag
keyis"delete_mode"and thevalueis"tagging", so that you can manage the lifecycle of these files on object storage based on the tags.
checksum_type: specifies the algorithm used to verify the integrity of archive files. If this parameter is not explicitly specified, all object storage services use the MD5 algorithm by default. Supported values vary by object storage service:md5: uses the MD5 algorithm to verify the integrity of archive files.Notice
MD5 verification does not take effect for the
GetObjectinterface.no_checksum: does not verify the integrity of archive files. Only OSS and Azure Blob support this value. For object storage accessed through the S3 protocol, including AWS S3, OBS, GCS, and COS, this value is not supported because of S3 SDK limitations.crc32: uses the CRC32 algorithm to verify the integrity of archive files. Only AWS S3 supports this value.
enable_worm: optional. When the archive destination is an Alibaba Cloud OSS bucket with a compliance retention policy (WORM) configured, set this parameter totrue.OSS retention policies provide WORM (Write Once Read Many) behavior, allowing data to be stored and used in a non-deletable and non-tamperable manner. After you configure and lock a retention policy for a bucket, you can upload and read objects in that bucket only before the retention period expires. After the retention period expires, the objects can be modified or deleted.
Notice
- In OceanBase Database V4.2.5, starting from V4.2.5 BP7, you can specify the
enable_wormparameter. - OceanBase Database does not configure a compliance retention policy for you. Before you set the archive path, make sure that the OSS bucket retention policy (WORM policy) has been properly configured and locked.
- If the bucket corresponding to the path to be configured has a WORM policy configured and locked, but
enable_worm=trueis not specified when you configure the archive destination, the statement fails and prompts you to setenable_worm=true. - After the
enable_wormparameter is set, it cannot be changed. - After the archive path is set, if a WORM policy is configured and locked for the bucket corresponding to the path, archiving may fail with error
-9140because data cannot be appended to the target path, indicatingthe object is locked by worm. If archiving fails because of the WORM policy, you must configure a new archive path and specifyenable_worm=true. - When you use a bucket with a WORM policy as the archive path, we recommend that you use the
taggingcleanup mode.
The
enable_wormparameter supports the following values:true: yes. OceanBase Database performs write and delete operations on this path according to WORM rules. When you set this value totrue, you must also explicitly setchecksum_type=md5.false: no. If this parameter is not explicitly specified, the default value isfalse.
- In OceanBase Database V4.2.5, starting from V4.2.5 BP7, you can specify the
s3_region: the region of the Amazon S3 bucket. This parameter is required when AWS S3 is used as the archive medium.addressing_model: sets the URL format used to access object storage. This optional parameter applies to object storage accessed through the S3 protocol, such as OBS, GCS, and COS. It is connected to other parameters with&. This parameter supports the following values:virtual_hosted_style: the default value. Object storage is accessed in virtual-hosted style.path_style: object storage is accessed in path style.
For example, the following statement shows how a user tenant configures OBS as the archive medium and accesses OBS in virtual-hosted style:
obclient> 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';zone,idc, andregion: specify the source side of the archive path, that is, the range of nodes that can access this path. These parameters are optional and are separated from other parameters with&. You can configurezone,idc, orregionat only one level, or leave it unset. By default, it is not set.Note
In OceanBase Database V4.2.5, starting from V4.2.5 BP2, you can configure the source side of an archive path.
If you need to configure the Region or IDC level, run
ALTER SYSTEM MODIFY ZONE zone_name SET REGION=region_name;orALTER SYSTEM MODIFY ZONE zone_name SET IDC=idc_name;first to set the Region or IDC information. We recommend configuring the source side at the IDC level. This allows archive tasks to use an IDC with abundant network bandwidth, gives archive tasks a wider range of candidate nodes, and frees you from tracking zone changes within an IDC in the cluster.If the specified
zone,idc, orregiondoes not exist, an error is returned indicating that the source-side information does not exist (error code-9133).Because all log archiving traffic is written by the leader replica, log archive paths have no access-priority difference. These parameters only limit the range of nodes that can access the archive path. To specify multiple zones, IDCs, or regions, separate values with commas (,) or semicolons (;). For example,
zone=z1,z2;z3specifiesz1,z2, andz3as the source side for archiving.When you configure
zone,idc, orregion, the leader replica must be in the specifiedzone,idc, orregion. Otherwise, archiving cannot proceed.
Examples
Sys tenant
The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is NFS. Optional binding is used, and one piece is switched every day.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is NFS. Zonesz1,z2, andz3can access this archive path. Optional binding is used, and one piece is switched every day.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive?zone=z1,z2,z3 BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is OSS. The archive file cleanup mode isdelete, and the MD5 algorithm is used to 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=md5' TENANT = mysql_tenant;The sys tenant configures the archive destination for tenant
mysql_tenant. The archive medium is OSS. The archive file cleanup mode isdelete, and the integrity of archive files is not verified.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;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is OSS. The archive file cleanup mode istagging, and the MD5 algorithm is used to verify the integrity of archive files. Whenenable_worm=trueis configured for this path, the system performs write and delete operations on this path according to WORM rules.Notice
OceanBase Database does not configure a compliance retention policy for you. Before you set the archive path, make sure that the OSS bucket retention policy (WORM policy) has been properly configured and locked.
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' TENANT = mysql_tenant;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is OSS. The archive file cleanup mode isdelete. Zonesz1,z2, andz3can access this archive path.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&zone=z1,z2,z3' TENANT = mysql_tenant;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is AWS S3. The archive file cleanup mode isdelete. Optional binding is used, and one piece is switched every 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;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is AWS S3. The archive file cleanup mode istagging, and the CRC32 algorithm is used to verify the integrity of archive files.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;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is OBS and is accessed 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;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is GCS and is accessed 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;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is COS. The archive file cleanup mode isdelete, and COS is accessed through the S3 protocol.Notice
When you use COS as the archive medium, you must first set the cluster-level parameter ob_storage_s3_url_encode_type. For detailed steps, see Preparation before 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;The sys tenant configures the archive path for tenant
mysql_tenant. The archive medium is Azure Blob. The cleanup mode isdelete, the verification algorithm ismd5, Optional binding is used, and one piece is switched every 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
Tenant
mysql_tenantconfigures the archive path for the current tenant. The archive medium is NFS. Optional binding is used, and one piece is switched every day.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d';Tenant
mysql_tenantconfigures the archive path for the current tenant. The archive medium is NFS. Regionregion1can access this archive path. Optional binding is used, and one piece is switched every day.obclient [oceanbase]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive?region=region1 BINDING=Optional PIECE_SWITCH_INTERVAL=1d';Tenant
mysql_tenantconfigures the archive path for the current tenant. The archive medium is OSS. The archive file cleanup mode isdelete, and the MD5 algorithm is used to 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=md5';Tenant
mysql_tenantconfigures the archive path for the current tenant. The archive medium is OSS. The archive file cleanup mode isdelete, and the integrity of archive files is not verified.obclient [oceanbase]> 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=delete&checksum_type=no_checksum';Tenant
mysql_tenantconfigures the archive path for the current tenant. The archive medium is OSS. The archive file cleanup mode isdelete. IDCIDC3can access this archive path.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&idc=idc3';Tenant
mysql_tenantconfigures the archive path for the current tenant. The archive medium is OSS. The archive file cleanup mode istagging, and the MD5 algorithm is used to verify the integrity of archive files. Whenenable_worm=trueis configured for this path, the system performs write and delete operations on this path according to WORM rules.Notice
OceanBase Database does not configure a compliance retention policy for you. Before you set the archive path, make sure that the OSS bucket retention policy (WORM policy) has been properly configured and locked.
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';The tenant configures the archive path for the current tenant. The archive medium is AWS S3. The archive file cleanup mode is
delete. Optional binding is used, and one piece is switched every 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_tenantconfigures the archive path for the current tenant. The archive medium is AWS S3. The archive file cleanup mode istagging, and the CRC32 algorithm is used to verify the integrity of archive files.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';The tenant configures the archive path for the current tenant. The archive medium is OBS and is accessed 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=****';The tenant configures the archive path for the current tenant. The archive medium is GCS and is accessed 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=****';The tenant configures the archive path for the current tenant. The archive medium is COS. The archive file cleanup mode is
delete, and COS is accessed through the S3 protocol.Notice
When you use COS as the archive medium, you must first set the cluster-level parameter ob_storage_s3_url_encode_type. For detailed steps, see Preparation before 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_tenantconfigures the archive path for the current tenant. The archive medium is Azure Blob. The cleanup mode isdelete, the verification algorithm ismd5, Optional binding is used, and one piece is switched every 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';
