This topic describes the preparations before you archive logs.
Configure the concurrency of log archiving (optional)
Before you enable the archiving mode, you can configure the concurrency of log archiving to improve the log archiving speed of the tenant.
Log in to the database as the
systenant user or the tenant administrator of the user tenant.Execute the appropriate statement to set the
log_archive_concurrencyparameter.The
log_archive_concurrencyparameter of a user tenant specifies the total number of worker threads for log archiving. This parameter takes effect immediately and does not require a restart of the OBServer node. The value range is [0, 100]. The default value is0, which indicates that the database adapts the log archiving concurrency. We recommend that you use the default value.Notice
For small tenants (with less than or equal to 4 CPU cores), we recommend that you use the default value and do not modify the value of this parameter.
The following methods are supported for setting the parameter:
Adjust the log archiving concurrency for a specified tenant as the
systenant user.ALTER SYSTEM SET log_archive_concurrency = 10 TENANT = mysql_tenant;Adjust the log archiving concurrency for all tenants as the
systenant user.ALTER SYSTEM SET log_archive_concurrency = 10 TENANT = all_user;or
ALTER SYSTEM SET log_archive_concurrency = 10 TENANT = all;Note
Starting from V4.2.1, OceanBase Database considers
TENANT = all_userandTENANT = allto be semantically equivalent. When you need to take effect in all user tenants, it is recommended to useTENANT = all_user.TENANT = allwill be deprecated.Adjust the log archiving concurrency for the current tenant as a user tenant.
ALTER SYSTEM SET log_archive_concurrency = 10;
For more information about the
log_archive_concurrencyparameter, see log_archive_concurrency.
Configure the destination for archiving logs
Before you start a log archiving task, you must execute the ALTER SYSTEM command to set the LOG_ARCHIVE_DEST parameter. The system tenant does not contain user data and is a tenant used for cluster management. Backup and restore are not supported for the sys tenant. Therefore, you do not need to configure an archive destination for this tenant.
The operation of configuring an archive destination mainly involves setting the LOCATION, BINDING, and PIECE_SWITCH_INTERVAL parameters.
Considerations
When you configure the destination for archiving, make sure that the archiving path for each tenant is an independent empty directory, and that the archiving paths for different tenants are different.
Procedure
Log in to the database as the tenant administrator of the
systenant or a user tenant.Note
In MySQL-compatible mode, the administrator user is the
rootuser, and in Oracle-compatible mode, the administrator user is theSYSuser.Configure the archive destination.
Configure the archive destination for the specified tenant in the sys tenant
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=archive_path [BINDING=archive_mode] [PIECE_SWITCH_INTERVAL=piece_switch_interval]' TENANT = tenant_name;Configure the archive destination for the current tenant
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=archive_path [BINDING=archive_mode] [PIECE_SWITCH_INTERVAL=piece_switch_interval]';
Notice
For an upgrade from OceanBase Database V4.0.x to V4.1.0, the archiving path must be changed after the upgrade. For an upgrade from OceanBase Database V4.1.x to V4.2.x, the archiving path does not need to be changed. In addition, for an upgrade from OceanBase Database V4.1.x to V4.2.x, log archiving can be performed during the upgrade.
The following table describes the parameters.
LOCATION(required)The
LOCATIONattribute is used to specify the archiving path. Currently, OceanBase Database supports the following archive media: NFS, Alibaba Cloud OSS, Azure Blob Storage (For OceanBase Database V4.3.5, supported starting from V4.3.5 BP3), AWS S3, and S3-compatible object storage such as Huawei OBS, Google GCS, and Tencent Cloud COS. Some archive media may need to meet certain basic requirements before they can be used. For more information about the requirements for each archive media, see the Backup media requirements section in Overview of physical backup and restore.OSSNFSS3Object storage services that comply with the S3 protocolWhen OSS is used as the archive media, in addition to specifying the archiving path,
host,access_key, andaccess_id, you can also configure thedelete_modeparameter to specify the mode for deleting archive files. Thedelete_modeparameter supports thedeleteandtaggingmodes. If you do not explicitly specify thedelete_modeparameter, thedeletemode is used by default.In addition, you can specify the
checksum_typeparameter to indicate the checksum algorithm for verifying the integrity of archive files. The supported values aremd5andno_checksum. If you do not explicitly specify thechecksum_typeparameter, the default value ismd5.Starting from V4.3.5 BP2, OceanBase Database supports using Alibaba Cloud OSS Buckets with configured compliance retention policies as archiving paths. When configuring the archiving path, you can use the
enable_wormparameter to specify whether OceanBase Database should follow the bucket’s retention policy (WORM policy) for write and delete operations on the path. The parameter supports values oftrueandfalse. If theenable_wormparameter is not explicitly configured, it defaults tofalse. When settingenable_worm=true, it is required to explicitly configurechecksum_type=md5. Once theenable_wormparameter is set, it cannot be changed.Notice
OceanBase Database will not replace or override your configured compliance retention policies. Ensure that the OSS Bucket’s retention policy (WORM policy) is correctly configured and locked before setting the archiving path.
For detailed descriptions of each parameter, refer to SET LOG_ARCHIVE_DEST.
Notice
When an object storage service is used as the archive media, separate the parameters for the object storage path with the
&character. Make sure that the values of the parameters contain only uppercase and lowercase letters, numbers, and the characters/-_$+=and the wildcard character. If you enter characters other than the preceding ones, the setting may fail.Here are some examples:
When using OSS as the archive media, set the archiving path for the tenant
mysql_tenantin the sys tenant, configure thedeletemode for deleting archive files, and specify themd5algorithm for verifying the integrity of archive files.obclient> 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;If you do not want to verify the integrity of archive files, you can set the
checksum_typeparameter tono_checksum. Here is an example:obclient> 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;When using OSS as the archive medium, the system tenant sets the archiving path for the specified tenant
mysql_tenant, configures the cleanup mode asdelete, specifies writing and deleting objects in a WORM-compliant manner, and sets the checksum algorithm tomd5.Notice
- OceanBase Database will not override the compliance retention policy you set. Before configuring the archive path, please make sure that the OSS bucket has been properly set up with a retention policy (WORM policy) and is locked.
- When using a bucket with a WORM policy as the archive path, it is recommended to use the
taggingcleanup mode.
obclient> 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;When using OSS as the archive medium, the user tenant sets the archiving path for its own tenant, configures the cleanup mode as
delete, and specifies the checksum algorithm asmd5.obclient> 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';
In this example,
oss://indicates that an OSS bucket is used as the archive media. The bucket name isoceanbase-test-bucketand the path in the bucket is/backup/archive. The parameters are separated from the path by using?, and the parameters are separated by using&. Thehostparameter specifies the host address of the bucket. Theaccess_idandaccess_keyparameters specify the access keys of the OSS service. Thedelete_modeparameter is set todelete, and themd5algorithm is used to verify the integrity of archive files. Theenable_wormparameter is set totrue, which indicates that write and delete operations on objects must comply with the WORM specification. Note that OceanBase Database does not replace the compliance-based retention policy that you set. Before you set the archiving path, make sure that the OSS bucket has a correctly configured retention policy (WORM policy) and the policy is locked.Notice
When you use NFS as the archive media, note the following items:
- The value of the
LOCATIONparameter cannot contain a question mark (?). - The value of the
LOCATIONparameter must be an absolute path, and the OBServer node must have read and write permissions on the path. - All OBServer nodes must mount the same NFS server. To ensure successful log archiving, use the parameters recommended in this topic to mount the NFS server. For more information about how to mount the NFS server, see Deploy an NFS client.
Here is an example of setting the archiving path when you use NFS as the archive media in the sys tenant:
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive' TENANT = mysql_tenant;Here is an example of setting the archiving path when you use NFS as the archive media in the current tenant:
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive';In these examples,
file://indicates that NFS is used as the archive media, and the archiving path is/data/nfs/backup/archive.Like OSS, you can specify the
delete_modeparameter to configure the mode for deleting archive files when you use Amazon Simple Storage Service (S3) as the archive media. The supported values are the same as those for OSS. In addition, you can specify thechecksum_typeparameter to indicate the checksum algorithm for verifying the integrity of archive files. The supported values aremd5andcrc32. If you do not explicitly specify thechecksum_typeparameter, the default value ismd5.For more information about the
delete_modeparameter and thechecksum_typeparameter, see SET LOG_ARCHIVE_DEST.Notice
When an object storage service is used as the archive media, separate the parameters for the object storage path with the
&character. Make sure that the values of the parameters contain only uppercase and lowercase letters, numbers, and the characters/-_$+=and the wildcard character. If you enter characters other than the preceding ones, the setting may fail.Here are some examples of using S3 as the archive media:
When using S3 as the archive media, set the archiving path for the tenant
mysql_tenantin the sys tenant, configure thedeletemode for deleting archive files, and specify thecrc32algorithm for verifying the integrity of archive files.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&checksum_type=crc32' TENANT = mysql_tenant;When using S3 as the archive media, set the archiving path for the current tenant, configure the
deletemode for deleting archive files, and specify thecrc32algorithm for verifying the integrity of archive files.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&checksum_type=crc32';
In these examples,
s3://indicates that an S3 bucket is used as the archive media. The bucket name isoceanbase-test-bucketand the path in the bucket is/backup/archive. The parameters are separated from the path by using?, and the parameters are separated by using&. Thehostparameter specifies the domain name of the Amazon S3 service. Theaccess_idandaccess_keyparameters specify the access keys of the Amazon S3 service. Thes3_regionparameter is required when S3 is used as the archive media. It specifies the region where the S3 bucket is located. Thedelete_modeparameter is set todelete, and thecrc32algorithm is used to verify the integrity of archive files.For more information about the AWS S3 path format, see Appendix: AWS S3 path format.
Most object storage services comply with the Simple Storage Service (S3) protocol. Therefore, object storage services that comply with the S3 protocol and meet the requirements of OceanBase Database can be used as the archive media for OceanBase Database. You can access such object storage services in the same way as you access S3. For example, Object Storage Service (OBS), Google Cloud Storage (GCS), and Tencent Cloud Object Storage (COS) can be accessed through the S3 protocol.
You can also specify the
checksum_typeparameter to indicate the checksum algorithm for verifying the integrity of archive files when you use OBS, GCS, or COS through the S3 protocol as the archive media. The supported value ismd5. If you do not explicitly specify thechecksum_typeparameter, the default value ismd5. For more information about thechecksum_typeparameter, see SET LOG_ARCHIVE_DEST.Notice
- When using object storage as the archive medium, the parameters for the object storage path are separated by the
&symbol. Please ensure that the values you enter contain only uppercase and lowercase English letters, numbers,/-_$+=, and wildcards. If you enter any other characters, the configuration may fail. - For some object storage services compatible with the S3 protocol, the default URL encoding method of the AWS S3 SDK may not be supported. When accessing via the
s3://protocol, if you encounter object storage-related error codes such as 9129 or 9026, it is recommended to set the cluster-level parameter ob_storage_s3_url_encode_type to specify the URL encoding method used by AWS S3 requests to be compatible with the Rfc3986 standard. For detailed configuration steps, please refer to Operation steps and examples for using COS as the archive medium below.
Here is an example of using OBS as the archive media:
When using OBS as the archive media, set the archiving path for the tenant
mysql_tenantin the sys tenant.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;When using OBS as the archive media, set the archiving path for the current tenant.
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=obs.****.myhuaweicloud.com&access_id=****&access_key=****';
In these examples,
s3://indicates that the object storage path is accessed through the S3 protocol. The bucket name isoceanbase-test-bucketand the path in the bucket is/backup/archive. The parameters are separated from the path by using?, and the parameters are separated by using&. Thehostparameter specifies the domain name of the OBS service. Theaccess_idandaccess_keyparameters specify the access keys of the OBS service.Here is an example of using GCS as the archive media:
When using GCS as the archive media, set the archiving path for the tenant
mysql_tenantin the sys tenant.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;When using GCS as the archive media, set the archiving path for the current tenant.
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test-bucket/backup/archive?host=https://storage.googleapis.com&access_id=****&access_key=****';
In these examples,
s3://indicates that the object storage path is accessed through the S3 protocol. The bucket name isoceanbase-test-bucketand the path in the bucket is/backup/archive. The parameters are separated from the path by using?, and the parameters are separated by using&. Thehostparameter specifies the domain name of the GCS service. Theaccess_idandaccess_keyparameters specify the access keys of the GCS service.Here is an example of using COS as the archive media:
View the value of the cluster-level parameter
ob_storage_s3_url_encode_type.obclient> SHOW PARAMETERS LIKE '%ob_storage_s3_url_encode_type%';The result is as follows:
+-------+----------+----------------+----------+-------------------------------+-----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | +-------+----------+----------------+----------+-------------------------------+-----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone1 | observer | 172.xx.xxx.xxx | 2882 | ob_storage_s3_url_encode_type | NULL | default | Determines the URL encoding method for S3 requests."default": Uses the S3 standard URL encoding method."compliantRfc3986Encoding": Uses URL encoding that adheres to the RFC 3986 standard. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +-------+----------+----------------+----------+-------------------------------+-----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ 1 row in setIf the value is
default, change it tocompliantRfc3986Encoding.obclient> ALTER SYSTEM SET ob_storage_s3_url_encode_type='compliantRfc3986Encoding';For more information about this parameter, see ob_storage_s3_url_encode_type.
Set the archiving path and specify the mode for deleting archive files by using the
delete_modeparameter.Use COS as the archive media. Set the archiving path for the tenant
mysql_tenantin the sys tenant and configure thedeletemode for deleting archive files:obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test/backup/archive?host=cos.ap-xxxx.myqcloud.com&access_id=***&access_key=***&delete_mode=delete' TENANT = mysql_tenant;Use COS as the archive media. Set the archiving path for the current tenant and configure the
deletemode for deleting archive files:obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=s3://oceanbase-test/backup/archive?host=cos.ap-xxxx.myqcloud.com&access_id=***&access_key=***&delete_mode=delete';In these examples,
s3://indicates that the object storage path is accessed through the S3 protocol. The bucket name isoceanbase-testand the path in the bucket is/backup/archive. The parameters are separated from the path by using?, and the parameters are separated by using&. Thehostparameter specifies the endpoint of COS without the bucket name. Theaccess_idandaccess_keyparameters specify the access keys of the COS service. Thedelete_modeparameter is set todelete.Notice
The archive access protocol cannot be changed during archiving. For example, archiving cannot be changed from S3 to OSS, or from OSS to S3.
tab Azure Blob Storage
In V4.3.5, Azure Blob Storage is supported as the archive media starting from V4.3.5 BP3.
Like Alibaba Cloud OSS, Azure Blob Storage supports the
delete_modeandchecksum_typeparameters. Thedelete_modeparameter specifies the cleanup mode for the archive files. If you do not explicitly configure thedelete_modeparameter, thedeletemode is used by default. Thechecksum_typeparameter specifies the verification algorithm for verifying the integrity of the archive files. The supported values aremd5andno_checksum. If you do not explicitly configure thechecksum_typeparameter, the default value ismd5.For more information about the parameters, see SET LOG_ARCHIVE_DEST.
Here are some examples:
Notice
- When you use an object storage service as the archive media, the parameters of the object storage path are separated by
&. Make sure that the parameter values contain only uppercase and lowercase English letters, numbers,/-_$+=, and wildcard characters. If you enter other characters, the configuration may fail. - When you use Azure Blob Storage as the archive media, the prefix of the
hostparameter must be specified ashttp://orhttps://. By default, Azure Blob Storage enables secure transfer. Therefore, it is accessed by usinghttps://. If you want to access it by usinghttp://, you must disable secure transfer for Azure Blob Storage. For more information, see Azure Blob Storage documentation on the Microsoft website.
When you use Azure Blob Storage as the archive media, set the archive path for the
mysql_tenanttenant in the system tenant. The cleanup mode isdelete, and the verification algorithm ismd5.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' TENANT = mysql_tenant;When you use Azure Blob Storage as the archive media, set the archive path for the current tenant in the user tenant. The cleanup mode is
delete, and the verification algorithm ismd5.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';
In the preceding examples,
azblob://indicates that Azure Blob Storage is used as the archive media. The bucket name isoceanbase-test-bucket, and the path in the bucket is/backup/archive. The path and parameters are separated by?, and the parameters are separated by&.hostspecifies the host address of the bucket, which can be obtained by concatenating the container attribute or connection string of the storage account.access_idspecifies the name of the storage account.access_keyspecifies the access key of Azure Blob Storage. The cleanup mode isdelete, and the integrity of the archive files is verified by using the MD5 algorithm.Configure the
BINDINGattribute (optional)The
BINDINGattribute specifies the priority mode between archiving and business. The attribute supports theOptionalandMandatorymodes. If you do not configure the attribute, the default valueOptionaltakes effect.The
Optionalmode indicates that business takes priority. In this mode, if the archiving speed falls behind the log generation speed, logs may be recycled before they are archived, causing a log stream interruption.The
Mandatorymode indicates that archiving takes priority. In this mode, if archiving falls behind the data write speed, data write may fail.
Here is an example of configuring the
BINDINGattribute when you use NFS as the archive media in the sys tenant:obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional' TENANT = mysql_tenant;Here is an example of configuring the
BINDINGattribute when you use NFS as the archive media in the current tenant:obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional';Configure the
PIECE_SWITCH_INTERVALattribute (optional)The
PIECE_SWITCH_INTERVALattribute specifies the interval for switchingpiece. The value range is[1d, 7d]. If you do not configure the attribute, the default value1dtakes effect.Here is an example of configuring the
PIECE_SWITCH_INTERVALattribute when you use NFS as the archive media in the sys tenant:obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant;Here is an example of configuring the
PIECE_SWITCH_INTERVALattribute when you use NFS as the archive media in the current tenant:obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d';
After the configuration is completed, you can query the parameter settings in views.
The
systenant can query the parameter settings in theCDB_OB_ARCHIVE_DESTview, and a user tenant can query the parameter settings in theDBA_OB_ARCHIVE_DESTview. For more information about how to query the parameter settings, see Query archive parameters.
Considerations and descriptions after the configuration is completed
After the
LOG_ARCHIVE_DESTparameter is successfully configured, the system creates aformatfile in the directory where the specified backup destination is located. Theformatfile is used to verify the validity of the backup destination and ensure the integrity of data in the destination. Therefore, note the following considerations when you configure a backup destination:If the
formatfile does not exist, the specified directory must be empty. Otherwise, an error-9080is returned, indicating that the file does not exist.If the
formatfile already exists, its content must pass the verification for the specified parameter to take effect. Otherwise, an error-9081is returned, indicating that the file does not match. The content verification of theformatfile mainly checks whether the cluster, tenant, and backup destination type specified in the file are consistent with those in the current operation.If the
formatfile does not exist or its content fails the verification during backup task execution, the task will fail.
After the destination for incremental backup is successfully configured, the destination for subsequent full backup cannot be changed. For example, if the
BINDINGattribute of the archival path/data/nfs/backup/archiveunder the NFS system is set toMandatoryand thePIECE_SWITCH_INTERVALattribute is set to1d, to change thePIECE_SWITCH_INTERVALto2dwhile retaining theBINDINGattribute setting ofMandatory, you still need to specify the value of the other attribute in the command. Otherwise, the attribute without a specified value will use the default value.You need to execute the following statements again for the modification.
Modification of a user under the system tenant
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST = 'LOCATION=file:///data/nfs/backup/archive BINDING=Mandatory PIECE_SWITCH_INTERVAL=2d' TENANT = mysql_tenant;Modification of a user under a user tenant
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST = 'LOCATION=file:///data/nfs/backup/archive BINDING=Mandatory PIECE_SWITCH_INTERVAL=2d';
After the archiving destination is set successfully, if the user changes the key information of the object storage due to security or other reasons, it is necessary to update the
access_idandaccess_keyinformation for the configured archiving path. For specific operations, refer to Change theaccess_idandaccess_keyInformation for the Backup Path or Archiving Path.
(Optional) Configure archive lag
OceanBase Database uses the tenant-level parameter archive_lag_target to control the latency of log archiving for the tenant. This parameter supports units of ms, s, m, and h. The default value is 2m, which specifies the maximum interval between two consecutive archive I/O operations and ensures that online logs can be archived in a timely manner, thereby reducing the risk of data loss.
OceanBase Database archives logs by log stream. If a log stream has logs written to it and the time since its last archive exceeds the value specified by the archive_lag_target parameter, the system triggers an archive operation for that log stream to archive all unarchived logs in the log stream.
For example, if the archive_lag_target parameter is set to 120s (2 minutes), each log stream will attempt to trigger an archive operation every 2 minutes (unless other conditions are met, such as the archive buffer being full), ensuring that the interval between two consecutive archive I/O operations for this log stream is less than 2 minutes. If the archive_lag_target parameter is set to 0, the system achieves real-time archiving.
For more information about the archive_lag_target parameter, see archive_lag_target.
Prerequisites
Before you modify the value of the archive_lag_target parameter, make sure that the archive destination has been configured. If the archive destination is not configured, the system will return an error message indicating that the archive destination has not been set when you try to modify the value of the archive_lag_target parameter.
Considerations
If the archive media is OSS, NFS, or COS, you can set the
archive_lag_targetparameter to any value within its valid range. If the archive media is an object storage service (OBS) or other object storage services compatible with the S3 protocol, the value of thearchive_lag_targetparameter must be greater than or equal to60s. If you set the value to be less than60s, the system will return an error.We recommend that you set the
archive_lag_targetparameter to a reasonable value to avoid frequent I/O operations that may affect system performance, especially when object storage is used. A high value may fail to meet the timeliness requirement for data recovery. Therefore, you need to strike a balance between the RPO and the performance of the archive media based on your business needs.
Procedure
Log in to the database as the tenant administrator of the
systenant or a user tenant.Based on your needs, execute the appropriate statement to configure the archive lag.
Here are some examples:
Configure the archive lag for a specified tenant when you are in the
systenant.obclient> ALTER SYSTEM SET archive_lag_target = '120s' TENANT = mysql_tenant;Notice
When you configure the
archive_lag_targetparameter, you cannot useTENANT = all_userto specify all user tenants in thesystenant.Configure the archive lag for the current tenant when you are in a user tenant.
obclient> ALTER SYSTEM SET archive_lag_target = '120s';