1. rdb数据备份恢复方法


redis 127.0.0.1:6379> SAVE
OK

或者

redis-cli -h 127.0.0.1 -p 6379 -a pwd bgsave

该命令将在 redis 安装目录中创建dump.rdb文件。

查找dump.rdb文件位置

redis 127.0.0.1:6379> CONFIG GET dir
1) “dir”
2) “/usr/local/redis/bin”

停止redis服务

redis-cli -p 6379 shutdown
127.0.0.1:6379> BGSAVE
Background saving started

2. AOF数据备份恢复方法

开启aof

redis-cli config set appendonly yes
redis-cli  --pipe < appendonly.aof
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 5
redis-cli config set appendonly no
OK

3. redis-dump

4. redis desktop manager 桌面图形管理工具

5 使用redis-dump-load工具

# pip install redis
# cd /usr/local
# git clone https://github.com/p/redis-dump-load.git
# cd redis-dump-load
# ./redisdl.py --help
# python redisdl.py -H 192.168.1.20 -p 6379 -d 0 -o /tmp/db0.json
# ll /tmp/db0.json
-rw-r--r--. 1 root root 411772591 Oct 17 09:15 /tmp/db0.json
python redisdl.py -l -H 192.168.204.128 -p 6379 -d 0 /tmp/db0.json
vi redisdl.py
version = [int(part) for part inself.info()['redis_version'].split('.')]
version = 3