VPS侦探论坛

 找回密码
 注册
查看: 3609|回复: 2

redis无法连接

[复制链接]
发表于 2018-4-27 12:41:13 | 显示全部楼层 |阅读模式

centos7 使用addons安装redis 安装完成后 php显示超时进入/usr/local/redis/bin redis-cli 卡住 没反应
service redis restart 和service redis stop都是卡在Stopping  Redis 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之后重启就没了
反复试了几次
偶尔会出现
[root@jdu4e00u53f7 etc]# service redis restart
/var/run/redis.pid does not exist, process is not running
Starting Redis server... done

这种情况 连接还是超时 ,最后addons.sh uninstall 卸载完之后神奇的发现竟然好使了
查了发现进程还在 kill之后就不好使了
再重装还是一样的超时问题 不知道为啥 装上之后就不好使 一直超时
但是卸载了之后反而好使了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 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-fpm  done
/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
Stopping  Redis 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
Stopping  Redis server...

又卡在停止redis这里了

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

ps aux|grep redis
root     11593  0.1  0.0  33336  2124 ?        Ssl  12: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卸载之后就放开了然后就能访问了

也不太懂到底啥问题 就是觉得怎么装上了不好使 卸载了反而好使了 太神奇了吧
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 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规则是否正常
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-4-29 17:23 , Processed in 0.026598 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表