忘记密码   免费注册 查看新帖 | 论坛精华区

ChinaUnix.net

  平台 论坛 博客 认证专区 大话IT HPC论坛 徽章 文库 沙龙 自测 下载 频道自动化运维 虚拟化 储存备份 C/C++ PHP MySQL 嵌入式 Linux系统
最近访问板块 发新帖
查看: 1005 | 回复: 1

python访问hdfs的问题。 [复制链接]

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-04-12 06:20:00
发表于 2017-04-27 17:17 |显示全部楼层
大侠们看看,我这里出什么问题了:
hadoop版本: hadoop-3.0.0-alpha2
python版本: 3.5.2
谢谢大家了!

>>> from pyhdfs import HdfsClient
>>> client=HdfsClient(hosts='localhost:50070')
>>> print(client.list_status('/'))
Failed to reach to localhost:50070 (attempt 2/2)
Traceback (most recent call last):
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 356, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/python3.5.2/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/python3.5.2/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/usr/local/python3.5.2/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/usr/local/python3.5.2/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/usr/local/python3.5.2/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x2adee34d30f0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=50070): Max retries exceeded with url: /webhdfs/v1/?op=LISTSTATUS&user.name=hadoop (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x2adee34d30f0>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/pyhdfs.py", line 360, in _request
    params=kwargs, timeout=self.timeout, allow_redirects=False,
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=50070): Max retries exceeded with url: /webhdfs/v1/?op=LISTSTATUS&user.name=hadoop (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x2adee34d30f0>: Failed to establish a new connection: [Errno 111] Connection refused',))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/pyhdfs.py", line 525, in list_status
    _json(self._get(path, 'LISTSTATUS', **kwargs))['FileStatuses']['FileStatus']
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/pyhdfs.py", line 381, in _get
    return self._request('get', *args, **kwargs)
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/pyhdfs.py", line 378, in _request
    raise HdfsNoServerException("Could not use any of the given hosts")
pyhdfs.HdfsNoServerException: Could not use any of the given hosts


论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-04-12 06:20:00
发表于 2017-04-27 17:22 |显示全部楼层
看网上的例子,pyhdfs都有connect方法,但我这里根本就没有。

Python 3.5.2 (default, Apr 26 2017, 14:51:11)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pyhdfs
>>> fs=pyhdfs.connect("127.0.0.1",9000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pyhdfs' has no attribute 'connect'
>>> pyhdfs.__version__
'0.1.2'
您需要登录后才可以回帖 登录 | 注册

本版积分规则

SACC2017购票8.8折优惠进行时

2017中国系统架构师大会(SACC2017)将于10月19-21日在北京新云南皇冠假日酒店震撼来袭。今年,大会以“云智未来”为主题,云集国内外顶级专家,围绕云计算、人工智能、大数据、移动互联网、产业应用等热点领域展开技术探讨与交流。本届大会共设置2大主会场,18个技术专场;邀请来自互联网、金融、制造业、电商等多个领域,100余位技术专家及行业领袖来分享他们的经验;并将吸引4000+人次的系统运维、架构师及IT决策人士参会,为他们提供最具价值的交流平台。
----------------------------------------
优惠时间:2017年8月2日前

活动链接>>
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号 北京市公安局海淀分局网监中心备案编号:11010802020122
广播电视节目制作经营许可证(京) 字第1234号 中国互联网协会会员  联系我们:
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP