安装后Hadoop示例无法正常工作

时间:2016-05-23 15:10:14

标签: java hadoop protocol-buffers

您好我最近以分布式模式安装了hadoop 2.7.2,其中namenode为hadoop,datanode为hadoop1hadoop2。当我在bash中yarn jar /usr/local/hadoop/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar pi 2 1000时,它会给出错误消息:

Number of Maps  = 2
Samples per Map = 1000
java.io.IOException: Failed on local exception: com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.; Host Details : local host is: "benji/192.168.1.4"; destination host is: "hadoop":9000; 
    at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:773)
    at org.apache.hadoop.ipc.Client.call(Client.java:1479)
    at org.apache.hadoop.ipc.Client.call(Client.java:1412)
    at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:229)
    at com.sun.proxy.$Proxy9.getFileInfo(Unknown Source)
    at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:771)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:191)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
    at com.sun.proxy.$Proxy10.getFileInfo(Unknown Source)
    at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:2108)
    at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1305)
    at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1301)
    at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
    at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1301)
    at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1424)
    at org.apache.hadoop.examples.QuasiMonteCarlo.estimatePi(QuasiMonteCarlo.java:278)
    at org.apache.hadoop.examples.QuasiMonteCarlo.run(QuasiMonteCarlo.java:354)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.hadoop.examples.QuasiMonteCarlo.main(QuasiMonteCarlo.java:363)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:71)
    at org.apache.hadoop.util.ProgramDriver.run(ProgramDriver.java:144)
    at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.
    at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:99)
    at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:498)
    at com.google.protobuf.GeneratedMessage.parseUnknownField(GeneratedMessage.java:193)
    at org.apache.hadoop.ipc.protobuf.RpcHeaderProtos$RpcResponseHeaderProto.<init>(RpcHeaderProtos.java:2207)
    at org.apache.hadoop.ipc.protobuf.RpcHeaderProtos$RpcResponseHeaderProto.<init>(RpcHeaderProtos.java:2165)
    at org.apache.hadoop.ipc.protobuf.RpcHeaderProtos$RpcResponseHeaderProto$1.parsePartialFrom(RpcHeaderProtos.java:2295)
    at org.apache.hadoop.ipc.protobuf.RpcHeaderProtos$RpcResponseHeaderProto$1.parsePartialFrom(RpcHeaderProtos.java:2290)
    at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:200)
    at com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(AbstractParser.java:241)
    at com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:253)
    at com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:259)
    at com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:49)
    at org.apache.hadoop.ipc.protobuf.RpcHeaderProtos$RpcResponseHeaderProto.parseDelimitedFrom(RpcHeaderProtos.java:3167)
    at org.apache.hadoop.ipc.Client$Connection.receiveRpcResponse(Client.java:1085)
    at org.apache.hadoop.ipc.Client$Connection.run(Client.java:979)

如果我hadoop jar /usr/local/hadoop/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar pi 2 1000,则会显示错误消息:

Number of Maps  = 2
Samples per Map = 1000
java.io.IOException: Failed on local exception: com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.; Host Details : local host is: "hadoop/192.168.1.4"; destination host is: "hadoop":9000;
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:773)
... blabla ...

请注意,两个错误消息之间的奇怪神秘区别在于本地主机名(一个是benji/192.168.1.4,另一个是hadoop/192.168.1.4)。我在start-dfs.sh之前start-yarn.shyarn jar ...,看起来都很好。

如果有人能帮助解决问题,我将非常感激。以下是一些配置文件的内容:

  • /etc/hosts文件(benji是主计算机上的非hadoop帐户):

    192.168.1.4     hadoop benji
    
    192.168.1.5     hadoop1
    
    192.168.1.9     hadoop2
    
  • /etc/hostname档案:

    hadoop
    
  • ~/.ssh/config档案:

    # hadoop1
    Host hadoop1
    HostName 192.168.1.5
    User hadoop1
    IdentityFile ~/.ssh/hadoopid
    
    # hadoop2
    Host hadoop2
    HostName 192.168.1.9
    User hadoop2
    IdentityFile ~/.ssh/hadoopid
    
    # hadoop localhost
    Host localhost
    HostName localhost
    User hadoop
    IdentityFile ~/.ssh/hadoopid
    
    # hadoop
    Host hadoop
    HostName hadoop
    User hadoop
    IdentityFile ~/.ssh/hadoopid
    
  • core-site.xml档案:

    <configuration>
    
    <property>
    
      <name>hadoop.tmp.dir</name>
    
      <value>file:///usr/local/hadoop/hadoopdata/tmp</value>
    
      <description>A base for other temporary directories.</description>
    
    </property>
    
    <property>
    
    <name>fs.defaultFS</name>
    
    <value>hdfs://hadoop:9000</value>
    
    </property>
    
    <property>
    
      <name>io.file.buffer.size</name>
    
      <value>131072</value>
    
    </property>
    
    </configuration>
    
  • hdfs-site.xml档案:

    <configuration>
    
    <property>
    
    <name>dfs.namenode.name.dir</name>
    
    <value>file:///usr/local/hadoop/hadoopdata/dfs/namenode</value>
    
    </property>
    
    <property>
    
    <name>dfs.datanode.du.reserved</name>
    
    <value>21474836480</value>
    
    </property>
    
    <property>
    
    <name>dfs.datanode.data.dir</name>
    
    <value>file:///usr/local/hadoop/hadoopdata/dfs/datanode</value>
    
    </property>
    
    <property>
    
    <name>dfs.replication</name>
    
    <value>1</value>
    
    </property>
    
    <property>
    
    <name>dfs.namenode.secondary.http-address</name>
    
    <value>hadoop:9001</value>
    
    </property>
    
    <property>
    
    <name>dfs.webhdfs.enabled</name>
    
    <value>true</value>
    
    </property> </configuration>
    

有人可以帮忙解决这个问题吗?谢谢!

更新1

我想出了部分问题。我做了jps并发现datanode和namenode没有运行。在netstat -an | grep 9000lsof -i :9000之后,我发现另一个进程正在侦听端口9000。我在fs.defaultFS文件中将hdfs://hadoop:9000hdfs://hadoop:9001更改为core-site.xml,将dfs.namenode.secondary.http-addresshadoop:9001更改为{{}后,名称节点才能运行在hadoop:9002中的1}}。此更改后hdfs-site.xml错误消息消失。但是根据protocol-buffer的结果,数据节点仍未运行。

datanode日志文件显示了一些奇怪的事情:

jps

我不明白为什么datanode尝试连接到端口9000上的namenode。

1 个答案:

答案 0 :(得分:0)

您应该在所有从属服务器上安装已配置的Hadoop软件包,仅将namenode中的fs.defaultFS更改为hdfs://hadoop:9001,但数据节点不会产生数据节点尝试连接到hdfs://hadoop:900 as它在core-site.xml中说明了。