如何将dump.rdb文件加载到redis中?

我有一个dump.rdb文件,它与redis.config位于同一目录中。

当我开始我的服务器时:

redis-server ./redis.config 

它不会加载该1 GB文件中的数据。

我如何加载数据?

编辑你的configuration文件,将dir选项设置为当前工作目录:

 # The filename where to dump the DB dbfilename dump.rdb # The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # Also the Append Only File will be created inside this directory. # # Note that you must specify a directory here, not a file name. dir /current/working/directory 

我们发现我们必须事先closuresaof,否则redis会在启动时创build一个空白的aof,并使用它来代替rdb文件。 一旦redis创build一个填充的aof,那么你可以重新打开aof。

做如下:

  1. 修改redis.conf,禁用appendonly.aof
     appendonly没有
  1. 重新启动Redis服务器

  2. 运行redis-cli BGREWRITEAOF ,创build一个新的appendonly文件。

  3. 修改redisconfigurationappendonlyyes并重新启动您的redis服务器

请看这个