ubuntu – systemd redis.service不允许unix socket连接?

前端之家收集整理的这篇文章主要介绍了ubuntu – systemd redis.service不允许unix socket连接?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在ubuntu 16.04上安装了redis-server,我试图通过unix socket连接到它.我在redis.conf中注释掉了bind和port指令,并取消注释了unixsocket指令,所以我有:
  1. # Accept connections on the specified port,default is 6379.
  2. # If port 0 is specified Redis will not listen on a TCP socket.
  3. # port 6379
  4.  
  5. # TCP listen() backlog.
  6. #
  7. # In high requests-per-second environments you need an high backlog in order
  8. # to avoid slow clients connections issues. Note that the Linux kernel
  9. # will silently truncate it to the value of /proc/sys/net/core/somaxconn so
  10. # make sure to raise both the value of somaxconn and tcp_max_syn_backlog
  11. # in order to get the desired effect.
  12. tcp-backlog 511
  13.  
  14. # By default Redis listens for connections from all the network interfaces
  15. # available on the server. It is possible to listen to just one or multiple
  16. # interfaces using the "bind" configuration directive,followed by one or
  17. # more IP addresses.
  18. #
  19. # Examples:
  20. #
  21. # bind 192.168.1.100 10.0.0.1
  22. # bind 127.0.0.1
  23.  
  24. # Specify the path for the Unix socket that will be used to listen for
  25. # incoming connections. There is no default,so Redis will not listen
  26. # on a unix socket when not specified.
  27. #
  28. unixsocket /var/run/redis/redis.sock
  29. unixsocketperm 770

我已将我的本地用户添加到redis组,并使用sudo systemctl restart redis.serivce重新启动redis服务,因此/ var / run / redis /文件夹如下所示:

  1. drwxrwsr-x 2 redis redis 80 Apr 27 17:39 .
  2. drwxr-xr-x 34 root root 1160 Apr 27 16:40 ..
  3. -rw-r--r-- 1 redis redis 6 Apr 27 17:38 redis-server.pid
  4. srwxrwx--- 1 redis redis 0 Apr 27 17:38 redis.sock

我希望现在可以使用连接到套接

  1. $redis-cli -s /var/run/redis/redis.sock

但我得到:

  1. Could not connect to Redis at /var/run/redis/redis.sock: Permission denied
  2. not connected>

怪异地运行$redis-cli给了我默认的127.0.0.1:6379\u0026gt;哪个应该是不受约束的?

如果我看一下redis进程:

  1. redis 18108 0.0 0.0 40136 6652 ? Ssl 17:45 0:00 /usr/bin/redis-server *:6379

在我看来它甚至没有使用正确的conf文件并绑定到*:6379. /etc/systemd/system/redis.service文件

  1. ExecStart=/usr/bin/redis-server /etc/redis/redis.conf

所以我很困惑为什么这不是正在运行的进程,或者为什么权限不允许我连接.

将本地用户添加到redis组后,您是否已注销并重新登录?您需要这样做到 apply the changes.

猜你在找的Ubuntu相关文章