分享

Redis 数据库迁移

 WindySky 2017-11-23

这里说的数据库迁移,指的是,在一个服务器中生成的数据库文件,直接拷贝到另外一台服务器上,而且两台服务器可能使用的是不同的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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

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

#save 900 1
#save 300 10
#save 60 10000
  • 1
  • 2
  • 3

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多