您的位置:首页 > 数据库 > Redis

Redis 数据库迁移

2016-03-23 19:57 567 查看
这里说的数据库迁移,指的是,在一个服务器中生成的数据库文件,直接拷贝到另外一台服务器上,而且两台服务器可能使用的是不同的Redis端口及配置。

如果直接将数据库文件dump.rdb复制到另外一个Redis目录,对数据库进行操作,会发现,dump.rdb里面原来的数据没了,只有刚刚新添加的key-value。

其实解决办法很简单,只要更改一下Redis配置文件即可。

################################ SNAPSHOTTING  #################################
#
# Save the DB on disk:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving at all commenting all the "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

save 900 1
save 300 10
save 60 10000


只要把save这几行注释掉,然后把生成的数据库文件复制过去,会发现,原来的数据还在,成功喽~~~

#save 900 1
#save 300 10
#save 60 10000
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息