使用eclipse连接hadoop失败情况

来源:互联网 发布:linux登录oracle 编辑:程序博客网 时间:2024/06/05 20:50
Mar 16, 2014 4:13:32 PM org.apache.hadoop.ipc.Client$Connection handleConnectionFailure
INFO: Retrying connect to server: vincent/192.168.56.101:9000. Already tried 0 time(s); maxRetries=45
Mar 16, 2014 4:13:53 PM org.apache.hadoop.ipc.Client$Connection handleConnectionFailure
INFO: Retrying connect to server: vincent/192.168.56.101:9000. Already tried 1 time(s); maxRetries=45
Mar 16, 2014 4:14:14 PM org.apache.hadoop.ipc.Client$Connection handleConnectionFailure
INFO: Retrying connect to server: vincent/192.168.56.101:9000. Already tried 2 time(s); maxRetries=45
Mar 16, 2014 4:14:35 PM org.apache.hadoop.ipc.Client$Connection handleConnectionFailure
INFO: Retrying connect to server: vincent/192.168.56.101:9000. Already tried 3 time(s); maxRetries=45
Mar 16, 2014 4:14:56 PM org.apache.hadoop.ipc.Client$Connection handleConnectionFailure
INFO: Retrying connect to server: vincent/192.168.56.101:9000. Already tried 4 time(s); maxRetries=45

Mar 16, 2014 4:15:17 PM org.apache.hadoop.ipc.Client$Connection handleConnectionFailure

..................

INFO: Retrying connect to server: vincent/192.168.56.101:9000. Already tried 43 time(s); maxRetries=45
Mar 16, 2014 4:28:56 PM org.apache.hadoop.ipc.Client$Connection handleConnectionFailure
INFO: Retrying connect to server: vincent/192.168.56.101:9000. Already tried 44 time(s); maxRetries=45
Exception in thread "main" java.net.SocketTimeoutException: Call to vincent/192.168.56.101:9000 failed on socket timeout exception: java.net.SocketTimeoutException: 20000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=vincent/192.168.56.101:9000]
at org.apache.hadoop.ipc.Client.wrapException(Client.java:1146)
at org.apache.hadoop.ipc.Client.call(Client.java:1118)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:229)
at $Proxy1.getProtocolVersion(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:85)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:62)
at $Proxy1.getProtocolVersion(Unknown Source)
at org.apache.hadoop.ipc.RPC.checkVersion(RPC.java:422)
at org.apache.hadoop.hdfs.DFSClient.createNamenode(DFSClient.java:183)
at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:281)
at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:245)
at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:100)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1446)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:67)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1464)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:263)
at org.apache.hadoop.fs.Path.getFileSystem(Path.java:187)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.addInputPath(FileInputFormat.java:372)
at org.conan.myhadoop.mr.WordCount.main(WordCount.java:68)
Caused by: java.net.SocketTimeoutException: 20000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=vincent/192.168.56.101:9000]
at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:213)
at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:511)
at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:481)
at org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:457)
at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:583)
at org.apache.hadoop.ipc.Client$Connection.access$2200(Client.java:205)
at org.apache.hadoop.ipc.Client.getConnection(Client.java:1249)
at org.apache.hadoop.ipc.Client.call(Client.java:1093)
... 21 more


开发环境: 

hadoop 1.2.1 运行于3太虚拟机

eclipse Version: Juno Service Release 2

JDK 1.7

ubuntu 12.04LTS

windows远程开发hadoop程序


因为是第一次在windows上通过eclipse连接hadoop,然后直接就碰到了上面的问题,折腾了8个多小时,反复尝试了很多办法。

比如:


