Hadoop: java.net.UnknownHostException: hadoop-slave-2

11,728

The issue lies in the /etc/hosts file of the slaves. The reason there were no errors while putting file and formatting namenode is that the master communicates to all the slaves and it has ip addresses for all of them. But once you run an application on the cluster, the Application master is created on one of the slaves. AM then through slave has to communicate with other slaves. Since slave’s host file does not have their address (judging by the posted hosts file for slaves) it is giving an Unknown host error.

As rule of thumb, make sure all the nodes in the cluster have ip addresses to every other node in the cluster. Fix this and the error should go away.

Share:
11,728
jsingh13
Author by

jsingh13

Updated on June 05, 2022

Comments

  • jsingh13
    jsingh13 almost 2 years

    I have created a hadoop cluster with 1 Master and 2 Slaves. I am running it with minimum specifications in the *-site.xml files.

    core-site.xml

    <configuration>
        <property>
            <name>fs.defaultFS</name>
            <value>hdfs://10.0.0.51:9000</value>
        </property>
    </configuration>
    

    hfds-site.xml

    <configuration>
        <property>
            <name>dfs.datanode.name.dir</name>
            <value>~/DNfiles</value>
        </property>
    </configuration>
    

    mapred-site.xml

    <configuration>
        <property>
            <name>mapreduce.framework.name</name>
            <value>yarn</value>
        </property>
    </configuration>
    

    yarn-site.xml

    <configuration>
    
        <!-- Site specific YARN configuration properties -->
    
        <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>
        <property>
            <name>yarn.resourcemanager.resource-tracker.address</name>
            <value>10.0.0.51:8025</value>
        </property>
        <property>
            <name>yarn.resourcemanager.scheduler.address</name>
            <value>10.0.0.51:8030</value>
        </property>
        <property>
            <name>yarn.resourcemanager.address</name>
            <value>10.0.0.51:8050</value>
        </property>
    </configuration>
    

    The problem is I am able to format namenode, put files into hfs and all but when i run a simple example i get the following error.

    Container launch failed for container_1455133326738_0002_02_000007 : java.lang.IllegalArgumentException: java.net.UnknownHostException: hadoop-slave-2 at org.apache.hadoop.security.SecurityUtil.buildTokenService(SecurityUtil.java:377)
        at org.apache.hadoop.security.SecurityUtil.setTokenService(SecurityUtil.java:356)
        at org.apache.hadoop.yarn.util.ConverterUtils.convertFromYarn(ConverterUtils.java:238)
    at org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy$ContainerManagementProtocolProxyData.newProxy(ContainerManagementProtocolProxy.java:266)
     at org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy$ContainerManagementProtocolProxyData.<init>(ContainerManagementProtocolProxy.java:244)
        at org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.getProxy(ContainerManagementProtocolProxy.java:129)
        at org.apache.hadoop.mapreduce.v2.app.launcher.ContainerLauncherImpl.getCMProxy(ContainerLauncherImpl.java:409)
        at org.apache.hadoop.mapreduce.v2.app.launcher.ContainerLauncherImpl$Container.launch(ContainerLauncherImpl.java:138)
        at org.apache.hadoop.mapreduce.v2.app.launcher.ContainerLauncherImpl$EventProcessor.run(ContainerLauncherImpl.java:375)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: java.net.UnknownHostException: hadoop-slave-2
    

    While the programs goes on to finish by working with other slave i.e. 1 slave is reachable but other is not though they have the same configurations. Since i am able to format and all so i am assuming my /etc/hosts file in master node is fine. Here is its snippet.

    ubuntu@hadoop-master-1:~/hadoop-2.7.1/bin$ cat /etc/hosts
    127.0.0.1 localhost
    10.0.0.51 hadoop-master-1
    10.0.0.36 hadoop-slave
    10.0.0.38 hadoop-slave-2
    10.0.0.39 hadoop-slave-1
    10.0.0.40 hadoop-slave-3
    10.0.0.41 hadoop-slave-4
    

    host file for slave

    ubuntu@hadoop-slave-1:~/hadoop-2.7.1/bin$ cat /etc/hosts
    127.0.0.1 localhost
    10.0.0.39 hadoop-slave-1
    10.0.0.51 hadoop-master-1
    

    Does anyone has any idea what could be the issue? Any help or possible pointers will be highly appreciated.