redis導入rdb文件的方法:
1.在源實例生成aof數據,代碼命令如下:
# 清空上文目標實例全部數據
[root@172.20.0.1 ~]# redis-cli -h 172.20.0.2 -a password flushall
OK
# 源實例開啟aof功能,將在dir目錄下生成appendonly.aof文件
[root@172.20.0.1 ~]# redis-cli -h 172.20.0.1 -a password config set appendonly yes
OK
2.在目標實例導入aof數據,代碼命令如下:
# 假設appendonly.aof就在當前路徑下
[root@172.20.0.1 ~]# redis-cli -h 172.20.0.2 -a password --pipe < appendonly.aof
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 5
# 源實例關閉aof功能
[root@172.20.0.1 ~]# redis-cli -h 172.20.0.1 -a password config set appendonly no
OK