解决Redis服务错误一例听语音

来源:互联网 发布:鼠标点击翻译软件 编辑:程序博客网 时间:2024/06/14 07:25

Redis是很有效的一项服务,但是初学者会碰到很多问题,我希望这篇文章能够帮助到他们。

在运行Redis服务后,几分钟后抛出一个错误:

Failed Opening .rdb for saving:Permission denied.

Background saving error

根据错误提示,是Redis后台保存时遭遇了权限问题。


  1. 在终端中打开redis.conf文件,redis.conf文件通常是在/usr/local/bin  目录下

    $ cd /usr/local/bin

    $ vim redis.conf

  2. 2

    在redis.conf文件中搜索dir的配置项,dir配置项是rdb文件保存的目录,

    # The working directory.

    ## The DB will be written inside this directory, with the filename specified# above using the 'dbfilename' configuration directive.

    # # The Append Only File will also be created inside this directory.

    # # Note that you must specify a directory here, not a file name.

    dir ./

    此处./表示redis-server所在的目录,查看该目录的权限

  3. 3

    查看权限

    $ ls -l

    ....

    -rw-r--r--.    1    root     root     35    Aug    4    00:59    dump.rdb

    ....

    此处dump.rdb文件root账号是有读写权限,而同为管理员组的其他账号之后读权限,所以造成了上诉问题

  4. 4

    修改文件权限:

    $ chmod g+w dump.rdb