开发者社区> 问答> 正文

redis未设置密码报错errorERR operation not permitted


我现在有一台服务器上有redis服务,之前用着一直正常。最近出现两次连接redis服务出错的情况。出现问题的时候通过redis_cli执行redis的任何命令都提示(error) ERR operation not permitted,经查我本地的配置文件里没有设置过密码,而且我是用root用户去执行的,应该不会存在权限问题。而且将redis服务重启之后就会恢复正常。所以我想问一下这个问题应该是怎么解决的。谢谢。  
# requirepass foobared
而且我配置文件里有设置开启写入文件,但实际缓存未写进磁盘



# 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 /opt/srv/redis/

展开
收起
且听风吟lyg 2015-12-18 16:03:12 11322 0
4 条回答
写回答
取消 提交回答
  • Reredis未设置密码报错errorERR operation not permitted
    一,什么是overcommit or oom问题
    Linux对大部分申请内存的请求都回复"yes",以便能跑更多更大的程序。因为申请内存后,并不会马上使用内存。这种技术叫做Overcommit。当linux发现内存不足时,会发生OOM killer(OOM=out-of-memory)。它会选择杀死一些进程(用户态进程,不是内核线程),以便释放内存。
    当oom-killer发生时,linux会选择杀死哪些进程?选择进程的函数是oom_badness函数(在mm/oom_kill.c中),该函数会计算每个进程的点数(0~1000)。点数越高,这个进程越有可能被杀死。每个进程的点数跟oom_score_adj有关,而且oom_score_adj可以被设置(-1000最低,1000最高)。
    内核参数overcommit_memory,它是 内存分配策略
    可选值:0、1、2。
    0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
    1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
    2, 表示内核允许分配超过所有物理内存和交换空间总和的内存
    二,出现的问题
    redis运行一段时间后就挂掉了,ps查看进程没啥问题,查看redis的log,发现有warning,如下:
    [26145] 07 Dec 19:54:54 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
    telnet到6379,任何操作都会返回not permitted,
    [root@localhost redis]# telnet 127.0.0.1 6379
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    keys *
    -ERR operation not permitted
    redis并没有设置requirepass,不可能是因为权限问题导致not permitted。
    三,解决办法
    1,修改内核参数,3种方法,任选其一:
    (1)编辑/etc/sysctl.conf ,改vm.overcommit_memory=1,然后sysctl -p 使配置文件生效
    (2)sysctl vm.overcommit_memory=1
    (3)echo 1 > /proc/sys/vm/overcommit_memory
    2,修改redis.conf,然后重启redis
    maxmemory 5368709120
    maxmemory-policy allkeys-lru
    maxmemory-samples 3
    设置一下maxmemory,建议设置为物理内存的1/2到3/4,大小不要超过最大物理内存。
    2017-02-27 17:50:50
    赞同 展开评论 打赏
  • Reredis未设置密码报错errorERR operation not permitted
    看一下系统的cpu利用率。我碰到的情况是被挖矿的程序入侵了服务器,造成CPU利用率%100,所以redis报 operation not permitted
    2017-02-21 14:08:01
    赞同 展开评论 打赏
  • Reredis未设置密码报错errorERR operation not permitted
    遇到了同样的问题,尝试设置了一个密码进行访问,后续再抓一下
    2017-01-09 03:07:38
    赞同 展开评论 打赏
  • Reredis未设置密码报错errorERR operation not permitted
    求助呀,有没有人遇到过,有没有大神能帮忙看一下
    2015-12-18 16:57:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Redis集群演化的心路历程——从2.x到3.0时代 立即下载
微博的Redis定制之路 立即下载
云数据库Redis版的开源之路 立即下载