redis import and export tool-redis-dump, centos7 installation and use
Install redis backup tool redi-dump on centos7
Precautions:
Because most of the system's built-in ruby version is 2.0.0 version, but redis-dump needs version 2.2.2 or higher to support. redis-dump is written in ruby language.
If you install it directly, the version will be too low. Requires higher version 2.2.2 or higher support.
The specific commands are as follows:
Install redis-dump
yum install centos-release-scl-rh -y
Configure yum warehouse
yum install rh-ruby23* -y
Install other tools, you may get an error if you don’t install it
scl enable rh-ruby23 bash
ruby -v
View version
gem install redis-dump -V
Note : Because scl enable rh-ruby23 bash is temporarily effective for the first time in the current shell window, you can use ruby -v to view the current version. Ruby is not permanent. If you switch the shell window to use the redis-dump command, it is recommended to execute scl enable rh-ruby23 bash again to make ruby2.3 take effect. Otherwise, there will still be problems;
redis-dump export data
(1) Export command
redis-dump -u 192.168.0.32 > test.json
If you carry the password, please execute the following command
redis-dump -u :[email protected]:16055 -d 0 >tes-fct111.txt
(2) Redis-load import data
< test.json redis-load -u 192.168.0.31
ERROR (Yajl::ParseError): lexical error: invalid bytes in UTF8 string.
lue":{"maxInactiveInterval":"¬웵0000\u0005sr\u0000\u0011jav
(right here) ------^
If an error is reported, the parameter -n can be added, and the utf-8 format will not be checked
< test.json redis-load -n -u 192.168.0.31