Redis 数据库迁移

这里说的数据库迁移,指的是,在一个服务器中生成的数据库文件,直接拷贝到另外一台服务器上,而且两台服务器可能使用的是不同的Redis端口及配置。
如果直接将数据库文件dump.rdb复制到另外一个Redis目录,对数据库进行操作,会发现,dump.rdb里面原来的数据没了,只有刚刚新添加的key-value。
其实解决办法很简单,只要更改一下Redis配置文件即可。

################################ SNAPSHOTTING  #################################
#
# Save the DB on disk:
#
#   save  
#
#   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

你可能感兴趣的:(Redis,数据库,redis,数据库,迁移,数据)