Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Shell+redis Could not connect to Redis at ip:port

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Os:rhel6.8 64 2.6.32

Db:redis3.2.8 cluster mode, cluster gem version 3.3.3

Is to use scripts or pipe characters to process the data returned by the redis database is to encounter this error Could not connect to Redis at ip:port: Cannot assign requested address

The operation of the script is to return the ttl time of these key according to the key name in the text, there are 3 texts, each text is about 75000 key. After executing for a period of time, the script found that the two scripts accessing master2 and master3 each had about 300 errors. I looked up on the Internet, saying that the available ports of the client, that is, the machine that executed the script, were used up.

Because the script is that each key needs to establish a connection to obtain the ttl value, and then disconnect after return, the port of the client machine occupied by this connection will not be released immediately and become available, but will take a period of time, which will eventually lead to the depletion of the available port.

Execute the command to modify the following two kernel parameters

Sysctl-w net.ipv4.tcp_timestamps=1 # enables support for TCP timestamps. If this is set to 0, one of the following settings will not work

Sysctl-w net.ipv4.tcp_tw_recycle=1 # means to enable the fast recovery of TIME-WAIT sockets in TCP connection

After execution, execute the initial export command so that the error is no longer reported.

The strange thing is why the node connecting to master1 does not report an error.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report