首页 文章

redis dump.rdb /保存小文件

提问于
浏览
22

上下文

  • 我正在使用redis . 数据库<100 MB .

  • 但是,我想进行每日备份 .

  • 我也在Ubuntu Server 12.04上运行

输入时:

redis-cli保存

我不知道dump.rdb保存在哪里(因为redis是作为服务而不是在我的本地目录中启动的) .

问题:

  • 如何找到redis将dump.rdb保存到的位置?

  • 在某种程度上我可以指定一个文件名来“保存”,所以我输入如下内容:

redis-cli save~ / db-2012-06-24.rdb

谢谢

4 回答

  • 18

    您可以在redis.conf文件(启动服务器)上设置文件位置,查看服务器配置:

    # The filename where to dump the DB
    dbfilename dump.rdb
    

    找到当前保存文件的位置,这取决于你如何启动服务器 - 你有redis-server文件 - 我想你可以用 ps -e aux | grep redisps -e | grep redis 找到它

  • 14

    为了更有帮助...如何查找或设置redis保存dump.rdb文件的位置(ubuntu服务器):首先找到你redis.conf文件:在你的终端运行中:

    ps -e aux | grep redis
    

    我找到了我的redis.conf文件:

    var/etc/redis/
    

    如果您的位置相同,请使用以下命令打开文件:

    pico var/etc/redis/redis.conf
    

    寻找:

    # 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 /var/lib/redis
    

    根据您的“dbfilename”和“dir”的设置,这是您找到redis dump.rdb文件的位置 .


    Update :要查看您的redis配置,请运行:

    redis-cli CONFIG GET *
    
  • 9

    在我的(默认,Ubuntu)设置上,db文件位于

    /var/lib/redis/redis.rdb
    

    正如Christoffer指出的那样,您可以从命令行客户端看到所有设置

    CONFIG GET *
    
  • 24

    一个衬里获取目录和转储文件名

    echo "CONFIG GET *" | redis-cli | grep -e "dir" -e "dbfilename" -A1
    

相关问题