Ubuntu
Redis 伺服器拒絕所有通過 Unix 套接字的連接
我正在執行帶有 Redis 5.0.7 的 Ubuntu 伺服器 20.04 LAMP。
問題:
當使用
port 0
Redis 配置 unix 套接字時,會拒絕所有連接。基本
/etc/redis/redis.conf
:# create a unix domain socket to listen on unixsocket /var/run/redis/redis.sock # set permissions for the socket unixsocketperm 775 bind 127.0.0.1 daemonize yes stop-writes-on-bgsave-error no rdbcompression yes # maximum memory allowed for redis maxmemory 50M # how redis will evice old objects - least recently used maxmemory-policy allkeys-lru # tells redis to ignore TCP ports port 0 #creates pidfile pidfile /run/redis/redis-server.pid
插座:
# ls -lh /var/run/redis total 4.0K -rw-rw---- 1 redis redis 5 Jul 30 18:23 redis-server.pid srwxrwxr-x 1 redis redis 0 Jul 30 18:23 redis.sock
監聽埠:
# ps aux | grep redis redis 4912 0.1 0.0 50192 3972 ? Ssl 18:23 0:01 /usr/bin/redis-server 127.0.0.1:0 root 6395 0.0 0.0 6432 592 pts/1 S+ 18:36 0:00 grep --color=auto redis
拒絕連接:
# redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused not connected> quit
和
# redis-cli -h 127.0.0.1 -p 0 Could not connect to Redis at 127.0.0.1:0: Connection refused
防火牆完全禁用。
有任何想法嗎?
從我看到的評論
redis
中不聽 TCP 埠而只使用套接字。在這種情況下,應使用命令完成連接redis-cli -s /var/run/redis/redis.sock
線
redis-cli -h 127.0.0.1 -p 0
連接到IP和埠。而且你不能使用 port
0
,AFAIK它是reserverd