You must execute the ALTER SYSTEM statement to configure the archive destination in the LOG_ARCHIVE_DEST parameter before you enable log archiving. The sys tenant is used for managing clusters and does not contain user data or support backup and restore. Therefore, you do not need to configure the archive destination for the sys tenant.
Configure the archive destination
Set the LOCATION, PIECE_SWITCH_INTERVAL, and BINDING attributes of the archive destination.
Log on to the database as an administrator of the
systenant or a user tenant.Note:
The administrator user is
rootin MySQL mode andSYSin Oracle mode.Configure the archive destination.
Configure the archive destination for a specified tenant in the sys tenant
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=xxx [PIECE_SWITCH_INTERVAL=xxx] [BINDING=xxx]' TENANT = tenant_name;Configure the archive destination for the current tenant in a user tenant
ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=xxx [PIECE_SWITCH_INTERVAL=xxx] [BINDING=xxx]';
You can query the settings from the
DBA_OB_ARCHIVELOG_SUMMARYview. For more information, see View the archiving parameter settings.Procedure:
(Required) Set
LOCATION.The
LOCATIONattribute specifies the archive destination. OceanBase Database supports two types of media as the archive destination: Network File System (NFS) and Alibaba Cloud Object Storage Service (OSS).NFS
Notice:
When you use NFS as the archive destination, consider the following points:
- The value of
LOCATIONcannot be a string with a question mark (?). - The value of
LOCATIONmust be an absolute path, and the OBServer node must have read and write privileges on the destination specified byLOCATION. - Ensure that all OBServer nodes are mounted to NFS of the same server and use the parameter settings recommended in this topic. For more information about the procedure of deploying NFS, see Deploy the NFS client.
To set NFS as the archive destination, execute the following statement:
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://specifies that NFS is used as the media for the archive destination, and the archive path is/data/nfs/backup/archive.- The value of
Alibaba Cloud OSS
When you use OSS as the archive destination, besides the archive path and the
host,access_key, andaccess_idparameters, you can also set thedelete_modeparameter to configure the cleanup mode for archived files.The
delete_modeparameter has two values:deleteandtagging. If you do not specify this parameter, the default valuedeletetakes effect.delete: Archived files that meet the cleanup requirements are directly deleted.In this mode, when you enable automatic cleanup for archived files in automatic mode, the system directly deletes the archived files that meet the requirements.
Notice:
This is the default cleanup mode. If you do not specify
delete_mode, the default cleanup modedeletetakes effect.tagging: The archived files that meet the cleanup requirements are tagged and retained.In this mode, when you enable automatic cleanup for archived files, the system directly tags the archived files that meet the cleanup requirements. The key of the tag is
delete_modeand the value istagging. In this way, you can manage the lifecycle of these files on OSS based on the tags.
For more information about the automatic cleanup of archived data in
deleteortaggingmode, see Automatic cleanup of archived data.To set OSS as the archive destination and configure the
taggingcleanup mode, execute the following statement: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://specifies that OSS is the archive destination. The storage bucket is namedoceanbase-test-bucket. The path in the storage bucket is/backup/archive. The question mark (?) is used to separate other parameters of the path. Thehostparameter specifies the host address of the storage bucket. Theaccess_idandaccess_keyparameters specify the access key of OSS. The cleanup mode is set totagging.
(Optional) Set the
BINDINGattribute.The
BINDINGattribute specifies the prioritizing mode for archiving and businesses. The BINDING attribute has two values:OptionalandMandatory. If you do not specify this attribute, the default valueOptionaltakes effect.The
Optionalmode prioritizes user businesses. In this mode, when log archiving falls behind log generation, logs may be recycled before being archived. This causes an interruption.The
Mandatorymode prioritizes archiving. In this mode, you may be unable to write more data before existing data is archived.
Here is an example:
obclient> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Mandatory' TENANT = mysql_tenant; obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST='LOCATION=file:///data/nfs/backup/archive BINDING=Optional';(Optional) Set the
PIECE_SWITCH_INTERVALattribute.The
PIECE_SWITCH_INTERVALattribute specifies the switching interval for pieces. The value range is[1d, 7d]. If you do not specify this attribute, the default value1dtakes effect.To configure an archive path and generate a log piece every two days, execute the following statement:
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 you set the LOG_ARCHIVE_DEST parameter, the system will create a file named format by default in the directory where the configured destination is located. This file is used to verify the validity of the archive destination and ensure the integrity of the data at the destination. Therefore, note the following items when you configure the log archive destination:
If the
formatfile does not exist, the directory where the configured destination is located must be empty so that theLOG_ARCHIVE_DESTparameter can be set. If this directory is not empty, the system returns the-9080error to indicate that theformatfile does not exist.If the
formatfile exists, its content must be verified so that the parameter can be set. Otherwise, the system returns the-9081error to indicate that theformatfile does not match. The content of theformatfile is verified to check whether the types of the cluster, tenant, and backup destination in the file match those of the current cluster, tenant, and backup destination.When you execute a backup job, the job fails to be initiated if the
formatfile does not exist or fails the verification.
In addition, incremental configuration is not supported after the archive destination is configured. For example, the BINDING attribute is set to Mandatory and the PIECE_SWITCH_INTERVAL attribute is set to 1d for the archive path /data/nfs/backup/archive in NFS. To update PIECE_SWITCH_INTERVAL to 2d but keep BINDING as Mandatory, you still need to specify values for other attributes. Otherwise, the default values are used for unspecified attributes.
Execute the following statement to modify the attribute settings:
obclient [(none)]> ALTER SYSTEM SET LOG_ARCHIVE_DEST = 'LOCATION=file:///data/nfs/backup/archive BINDING=Mandatory PIECE_SWITCH_INTERVAL=2d' TENANT = mysql_tenant;