Updated on 2024-09-23 GMT+08:00

Backing Up ClickHouse Service Data

Scenario

To ensure ClickHouse service data security routinely or before a major operation on ClickHouse (such as upgrade or migration), you need to back up ClickHouse service data. The backup data can be used to recover the system if an exception occurs or the operation has not achieved the expected result, minimizing the adverse impacts on services.

You can create a backup task on FusionInsight Manager to back up ClickHouse service data. Both automatic and manual backup tasks are supported.

This function is supported only by MRS 3.1.0 or later.

Prerequisites

  • To back up data to a remote HDFS, the following conditions must be met:
    • A standby cluster for backing up data has been created. The authentication mode must be the same as that of the active cluster.
    • If the active cluster is deployed in security mode and the active and standby clusters are not managed by the same FusionInsight Manager, mutual trust has been configured. For details, see Configuring Mutual Trust Between MRS Clusters. If the active cluster is deployed in normal mode, no mutual trust is required.
    • Time is consistent between the active and standby clusters and the NTP services on the active and standby clusters use the same time source.
    • The HDFS in the standby cluster has sufficient space. You are advised to save backup files in a custom directory.
    • In active/standby mode, ensure that the value of HADOOP_RPC_PROTECTION of ClickHouse is the same as that of hadoop.rpc.protection of HDFS.
  • You have planned the backup type, period, object, and directory based on service requirements.

Backing Up ClickHouse Service Data

  1. On FusionInsight Manager, choose O&M > Backup and Restoration > Backup Management.
  2. Click Create.
  3. Set Name to the name of the backup task.
  4. Select the cluster to be operated from Backup Object.
  5. Set Mode to the type of the backup task.

    Periodic indicates that the backup task is executed by the system periodically. Manual indicates that the backup task is executed manually.

    Table 1 Periodic backup parameters

    Parameter

    Description

    Started

    Indicates the time when the task is started for the first time.

    Period

    Indicates the task execution interval. The options include Hours and Days.

    Backup Policy

    • Full backup at the first time and incremental backup subsequently
    • Full backup every time
    • Full backup once every n times
    NOTE:

    Incremental backup is not supported when Manager data and component metadata are backed up. Only Full backup every time is supported.

  6. In Configuration, select ClickHouse under Service Data.
  7. Set Path Type of ClickHouse to a backup directory type.

    Currently, only the RemoteHDFS type is available.

    RemoteHDFS: indicates that backup files are stored in HDFS of the standby cluster.

    This option is available for MRS 3.1.0 and 3.1.2 clusters only after you configure the environment by referring to Configuring the Environment When the ClickHouse Backup Task's Path is RemoteHDFS.

    You also need to configure the following parameters for MRS 3.2.0 and later clusters:
    • Destination NameService Name: indicates the NameService name of the standby cluster, for example, hacluster. You can obtain it from the NameService Management page of HDFS of the standby cluster.
    • IP Mode: indicates the mode of the target IP address. The system automatically selects the IP address mode based on the cluster network type, for example, IPv4 or IPv6.
    • Destination Active NameNode IP Address: indicates the service plane IP address of the active NameNode in the standby cluster.
    • Destination Standby NameNode IP Address: indicates the service plane IP address of the standby NameNode in the standby cluster.
    • Destination NameNode RPC Port: indicates the value of dfs.namenode.rpc.port in the HDFS basic configuration of the destination cluster.
    • Target Path: indicates the HDFS directory for storing standby cluster backup data. The storage path cannot be an HDFS hidden directory, such as a snapshot or recycle bin directory, or a default system directory, such as /hbase or /user/hbase/backup.
    You also need to configure the following parameters for MRS 3.1.0 or 3.1.2 clusters:
    • Destination NameService Name: indicates the NameService name of the standby cluster, for example, hacluster. You can obtain it from the NameService Management page of HDFS of the standby cluster.
    • IP Mode: indicates the mode of the target IP address. The system automatically selects the IP address mode based on the cluster network type, for example, IPv4 or IPv6.
    • Target NameNode IP Address: indicates the IP address of the NameNode service plane in the standby cluster. It can be of an active or standby node.
    • Target Path: indicates the HDFS directory for storing standby cluster backup data. The storage path cannot be an HDFS hidden directory, such as a snapshot or recycle bin directory, or a default system directory, such as /hbase or /user/hbase/backup.
    • Maximum Number of Backup Copies: indicates the number of backup file sets that can be retained in the backup directory.
    • Maximum Number of Maps: indicates the maximum number of maps in a MapReduce task. The default value is 20.
    • Maximum Bandwidth of a Map (MB/s): indicates the maximum bandwidth of a map. The default value is 100.

  8. Set Maximum Number of Recovery Points to the number of snapshots that can be retained in the cluster.
  9. Set Backup Content to one or multiple ClickHouse tables to be backed up.

    You can select backup data using either of the following methods:

    • Adding a backup data file

      Click the name of a database in the navigation pane to show all the tables in the database, and select specified tables.

      MRS 3.2.0 or later:

      1. Click Add.
      2. Select the table to be backed up under File Directory, and click Add to add the table to Backup Content.
      3. Click OK.
    • MRS 3.2.0 or later: Regular expression filtering
      1. Click Query Regular Expression.
      2. Enter the logical cluster and database to which the ClickHouse table belongs in the first text box as prompted. The logical cluster and database must match the existing logical cluster and database, for example, /default_cluster/database.
      3. Enter a regular expression in the second box. Standard regular expressions are supported. For example, to filter all tables that contain the keyword test in the database, enter test.*.
      4. Click Refresh to view the displayed tables in Directory Name.
      5. Click Synchronize to save the result.
      • When entering regular expressions, click or to add or delete an expression.
      • If the selected table or directory is incorrect, click Clear Selected Node to deselect it.
    • Versions earlier than MRS 3.2.0: Regular expression filtering
      1. Click Query Regular Expression.
      2. Enter the database where the ClickHouse tables are located in the first text box as prompted. The database must be the same as the existing database, for example, default.
      3. Enter a regular expression in the second text box. Standard regular expressions are supported. For example, to get all tables in the database, enter ([\s\S]*?). To get tables whose names consist of letters and digits, for example, tb1, enter tb\d*.
      4. Click Refresh to view the displayed tables in Directory Name.
      5. Click Synchronize to save the result.
      • When entering regular expressions, click or to add or delete an expression.
      • If the selected table or directory is incorrect, click Clear Selected Node to deselect it.

  10. Click Verify to check whether the backup task is configured correctly.

    The possible causes of the verification failure are as follows:

    • The target NameNode IP address is incorrect.
    • The directory or table to be backed up does not exist.
    • The name of the NameService is incorrect.

  11. Click OK.
  12. In the Operation column of the created task in the backup task list, click More and select Back Up Now to execute the backup task.

    After the backup task is executed, the system automatically creates a subdirectory for each backup task in the backup directory. The format of the subdirectory name is Data source_Task creation time, and the subdirectory is used to save latest data source backup files.

