温馨提示×

redis如何导入rdb文件

小新
2708
2021-02-22 13:37:57
栏目: 云计算

redis如何导入rdb文件

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

1