title: Hadoop: java.net.UnknownHostException: hadoop-slave-2
body: <p>I have created a hadoop cluster with 1 Master and 2 Slaves. I am running it with minimum specifications in the *-site.xml files.</p>
  
  <p><em>core-site.xml</em></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configuration&gt;
      &lt;property&gt;
          &lt;name&gt;fs.defaultFS&lt;/name&gt;
          &lt;value&gt;hdfs://10.0.0.51:9000&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><em>hfds-site.xml</em></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configuration&gt;
      &lt;property&gt;
          &lt;name&gt;dfs.datanode.name.dir&lt;/name&gt;
          &lt;value&gt;~/DNfiles&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><em>mapred-site.xml</em></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configuration&gt;
      &lt;property&gt;
          &lt;name&gt;mapreduce.framework.name&lt;/name&gt;
          &lt;value&gt;yarn&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><em>yarn-site.xml</em></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configuration&gt;
  
      &lt;!-- Site specific YARN configuration properties --&gt;
  
      &lt;property&gt;
          &lt;name&gt;yarn.nodemanager.aux-services&lt;/name&gt;
          &lt;value&gt;mapreduce_shuffle&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;yarn.resourcemanager.resource-tracker.address&lt;/name&gt;
          &lt;value&gt;10.0.0.51:8025&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;yarn.resourcemanager.scheduler.address&lt;/name&gt;
          &lt;value&gt;10.0.0.51:8030&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;yarn.resourcemanager.address&lt;/name&gt;
          &lt;value&gt;10.0.0.51:8050&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>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.&lt;init&gt;(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
  </code></pre>
  
  <p>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.</p>
  
  <pre class="lang-bash prettyprint-override"><code>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
  </code></pre>
  
  <p>host file for slave</p>
  
  <pre class="lang-bash prettyprint-override"><code>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
  </code></pre>
  
  <p>Does anyone has any idea what could be the issue? Any help or possible pointers will be highly appreciated.</p>