Could not connect to Redis at 127.0.0.1:13141: Cannot assign requested address

使用redis-benchmark做基准测试时提示错误:

Could not connect to Redis at 127.0.0.1:13141: Cannot assign requested address

测试命令为:

 ./redis-benchmark -h 127.0.0.1 -p 13141 -a iDvKW33333 -c 9000 -n 500000 -d 50 -q

Could not connect to Redis at 127.0.0.1:13141: Cannot assign requested address_第1张图片

原因:

服务端设置openfile后,还是会出现这个错误提示,查看ulimit -a

Could not connect to Redis at 127.0.0.1:13141: Cannot assign requested address_第2张图片

redis maxclients:

执行压测

 ./redis-benchmark -h 192.168.12.113 -p 13133 -a iD44421 -c 5000 -n 50000 -d 50 

一段时间后客户端报错:

Could not connect to Redis at 192.168.12.113:13141: Cannot assign requested address

connected_clients连接数没有超,如下图

Could not connect to Redis at 127.0.0.1:13141: Cannot assign requested address_第3张图片

客户端TIME-WAIT端口也很多

Could not connect to Redis at 127.0.0.1:13141: Cannot assign requested address_第4张图片

sysctl -w net.ipv4.tcp_timestamps=1  开启对于TCP时间戳的支持,若该项设置为0,则下面一项设置不起作用

sysctl -w net.ipv4.tcp_tw_recycle=1  表示开启TCP连接中TIME-WAIT sockets的快速回收

结论:

压测的服务端和客户端机器都要设置openfile 和 快速回收策略

你可能感兴趣的:(redis,redis并发测试)