最开始一度以为是因为windows本身并不是hadoop node中的一员,所以无法访问。然后尝试把windows的公钥发布到ubuntu上面,让windows像其他datanode一样可以免密码登陆但是无济于事,然后又考虑是不是因为windows本身的登陆用户不是hadoop,造成的无法登陆呢,这个思考点是因为hadoop节点本身需要所有的node都是用hadoop(不一定是hadoop,但一定要求相同)作为用户名,才可以互相成功组成集群,否则master node会以mastr node的用户名登陆其他节点,造成无法登陆,也就使得hadoop无法成功启动。但其实对windows这个外部节点来说,并不是要求这样。网上也有很多人说需要修改windows本身的登陆用户,但是估计是因为他们都在windows上安装了hadoop,并且作为了hadoop的一个节点,才需要这样做的吧。


0 网上大部分都说是地址没有配置正确,说把localhost或者127.0.0.1换成机器的IP地址,但是我自己的情况并非是本地调试。而且本来core-site.xml中就是配置的host名字。后来我还尝试把host改成ip地址,其实两者是等价的,没有必要更改。


1 如下图在hdfs-site.xml中增加dfs.permissions节点 。这是由于怀疑是权限造成的不能访问,才想尝试更改这里。但是不行。


2 修复了namenode每次重启就无法启动的bug,指望能对这个问题带来改变,结果也不行

如下,在core-site.xml中增加hadoop.tmp.dir节点,然后 bin/hadoop namenode -format

要注意,每次format namenode,那么datanode里面存的所有数据就都清空了。这个问题问题一开始没意识到,后来程序运行起来才发现。

另外一个问题就是要把配置文件同步到所有节点上,否则,datanode的启动会出现问题,我在另外一个博客中阐述了这个问题。



3 开始使用eclipse的hadoop插件来解决这个问题,但是插件同样也碰到了这个相同的无法连接的问题。会一直处于listing状态,最后报错。

以为是插件配置上造成的连接问题,所以查看了很多配置插件的文章,但是没有什么结果

因为是hadoop 1.2.1的插件,这个版本中没有hadoop.job.ugi的配置项目。



4 还有很多人帖子里面提到要关闭掉hadoop node的防火墙,经过查看,我的所有node的防火墙已经处于关闭状态

由于LInux原始的防火墙工具iptables过于繁琐,所以ubuntu默认提供了一个基于iptable之上的防火墙工具ufw。

ubuntu 9.10默认的便是UFW防火墙,它已经支持界面操作了。在命令行运行ufw命令就可以看到提示的一系列可进行的操作。

最简单的一个操作:sudo ufw status可检查防火墙的状态,我的返回的是:不活动

开启/关闭防火墙 (默认设置是’disable’)

sudo  ufw enable|disable


5 因为hadoop运行之后,可以在master node上通过50030端口访问到hdfs管理页面。所以我开始考虑能否在windows上访问到这个界面。结果是失败。

但是这个失败的访问导致我开始怀疑真正我连接master node失败的原因是网络连接的问题。



然后看到有人提议说,先检查下master node上的9000端口是否开启了,可以通过telnet的方式测试。

telnet 192.158.56.101 9000

然后首先发现win7系统中telnet是禁用状态的。需要手动开启


如上图中,Control Panel-> Turn Windows features on or off -> 勾选Telnet Client。就可以打开telnet功能了。

然后在CMD中开始测试,但是很明显无法连接到对方的9000端口。这个时候我猜想应该是windows本身的防火墙功能屏蔽了telnet。电脑上安装的是赛门铁克,通过services.msc进入服务项,关闭相应的服务,然后再次尝试




上图就是telnet成功连接之后的图片,不过没有什么返回信息。

并且同时也可以通过浏览器访问master node 上的50030和50070端口,查看hadoop集群信息页面了。到此大功告成。无论是eclipse中的项目还是插件都可以访问到hadoop了。



总结:在这整个过程中学习了很多东西,但是最终发现竟然是本身windows上防火墙的原因,让我哭笑不得。如果hadoop运行过程中碰到什么问题,查看log是个很好的方法。


问题:最终的解决方案,带来了一个问题,就是为什么开着防火墙就无法访问呢,也许是防火墙没有开放这些端口吧。

4 0
原创粉丝点击