worldtongfb 发表于 2018-4-27 12:41:13

redis无法连接

centos7 使用addons安装redis 安装完成后 php显示超时进入/usr/local/redis/bin redis-cli 卡住 没反应
service redis restart 和service redis stop都是卡在StoppingRedis server... 然后没反应
kill之后 重新启动正常 但是连接还是超时,开了远程连接显示操作超时
log是正常的
4740:M 27 Apr 12:28:20.653 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4740:M 27 Apr 12:28:20.653 # Server started, Redis version 3.2.8
4740:M 27 Apr 12:28:20.653 * DB loaded from disk: 0.000 seconds
4740:M 27 Apr 12:28:20.653 * The server is now ready to accept connections on port 6379

有一次出现绑定端口时有占用 kill之后重启就没了
反复试了几次
偶尔会出现
# service redis restart
/var/run/redis.pid does not exist, process is not running
Starting Redis server... done

这种情况 连接还是超时 ,最后addons.sh uninstall 卸载完之后神奇的发现竟然好使了
查了发现进程还在 kill之后就不好使了
再重装还是一样的超时问题 不知道为啥 装上之后就不好使 一直超时
但是卸载了之后反而好使了

worldtongfb 发表于 2018-4-27 13:01:25

1243 ./addons.sh uninstall redis1243 查看防火墙信息 关闭的 iptables没装
firewall-cmd --list-ports
FirewallD is not running

1245 ./addons.sh install redis
Add to auto startup...
Add redis service at system startup...
Restarting php-fpm......
Gracefully shutting down php-fpm . done
Starting php-fpmdone
/var/run/redis.pid exists, process is already running or crashed
====== Redis install completed ======
Redis installed successfully, enjoy it!


访问 timeout
1247 service redis status
Redis server is running.
停止卡住了
service redis stop
StoppingRedis server...

强行停止
service redis kill
force kill redis server...
done

修改log
vi /usr/local/redis/etc/redis.conf 改成允许远程连接
启动
service redis start
Starting Redis server... done

还是超时 查看日志
11593:M 27 Apr 12:51:34.292 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
11593:M 27 Apr 12:51:34.292 # Server started, Redis version 3.2.8
11593:M 27 Apr 12:51:34.292 * DB loaded from disk: 0.000 seconds
11593:M 27 Apr 12:51:34.292 * The server is now ready to accept connections on port 6379


netstat -atunlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address         Foreign Address         State       PID/Program name
tcp      0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      11593/redis-server

端口和进程都对
重启
service redis restart
StoppingRedis server...

又卡在停止redis这里了

然后ctrl+c 没kill进程 直接卸载
卸载完之后php用redis好使了

ps aux|grep redis
root   115930.10.0333362124 ?      Ssl12:51   0:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379


netstat -atunlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address         Foreign Address         State       PID/Program name
tcp      0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      11593/redis-server


查看进程和端口没变
问题好像就是进程还是端口被那个占用了 把redis卸载之后就放开了然后就能访问了

也不太懂到底啥问题 就是觉得怎么装上了不好使 卸载了反而好使了 太神奇了吧

licess 发表于 2018-4-27 13:43:06

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
这个的话编辑 /etc/sysctl.conf 加上 一行 net.core.somaxconn = 2048 然后执行sysctl -p 就行

php或cli 连接超时的话建议看一下iptables规则是否正常
页: [1]
查看完整版本: redis无法连接