[英]Redis Error 8 connecting localhost:6379. nodename nor servname provided, or not known
My environment is Mac OS 10.9.2, python3.3, redis-2.6.9 (64-bit).我的环境是 Mac OS 10.9.2、python3.3、redis-2.6.9(64 位)。
I have many threads (nealy 2000) that use the same redis instance to write data, but some threads throw the following exceptions:我有很多线程(大约 2000 个)使用相同的 redis 实例来写入数据,但有些线程会抛出以下异常:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.3/site-packages/redis/connection.py", line 250, in connect
sock = self._connect()
File "/usr/local/lib/python3.3/site-packages/redis/connection.py", line 268, in _connect
self.socket_timeout)
File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/socket.py", line 417, in create_connecti
on
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py", line 901, in _bootstrap_i
nner
self.run()
File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py", line 858, in run
self._target(*self._args, **self._kwargs)
File "proxypool.py", line 289, in _efficiency_proxy
self.rdb.zadd(db_proxy, time_delay, proxy)
File "/usr/local/lib/python3.3/site-packages/redis/client.py", line 1345, in zadd
return self.execute_command('ZADD', name, *pieces)
File "/usr/local/lib/python3.3/site-packages/redis/client.py", line 464, in execute_command
connection.send_command(*args)
File "/usr/local/lib/python3.3/site-packages/redis/connection.py", line 334, in send_command
self.send_packed_command(self.pack_command(*args))
File "/usr/local/lib/python3.3/site-packages/redis/connection.py", line 316, in send_packed_command
self.connect()
File "/usr/local/lib/python3.3/site-packages/redis/connection.py", line 253, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 8 connecting localhost:6379. nodename nor servname provided, or not known.
Is there some way to solve this problem?有没有办法解决这个问题?
I tried to connect to redis server when this exception happens and use ulimit -n
to set a larger number, but the two methods don't work.当这个异常发生时,我尝试连接到redis服务器并使用
ulimit -n
设置一个更大的数字,但是这两种方法都不起作用。
I know why this happened.我知道为什么会这样。 It's caused by the max number of connections to redis-server and it's related to the max number of file handlers that the OS sets.
它是由 redis-server 的最大连接数引起的,它与操作系统设置的最大文件处理程序数有关。
If I set:如果我设置:
$ ulimit -n 1024
it works.有用。
I also faced this issue.我也遇到过这个问题。
When you are using the wrong Redis HOST then you also meet that error.当您使用错误的 Redis HOST 时,您也会遇到该错误。
Most likely the reds server is not running.很可能 reds 服务器没有运行。 Run it using "redis-server" command.
使用“redis-server”命令运行它。
brew services start redis (on mac)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.