Because you need to. Compare Redis data export to database data, and export data in a pipe-break connection:
/opt/$company _name/redis-3.0.5/bin/redis-cli-h $IP-P $PORT-a $PASSWORD keys \* |xargs-n 1/opt/$company _name/redis -3.0.5/bin/redis-cli-h $IP-P $PORT-a $PASSWORD get > Key.txt
During the export process, error:
Could not connect to Redis at Ip:port,cannot assign requested address.
This is because the client is frequently connected to the server, the amount of data is large, because each connection in a very short period of time, resulting in a lot of time_wait, so that the use of the port number is used, so the new connection can not bind the port, that is, "cannot assign Requestedaddress ".
The problem with the client is not the server side. Through netstat, you do see a lot of time_wait state connections.
Execute the command to modify the following 2 kernel parameters
Sysctl-w Net.ipv4.tcp_timestamps=1 #开启对于TCP时间戳的支持, if the entry is set to 0, the following setting does not work
Fast recovery of Sysctl-w net.ipv4.tcp_tw_recycle=1 #表示开启TCP连接中TIME-wait sockets
After execution, and then execute the Export command at the beginning, no longer an error.
This article is from the Linux and networking blogs, so be sure to keep this source http://khaozi.blog.51cto.com/952782/1750786
Redis data export, error could not connect to Redis at Ip:port:Cannot Assign requested address workaround