This topic describes how to configure the backup destination and the backup-related parameters.
Configure the backup destination
Log on to the
systenant as therootuser.Configure the backup destination.
OceanBase Database allows you to use Network File System (NFS) and Alibaba Cloud Object Storage Service (OSS) as the backup destination.
For example:
NFS
Notice
When you use NFS as the backup destination, note the following points:
- The string value of
backup_destcannot contain the question mark (?). backup_destmust be set to an absolute value to ensure that the OBServer node has the write permission on thebackup_dest.- 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 mounting NFS, see Deploy the NFS client.
- After you set the backup destination and enable backup, the backup files are stored in the directory named after the cluster. A backup destination can store backup files of different clusters. If the directory where the backup destination resides contains a directory with the same name as the cluster, this directory named after the cluster must be empty.
Set the backup destination to NFS:
obclient> ALTER SYSTEM SET backup_dest='file:///data/nfs/backup';- The string value of
Alibaba Cloud OSS
When you use OSS as the backup destination, you can set the backup destination and the
delete_modeparameter to configure the backup file clearing mode.The
delete_modecan be set to either of the following modes:deletespecifies that backup files that meet requirements are directly cleared.After you configure this mode, the system clears backup files that meet the requirements, regardless of whether the backup file clearing mode is automatic or manual. This is the default clearing mode. If you do not specify
delete_mode, the default clearing modedeleteis used.taggingspecifies that backup files that meet the clearing requirements are tagged and retained.After you configure this mode, the system tags backup files that meet the clearing requirements, regardless of whether the backup file clearing mode is automatic or manual. The key of the tag is set to
delete_modeand the value is set totagging. This way, you can manage the lifecycle of these files on OSS based on the specified tag.
For more information about the operation of automatically clearing backup data, see Automatically clear backup data for clusters. For more information about the operation of manually clearing backup data, see Manually clear backup data for clusters.
Set the backup destination and configure a backup file clearing mode:
obclient> ALTER SYSTEM SET backup_dest='oss://oceanbase-test-bucket/backup/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx&delete_mode=delete';Notice
- After you configure
backup_destand initiate a backup task, the value of thedelete_modeparameter cannot be modified. - You must use the automatic backup expiration feature of OSS in conjunction with the
delete_modeparameter of OceanBase Database.
Huawei Cloud OBS
obclient> ALTER SYSTEM SET backup_dest='obs//oceanbase-test-appid/backup?host=obs.cn-east-2.myhuaweicloud.com&access_id=xxx&access_key=xxx';
After the backup destination is configured, the destination can be replaced only after you perform the following steps during backup and secondary backup tasks:
Stop the backup task.
For more information, see Stop a backup.
(Recommended) Stop backup clearing.
For more information, see Stop backup data clearing for clusters.
Stop the secondary backup task.
For more information, see Stop a secondary backup.
(Recommended) Stop secondary backup clearing.
For more information, see Stop secondary backup clearing.
(Optional) Configure backup parameters
Log on to the
systenant as therootuser.Set the
backup_dest_optionparameter to configure backup-related parameters.The backup parameters include:
log_archive_checkpoint_intervalThe
log_archive_checkpoint_intervalparameter specifies the interval of generating log archive checkpoints for infrequently accessed partitions.Note
Partitions with data writes are archived by clog. Infrequently accessed partitions do not have data writes. Therefore, log archive checkpoints are generated to facilitate log archiving for infrequently accessed partitions.
If you do not specify this parameter for
backup_dest_option, the value of the cluster-levellog_archive_checkpoint_intervalis used by default. If you do not specify eitherbackup_dest_optionorlog_archive_checkpoint_interval, the default value120sis used. If bothbackup_dest_optionandlog_archive_checkpoint_intervalare specified, the value ofbackup_dest_optionis used. We recommend that you set this parameter forbackup_dest_option.recovery_windowThe
recovery_windowparameter specifies the time window for restoring backup data. The system determines whether backup data has expired based on the value of this parameter. For example, the configurationrecovery_window='7d'indicates that backup data within the last 7 days can be restored, and the backup data beyond this restore window is considered expired. For more information about therecovery_windowparameter, see Automatically clear backup data for clusters.If you do not specify this parameter for
backup_dest_option, the value of the cluster-levelbackup_recovery_windowis used by default. If you do not specify eitherbackup_dest_optionorbackup_recovery_window, the default value0is used, indicating that backup data will never expire. If bothbackup_dest_optionandbackup_recovery_windoware specified, the value ofbackup_dest_optionis used. We recommend that you set this parameter forbackup_dest_option.When the backup expires, the system automatically clears it based on preset rules.
In the manual clearing mode, when the backup data expires, you can manually clear the data as the administrator.
auto_delete_obsolete_backupThe
auto_delete_obsolete_backupparameter specifies whether to enable automatic data clearing. When you setauto_delete_obsolete_backupto true, the system automatically clears expired backup data.If you do not specify this parameter for
backup_dest_option, the value of the cluster-levelauto_delete_expired_backupis used by default. If you do not specify eitherbackup_dest_optionorauto_delete_expired_backup, the default valuefalseis used, which indicates that expired backup data is not automatically cleared. If bothbackup_dest_optionandauto_delete_expired_backupare specified, the value ofbackup_dest_optionis used. We recommend that you set this parameter forbackup_dest_option.log_archive_piece_switch_intervalThe
log_archive_piece_switch_intervalparameter specifies whether to automatically split the log file directory into multiple directories based on a specific interval. Value range: [1d, 7d]. Default value:0, which specifies not to perform log splitting.You must configure this parameter to enable log splitting.
backup_copiesThe
backup_copiesparameter specifies the number of backup copies. Default value:0. If you do not specifybackup_backup_dest, we recommend that you set backup_copies to2. The valid value range of backup_copies is [0, 8].If you set
backup_copiesto a value less than2, the system deletes backup data without considering whether its secondary backup is successful. If you setbackup_copiesto2, the system will only automatically clear backup data inbackup_destafter its secondary backup is saved tobackup_backup_dest. If secondary backup is not set, we recommend that you use the default value.
For more information about the
backup_dest_optionparameter, see backup_dest_option.Here is an example:
obclient> ALTER SYSTEM SET backup_dest_option='log_archive_checkpoint_interval=2m&recovery_window=7d&auto_delete_obsolete_backup=true&log_archive_piece_switch_interval=1d&backup_copies=0';