如何导入dump.rdb文件到redis本地服务器

how to import dump.rdb file to redis local server

您好,我正在尝试将 dump.rdb 文件导入我正在使用的本地 Redis ubuntu 14.04,

我试过这个解决方案:

  1. backup data from server using SAVE command
  2. Locate the location to put the dump.rdb file

因为我是用这个tutorial安装redis的,所以我复制导入的dump.rdb到我的redis根目录,然后像这样启动redis服务器这:

src/redis-server

然后使用以下方式连接客户端:

src/redis-cli

但是当我尝试使用 KEYS * 获取所有密钥时,我得到了 (empty list or set) 我哪里出错了?我已经玩了几个小时了,有什么帮助吗?谢谢

如果您正确地按照这些步骤进行操作,它将正常工作。

    1) Make sure the imported dump.rdb contains your data
    2) Stop the redis server
    3) copy the file in the correct directory (inside redis bin directory) 
parallel to redis-server.
    4) make sure you have the same data, that is copied. (bcz possibilites 
that if your server is still running, it will replace your dump.rdb).
    5) start your redis server you will surely find the values.

如果还是不行。检查 redis.conf 文件中的 dbfilename。 它必须是 dbfilename dump.rdb。如果位置发生变化,请将其放在正确的目录中。

希望这有效。

我在我的步骤中发现了问题,在文档中 quick start redis :
使用 src/redis-server Redis 是在没有任何显式配置文件的情况下启动的,因此我需要使用配置文件启动服务器以使服务器读取我的 dump.rdb 文件,如下所示:

src/redis-server redis.conf

现在我可以获取所有导入的数据了。