Manual Packaging
Package source components following the instructions below to prevent data, configuration, and log files outside the installation package from being lost.
The tool cannot automatically migrate Redis installed using an RPM package. Perform a manual migration instead.
Files to Be Migrated
Procedure
- Check whether the files to be migrated are in the specified directories.
- Create a directory named source_related for storing additional files required for migration in the same directory as redis-server, for example, bin/source_related.
1 2
mkdir source_related cd source_related
- To start Redis, you need to specify the configuration file (redis.conf by default). If your configuration file is not in the preceding directory, run the following commands:
1 2
mkdir -p ./path/to/ cp /path/to/redis.conf ./path/to
/path/to: directory storing redis.conf. Replace it with the actual directory.
- Query the data and log file paths.
- Open another terminal, start redis-server, and access the redis-cli console. Run the following command to query the data file paths (the default files are dump.rdb and appendonly.aof):
1./redis-cli -h IP -p port
- IP: Redis IP address.
- The default port enabled for redis-cli is 6379.
- If the requirepass field is set in the configuration file, run the following command to verify the password:
1AUTH password - Query the data directory.
- Obtain dir:
1CONFIG GET dir
Command output:1 2
1) "dir" 2) "/home/user"
- Obtain appendfilename.
1CONFIG GET appendfilename
Command output:
1 2
1) "appendfilename" 2) "appendonly.aof"
If the command output is empty (empty list or set), run the CONFIG GET appendonly command. If yes is returned, search for the appendfilename field in the Redis configuration file specified in step 3. For example, the default value of appendfilename is appendonly.aof.
- Obtain dbfilename.
1CONFIG GET dbfilename
Command output:1 2
1) "dbfilename" 2) "dump.rdb"
- Obtain dir:
- Query the log file path.
1CONFIG GET logfile
Command output:1 2
1) "logfile" 2) "/home/user/redis/redis-4.0.14/redis.log"
- If the file exists and is not in the preceding directory structures, go back to the previous terminal and run the following command in the source_related directory:
1mkdir -p ./dir_address
- Copy data files.
1 2
cp /home/user/appendonly.aof ./dir_address cp /home/user/dump.rdb ./dir_address
- Copy log data.
1 2
mkdir -p ./home/user/redis/redis-4.0.14 cp /home/user/redis/redis-4.0.14/redis.log ./home/user/redis/redis-4.0.14
/home/user/redis/redis-4.0.14/redis.log: log file directory obtained in step 4.d. Replace it with the actual directory.
- Open another terminal, start redis-server, and access the redis-cli console. Run the following command to query the data file paths (the default files are dump.rdb and appendonly.aof):
- Create a JSON file named devkit_redis_conf_data.json in the parent directory of redis-server and add the following content to the file. Modify the content as required. If the sentinel mode is used, set is_sentinel_mode to true.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
{ "redis": { "redis_conf": "", "redis_conf_in_package": false, "redis_dir": "", "redis_dir_in_package": false, "redis_dbfile": "", "redis_aof": "", "redis_logfile": "", "redis_logfile_in_package": false, "redis_pidfile": "" }, "sentinel": { "sentinel_conf": "", "is_sentinel_mode": false, "sentinel_conf_in_package": false, "sentinel_dir": "" } }
Redis configuration:
- redis_conf: absolute path to the Redis configuration file.
- redis_conf_in_package: indicates whether the Redis configuration file is in the Redis installation package. The default value is false.
- redis_dir: absolute path to dir obtained in step 4.c.
- redis_dir_in_package: indicates whether dir is in the Redis installation package. The default value is false.
- redis_dbfile: absolute path to dbfilename obtained in step 4.c.
- redis_aof: absolute path to appendfilename obtained in step 4.c.
- redis_logfile: absolute path to logfile obtained in step 4.d.
- redis_logfile_in_package: indicates whether logfile is in the Redis installation package. The default value is false.
- redis_pidfile: pidfile path in the Redis configuration file. Leave it empty if you do not want to change it.
Sentinel configuration:
- sentinel_conf: absolute path to the Redis sentinel configuration file. The default value is sentinel.conf.
- is_sentinel_mode: indicates whether to enable the sentinel mode. The default value is false. To enable this mode, set it to true.
- sentinel_conf_in_package: indicates whether the Redis sentinel configuration file is in the Redis installation package. The default value is false.
- sentinel_dir: absolute path to dir in the Redis sentinel configuration file. Leave it empty if you do not want to change it.
- Compress the installation directory of the source components to be scanned into a package, for example, a tar.gz package. Replace the example package name with the actual one.
- Run the packaging command in the upper-level directory of the directory where redis-server is located to generate a package, for example, redis.tar.gz.
- For the bin/redis-server directory structure, go to the upper-level directory of bin and run the following command:
tar -zcvf redis.tar.gz bin/
- For the redis-xxx/src/redis-server directory structure, go to the upper-level directory of redis-xxx and run the following command:
tar -zcvf redis.tar.gz redis-xxx/
- For the bin/redis-server directory structure, go to the upper-level directory of bin and run the following command:
- Obtain the source components using either of the following methods:
- If you select the Upload source component package option, return to the Add Component Information tab, and click Upload next to Upload source component package to upload the source component package.
- If you select the Obtain from node server option, run the following command to decompress the source component package.
- Log in to the tool through SSH and upload the package to the user-defined directory on Target Node.
- Go to the directory that stores the package.
1cd User-defined_directory
- Decompress the source component package.
tar xvf redis.tar.gz
- After the decompression is complete, you can run the following command to delete the source component package.
rm -f redis.tar.gz
- Set the path to the decompressed file as the source component path.
- Run the packaging command in the upper-level directory of the directory where redis-server is located to generate a package, for example, redis.tar.gz.
- After the packaging is complete, delete the source_related directory and devkit_redis_conf_data.json file.