Prepare for log archiving

2025-12-15 07:29:00  Updated

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.

  1. Log in to the database as the tenant administrator of the sys tenant or a user tenant.

  2. Choose an appropriate statement to set the log_archive_concurrency parameter.

    The tenant-level log_archive_concurrency parameter 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 is 1, 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_concurrency parameter.

    You can set the parameter in the following ways:

    • Adjust the log archive concurrency for a tenant as the sys tenant

      ALTER SYSTEM SET log_archive_concurrency = 10 TENANT = mysql_tenant;
      
    • Adjust the log archive concurrency for all tenants as the sys tenant

      ALTER 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_concurrency parameter, 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.

  1. Log in to the database as the tenant administrator of the sys tenant or a user tenant.

    Note

    The administrator user in MySQL mode is root, and that in Oracle mode is SYS.

  2. 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_DEST view for more information. For more information, see View archive parameters.

    The following table describes the parameters to be set:

    • Set the LOCATION parameter (mandatory)

      The LOCATION parameter 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 LOCATION parameter cannot contain a question mark (?).
        • The value of the LOCATION parameter 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.

      • Alibaba Cloud OSS

        When you use OSS as the destination for archiving logs, you need to set the archive path, host, access_key, and access_id. You can also use the delete_mode parameter to configure the cleanup mode of the archived files.

        The delete_mode parameter supports two values: delete and tagging. The default value is delete.

        • 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_mode parameter, the delete cleanup mode will be used.

        • tagging: specifies to set the Tag for 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 key of the tag is "delete_mode" and the value is "tagging". This allows you to manage the lifecycle of the files on OSS through 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 is oceanbase-test-bucket, and the path in the storage bucket is /backup/archive. The parameters after ? are used to separate other parameters in the path. host is the host address of the storage bucket. access_id and access_key are the access keys of OSS. The cleanup mode is set to tagging.

    • Set the BINDING attribute (optional)

      The BINDING attribute sets the priority mode for archiving and business. Currently, the Optional and Mandatory modes are supported. The default value is Optional.

      • The Optional mode 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 Mandatory mode 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_INTERVAL attribute (optional)

      The PIECE_SWITCH_INTERVAL attribute sets the cycle period for switching piece, with a value range of [1d, 7d]. The default value is 1d.

      For example, the following sample code shows how to configure a destination for archiving logs and set a new piece every 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 format file does not exist, the specified destination directory must be empty. Otherwise, the system returns an error with the error code -9080, indicating that the format file does not exist.

  • If the format file exists, the content of the file must pass the verification. Otherwise, the system returns an error with the error code -9081, indicating that the format file is mismatched. The content verification of the format file checks whether the cluster, tenant, and destination type specified in the file are consistent with those for the current operation.

  • If the format file 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;

References

Contact Us