MinIO|无法建立新连接:[Erno-2]名称或服务未知



目标:下载MinIO存储桶中文件夹中的所有文件。

由于我想动态下载文件夹中的所有文件,我使用:

objs = list(client.list_objects(bucket, recursive=True)).sort()

这样,我可以使用迭代每个文件名进行下载

for o in objs:
obj = client.get_object(bucket, o)

下载指定文件也失败:

obj = client.get_object(bucket, 'industry/gri/esg/ESG_COMP.csv')

代码:

from sdg.datasource.MinioConn import MinioConn
client = MinioConn().client()
bucket = 'synthetic-data-gen'
obj = client.get_object(bucket, 'industry/gri/esg/ESG_COMP.csv')
print('###')
print(obj)
objs = list(client.list_objects(bucket, recursive=True)).sort()
dfs = []
for o in objs:
obj = client.get_object(bucket, o)
dfs.append(pd.read_csv(obj).iloc[:, 0].tolist())  # 1 column csvs

MinioConn:

from minio import Minio
class MinioConn:
def __init__(self,
host='foo.bar.foo.bar.com:9000',
access_key='CENSORED', secret_key='CENSORED',
secure=False):
self.host = host
self.access_key = access_key
self.secret_key = secret_key
self.secure = secure
def client(self):
return Minio(self.host, self.access_key, self.secret_key,
secure=self.secure)

追溯:

Traceback (most recent call last):
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/util/connection.py", line 73, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/home/me/miniconda3/envs/sdg/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/http/client.py", line 1010, in _send_output
self.send(msg)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/http/client.py", line 950, in send
self.connect()
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fc6f4ee17f0>: Failed to establish a new connection: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/me/miniconda3/envs/sdg/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/mnt/c/Users/me/Documents/GitHub/repo/project/foo/__init__.py", line 5, in <module>
from sdg.sdg import generate_data
File "/mnt/c/Users/me/Documents/GitHub/repo/project/foo/sdg.py", line 10, in <module>
from sdg.industry.gri.generator import Generator as GRIGenerator
File "/mnt/c/Users/me/Documents/GitHub/repo/project/foo/industry/gri/generator.py", line 40, in <module>
class Generator:
File "/mnt/c/Users/me/Documents/GitHub/repo/project/foo/industry/gri/generator.py", line 346, in Generator
dfs = get_esgs()
File "/mnt/c/Users/me/Documents/GitHub/repo/project/foo/industry/gri/generator.py", line 61, in get_esgs
obj = client.get_object(bucket, 'industry/gri/esg/ESG_COMP.csv')
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/minio/api.py", line 1151, in get_object
return self._execute(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/minio/api.py", line 394, in _execute
region = self._get_region(bucket_name, None)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/minio/api.py", line 461, in _get_region
response = self._url_open(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/minio/api.py", line 266, in _url_open
response = self._http.urlopen(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connectionpool.py", line 783, in urlopen
return self.urlopen(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connectionpool.py", line 783, in urlopen
return self.urlopen(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connectionpool.py", line 783, in urlopen
return self.urlopen(
[Previous line repeated 2 more times]
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/home/me/miniconda3/envs/sdg/lib/python3.8/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='foo.bar.foo.bar.com', port=9000): Max retries exceeded with url: /synthetic-data-gen?location= (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc6f4ee17f0>: Failed to establish a new connection: [Errno -2] Name or service not known'))

错误消息:

socket.gaierror: [Errno -2] Name or service not known

意味着主机名(foo.bar.foo.bar.com(上的DNS解析失败。如果主机名不正确,您可能需要检查DNS配置或修复主机名。

相关内容

  • 没有找到相关文章

最新更新