Configuring the Environment When the ClickHouse Backup Task's Path is RemoteHDFS

This topic is available for MRS 3.1.0 and 3.1.2 only.

  1. Log in to FusionInsight Manager of the standby cluster.
  2. Choose Cluster > Services > HDFS. Click More and select Download Client. Set Select Client Type to Configuration Files Only, select x86_64 for x86 or aarch64 for Arm based on the type of the node, and click OK.
  3. After the client file package is generated, download the client to the local PC as prompted and decompress the package.

    For example, if the client file package is FusionInsight_Cluster_1_HDFS_Client.tar, decompress it to obtain FusionInsight_Cluster_1_HDFS_ClientConfig_ConfigFiles.tar. Then, decompress this file to the D:\FusionInsight_Cluster_1_HDFS_ClientConfig_ConfigFiles directory on the local PC. The directory name cannot contain spaces.

  4. Go to the FusionInsight_Cluster_1_HDFS_ClientConfig_ConfigFiles\ client directory and obtain the hosts file.
  5. Go to FusionInsight_Cluster_1_HDFS_ClientConfig_ConfigFiles\HDFS\config to obtain the core-site.xml and hdfs-site.xml files.
  6. Log in to FusionInsight Manager of the source cluster.
  7. Choose Cluster > Services > ClickHouse, choose Configurations > All Configurations, and select backup under ClickHouse(Service).

    For remote_connect_core_config_file, click Upload File and select the core-site.xml file prepared in 5.

    For remote_connect_hdfs_config_file, click Upload File and select the hdfs-site.xml file prepared in 5.

    Figure 1 Configuring ClickHouse data backup parameters

  8. Click Save, confirm the information, and click OK to save the configuration. After saving the configurations, click Finish.
  9. Choose Cluster > Services > ClickHouse, click Instances, and view the instance IP address of ClickHouseServer.
  10. Log in to the host nodes of the ClickHouseServer instances as user root and check whether the /etc/hosts file contains the host information in 4. If not, add the host information in 4 to the /etc/hosts file.