Updated on 2024-11-29 GMT+08:00

Redis Data Restoration Tool

Scenario

Use the backup data file to restore the data stored in the Redis cluster as an MRS cluster administrator when the Redis service is faulty or reinstalled. The restoration operation does not delete the existing data in the Redis cluster.

Prerequisites

  • The Redis cluster and instances are running properly.
  • You have obtained the backup Redis data files.
  • If the installation mode of the Redis service is the security mode, the Redis client can access the Redis cluster and perform operations only after login authentication and authorization. You need to perform the following operations:
    1. Log in to FusionInsight Manager and choose System > Permission > Role to create a role that has the permission to manage the specified Redis cluster. For details, see Creating a Redis Role.
    2. Choose System > Permission > User, create a machine-machine user, and assign the role permissions created in 1 to the role.
    3. After the user is created successfully, click More > Download authentication credential next to the username in the user list to download the keytab file. After the file is automatically generated, specify the location to save the file.

      xxx indicates the version number. Replace it with the actual version number.

    4. Decompress the keytab file, and upload the decompressed file to the Software installation path/FusionInsight_HD_xxx/install/FusionInsight-redis-xxx/redis/config directory on the target Redis node as user omm.
    5. In the Software installation path/FusionInsight_HD_xxx/install/FusionInsight-redis-xxx/redis/config/auth.conf file, change the value of userName to Username@Cluster domain name, change the value of realmsName to the current domain name, change the value of keyTabFile to the absolute path of the uploaded user.keytab file, and change the value of krbConfPath to the absolute path of the uploaded krb5.conf file.

Procedure

  1. Upload the data file to be restored to any Redis node in the cluster, for example, the /opt/arch/cluster1 directory.
  2. Log in to the node as the root user.
  3. Run the following command to open the Redis backup configuration file aof-backup.properties, set related parameters based on the description in Table 1, save the settings, and exit:

    vi ${BIGDATA_HOME}/FusionInsight_HD_xxx/install/FusionInsight-redis-xxx/redis/config/aof-backup.properties

    Table 1 Parameters required for restoring the Redis cluster data

    Parameter

    Parameter Description

    Example Value

    redis.server.mode

    Redis operating modes, which include the following options:

    • single
    • cluster
    NOTE:

    The current version supports data backup and restoration only in Redis cluster mode.

    cluster

    redis.server.address

    Redis instance IP address (management plane) and port number.

    You can set this parameter to the IP address and port number of any Redis instance or the IP addresses and port numbers of multiple Redis instances in the Redis cluster to be restored, and use commas (,) to separate multiple pairs of IP address and port number.

    • The IP address of the Redis instance is the IP address of the node where the Redis instance is located.
    • The formula for calculating the port number of the Redis instance is: 22400 + Instance ID - 1.

      To view the instance ID, choose Cluster > Name of the desired cluster > Service > Redis > Redis Manager on FusionInsight Manager and click the target Redis cluster name.

      For example, in the Redis cluster, the port number of the Redis instance that corresponds to the role R1 port is 22400 (22400 + 1-1 =22400).

    192.168.0.100:22400

    192.168.0.100:22400,192.168.0.101:22401

    client.read.timeout

    Client read/write timeout interval, in milliseconds. You are advised to use the default value.

    10000

    aof.source

    Full path of the data file to be restored.

    If multiple data files are available, separate each two with a comma (,).

    /opt/arch/cluster1/192.168.0.101-22400.aof,/opt/arch/cluster1/192.168.0.101-22401.aof,/opt/arch/cluster1/192.168.0.102-22400.aof

    max.worker.num

    Maximum number of threads for restoring data files. You are advised to use the default value.

    10

    redis_ssl_on

    Whether to enable SSL channel encryption. The value must be the same as that configured on FusionInsight Manager.

    • true
    • false
    NOTE:

    Log in to FusionInsight Manager and choose Cluster > Services > Redis. Click Configuration then All Configurations and search for redis_ssl_on to view the value.

    false

  4. Run the following commands in the backup directory to ensure that the omm user has the operation permission:

    chmod 744 Outermost path for backup files -R

    chown omm:wheel Outermost path for backup files -R

  5. Run the su - omm command to switch to user omm.
  6. Go to the ${BIGDATA_HOME}/FusionInsight_HD_xxx/install/FusionInsight-redis-xxx/redis/sbin directory and run the redis-restore.sh script.

    cd ${BIGDATA_HOME}/FusionInsight_HD_xxx/install/FusionInsight-redis-xxx/redis/sbin

    ./redis-restore.sh

    After the restoration is successful, the following information is displayed:

    /opt/arch/cluster1/192.168.0.1-22400.aof: Success 
    /opt/arch/cluster1/192.168.0.2-22400.aof: Success