执行字数统计程序时出现Hadoop错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了执行字数统计程序时出现Hadoop错误相关的知识,希望对你有一定的参考价值。

我是Hadoop编程的初学者,我试图在hadoop包中运行word count程序。

我运行命令并面对下面的错误。我试图在网上搜索相同的问题,但我无法解决。我认为我的问题与配置文件中的权限有关。

./bin/hadoop jar hadoop-examples-1.0.3.jar wordcount README.txt ~/wordcount-output

以下是我的错误。

16/05/04 00:05:26 INFO util.NativeCodeLoader: Loaded the native-hadoop library
16/05/04 00:05:26 INFO mapred.JobClient: Cleaning up the staging area file:/tmp/hadoop-sclee1/mapred/staging/sclee1466120821/.staging/job_local_0001
16/05/04 00:05:26 ERROR security.UserGroupInformation: PriviledgedActionException as:sclee1 cause:java.net.UnknownHostException: NGS1: NGS1: Name or service not known
java.net.UnknownHostException: NGS1: NGS1: Name or service not known
        at java.net.InetAddress.getLocalHost(InetAddress.java:1496)
        at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:874)
        at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:850)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
        at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:850)
        at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
        at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
        at org.apache.hadoop.examples.WordCount.main(WordCount.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)
        at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)
        at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:64)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.net.UnknownHostException: NGS1: Name or service not known
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:922)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1316)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1492)
        ... 21 more

为了更好地理解,sclee1是我的帐户,NGS1是我的linux服务器,这是centos版本。

我努力解决问题,但失败了。

答案

检查并添加主机名与/etc/hosts文件中所有节点上的主服务器和从服务器的IP地址之间的关联。确保群集中的所有节点都能够相互ping通。

示例配置:/etc/hosts文件如下:

127.0.0.1       localhost       NGS1

以上是关于执行字数统计程序时出现Hadoop错误的主要内容,如果未能解决你的问题,请参考以下文章

Apache Zeppelin 与 Ignite 集成时出现“无法启动 Ignite 节点”错误

在 Hadoop 2.7.3 上执行简单 SQOOP 导入命令时出现 Sqoop 错误

走目录时的字数PDF文件

在片段java类中使用“this”和getLastSignedInAccount时出现错误[重复]

HADOOP HTTPFS:通过 Http 访问应用程序时出现错误“用户:ubuntu 不允许模拟 ubuntu”

执行带有axios的GET请求时出现401错误