This topic describes the preparations for log archiving.
Configure the log archive concurrency (optional)
Before you enable the archive mode, you can configure the log archive concurrency to increase the log archiving speed of a tenant.
Log in to the database as the tenant administrator of the
systenant or a user tenant.Choose an appropriate statement to set the
log_archive_concurrencyparameter.The tenant-level
log_archive_concurrencyparameter specifies the total number of worker threads for log archiving. The parameter value takes effect immediately without the need to restart the OBServer node. The default value is1, with a value range of [1, 100]. Currently, only the values 1 to 10 are supported. If the value is greater than 10, it will be set to 10. More worker threads will lead to higher memory usage. Generally, we recommend that you use the default value unless you have special requirements.Notice
We recommend that you use the default value for small tenants (with two or four CPU cores) and do not modify the
log_archive_concurrencyparameter.You can set the parameter in the following ways:
Adjust the log archive concurrency for a tenant as the
systenantALTER SYSTEM SET log_archive_concurrency = 10 TENANT = mysql_tenant;Adjust the log archive concurrency for all tenants as the
systenantALTER SYSTEM SET log_archive_concurrency = 10 TENANT = ALL;Adjust the log archive concurrency for the current tenant as a user
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 an log archiving task, you must use the ALTER SYSTEM command to set the LOG_ARCHIVE_DEST parameter. The system tenant is a management tenant that does not contain user data. Therefore, it does not support backup and restore. As a result, you do not need to configure a destination for archiving logs for the sys tenant.
The procedure for configuring a destination for archiving logs mainly involves setting the LOCATION, PIECE_SWITCH_INTERVAL, and BINDING attributes.
Log in to the database as the tenant administrator of the
systenant or a user tenant.Note
The administrator user in MySQL mode is
root, and that in Oracle mode isSYS.Configure the destination for archiving logs.
Configure a destination for a specified tenant
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=xxx [PIECE_SWITCH_INTERVAL=xxx] [BINDING=xxx]' TENANT = tenant_name;Configure a destination for the current tenant
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=xxx [PIECE_SWITCH_INTERVAL=xxx] [BINDING=xxx]';
Notice
After upgrading OceanBase Database from V4.0.x to V4.1.0, you need to change the archive path.
After you set the destination, you can query the
DBA_OB_ARCHIVE_DESTview for more information. For more information, see View archive parameters.The following table describes the parameters to be set:
Set the
LOCATIONparameter (mandatory)The
LOCATIONparameter specifies the destination for archiving logs. Currently, OceanBase Database supports NFS and Alibaba Cloud OSS as the destination for archiving logs.NFS
Notice
When you use NFS as the destination for archiving logs, note the following points:
- The value of the
LOCATIONparameter cannot contain a question mark (?). - The value of the
LOCATIONparameter must be an absolute path that the OBServer node has read and write permissions for. - All OBServer nodes must mount the same NFS server. Additionally, to ensure smooth archiving, it is recommended that you use the parameters suggested in this topic to mount NFS. For more information, see Deploy an NFS client.
Here is an example of how to configure a destination for archiving logs when the destination is an NFS server:
obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive' TENANT = mysql_tenant; obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive';In this example,
file://indicates that NFS is used as the destination for archiving logs, and the log archive path is/data/nfs/backup/archive.- The value of the
Alibaba Cloud OSS
When you use OSS as the destination for archiving logs, you need to set the archive path,
host,access_key, andaccess_id. You can also use thedelete_modeparameter to configure the cleanup mode of the archived files.The
delete_modeparameter supports two values:deleteandtagging. The default value isdelete.delete: specifies to directly delete the archived files that meet the cleanup requirements.If you set this mode, when you automatically clear archived files, the system will directly delete the files that meet the cleanup requirements.
Notice
This is the default cleanup mode. If you do not specify the
delete_modeparameter, thedeletecleanup mode will be used.tagging: specifies to set theTagfor the archived files that meet the cleanup requirements and retain the files.If you set this mode, when you automatically clear archived files, the system will set a tag for the files that meet the cleanup requirements. The
keyof the tag is"delete_mode"and thevalueis"tagging". This allows you to manage the lifecycle of the files onOSSthrough the tags later.
For more information about how to clear archived data automatically, see Automatically clear up backed-up data.
Here is an example of how to configure a destination for archiving logs when the destination is OSS:
obclient [(none)]> 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; obclient [(none)]> 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';In this example,
oss://indicates that OSS is used as the destination for archiving logs. The name of the storage bucket isoceanbase-test-bucket, and the path in the storage bucket is/backup/archive. The parameters after?are used to separate other parameters in the path.hostis the host address of the storage bucket.access_idandaccess_keyare the access keys ofOSS. The cleanup mode is set totagging.
Set the
BINDINGattribute (optional)The
BINDINGattribute sets the priority mode for archiving and business. Currently, theOptionalandMandatorymodes are supported. The default value isOptional.The
Optionalmode indicates that the business takes precedence. In this mode, if the archiving speed (log archiving) cannot keep up with the log generation speed, the system may recycle logs that have not been archived in time, resulting in a log stream interruption.The
Mandatorymode indicates that archiving takes precedence. In this mode, if the archiving speed cannot keep up with the write speed of user data, the system may prevent you from writing user data.
Here is an example:
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional' TENANT = mysql_tenant; obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional';Set the
PIECE_SWITCH_INTERVALattribute (optional)The
PIECE_SWITCH_INTERVALattribute sets the cycle period for switchingpiece, with a value range of[1d, 7d]. The default value is1d.For example, the following sample code shows how to configure a destination for archiving logs and set a new
pieceevery two days:obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d' TENANT = mysql_tenant; obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional PIECE_SWITCH_INTERVAL=1d';
Considerations after configuration
After the LOG_ARCHIVE_DEST parameter is successfully configured, the system will create a format file in the specified destination directory to verify the validity of the destination and ensure the integrity of the data. Therefore, note the following considerations when you configure the destination for log archiving:
If the
formatfile does not exist, the specified destination directory must be empty. Otherwise, the system returns an error with the error code-9080, indicating that theformatfile does not exist.If the
formatfile exists, the content of the file must pass the verification. Otherwise, the system returns an error with the error code-9081, indicating that theformatfile is mismatched. The content verification of theformatfile checks whether the cluster, tenant, and destination type specified in the file are consistent with those for the current operation.If the
formatfile does not exist or the verification fails during backup, the task will fail.
In addition, after the destination for log archiving is successfully configured, incremental configuration is not supported. For example, assume that the BINDING attribute of the archive path /data/nfs/backup/archive in NFS is set to Mandatory, and the PIECE_SWITCH_INTERVAL attribute is set to 1d. If you want to change the value of the PIECE_SWITCH_INTERVAL attribute to 2d, you still need to specify the value of the BINDING attribute in the command. Otherwise, the value of the unspecified attribute will default to Mandatory.
You need to re-execute the following statements.
obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST = 'LOCATION=file:///data/nfs/backup/archive BINDING=Mandatory PIECE_SWITCH_INTERVAL=2d' TENANT = mysql_tenant;