title: hadoop cluster datanodes cannot be connected:all nodes has the same hostname is ok or not?
body: <p>I am now establishing a hadoop cluster(4 machines including 1 master to run namenode and jobTracker,  3 slaves to run dataNode and TaskTraker ).But it is a pitty that all the datanode cannot be connected.I run <code>sudo netstat -ntlp</code> on master machine,result is:</p>
  
  <pre><code>tcp        0      0 0.0.0.0:52193           0.0.0.0:*               LISTEN      -               
  tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -               
  tcp        0      0 0.0.0.0:39267           0.0.0.0:*               LISTEN      7284/rpc.mountd 
  tcp        0      0 0.0.0.0:33219           0.0.0.0:*               LISTEN      7284/rpc.mountd 
  tcp        0      0 0.0.0.0:41000           0.0.0.0:*               LISTEN      1539/mongos     
  tcp6       0      0 :::50030                :::*                    LISTEN      604/java        
  tcp6       0      0 :::57134                :::*                    LISTEN      32646/java      
  tcp6       0      0 :::111                  :::*                    LISTEN      13786/rpcbind   
  tcp6       0      0 :::57428                :::*                    LISTEN      -               
  tcp6       0      0 :::57173                :::*                    LISTEN      7284/rpc.mountd 
  tcp6       0      0 :::50070                :::*                    LISTEN      32646/java      
  tcp6       0      0 :::5910                 :::*                    LISTEN      2452/Xvnc       
  tcp6       0      0 :::22                   :::*                    LISTEN      32473/sshd      
  tcp6       0      0 :::50744                :::*                    LISTEN      7284/rpc.mountd 
  tcp6       0      0 :::55036                :::*                    LISTEN      14031/rpc.statd 
  tcp6       0      0 :::42205                :::*                    LISTEN      7284/rpc.mountd 
  tcp6       0      0 :::44289                :::*                    LISTEN      504/java        
  tcp6       0      0 :::2049                 :::*                    LISTEN      -               
  tcp6       0      0 :::38950                :::*                    LISTEN      604/java        
  tcp6       0      0 192.168.10.10:9000      :::*                    LISTEN      32646/java      
  tcp6       0      0 192.168.10.10:9001      :::*                    LISTEN      604/java        
  tcp6       0      0 :::50090                :::*                    LISTEN      504/java
  </code></pre>
  
  <p>And the exception message from my 3 datanodes machines are the same(of course they have different ips):
  The error log for datanode 192.168.10.12:</p>
  
  <pre><code>2014-01-13 12:41:02,332 INFO org.apache.hadoop.metrics2.impl.MetricsSourceAdapter: MBean for source ugi registered.
  2014-01-13 12:41:02,334 WARN org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Source name ugi already exists!
  2014-01-13 12:41:03,427 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: mongodb/192.168.10.12:9000. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)
  2014-01-13 12:41:04,427 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: mongodb/192.168.10.12:9000. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)
  2014-01-13 12:41:05,428 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: mongodb/192.168.10.12:9000. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)
  2014-01-13 12:41:06,428 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: mongodb/192.168.10.12:9000. Already tried 3 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)
  </code></pre>
  
  <p>So ,what make me confused is that why is every datanode is trying to connect to itself?For example , the error log of datanode 192.168.10.12 shows that it is trying to connect 192.168.10.12 on port 9000,and there is no such a listening port on 12.</p>
  
  <p>All my cluster nodes has the same hostname but different ips(master:192.168.10.10 slaves:192.168.10.11,192.168.10.12,192.168.10.13),All my configuration files ,including <code>core-site.xml</code>,<code>hdfs-site.xml</code> and <code>mapred-site.xml</code> use ip address directly.I use <code>sudo ufw status</code> ,it shows the firewall for all machines are <code>**inactive**</code>!</p>
  
  <p>the configuration file for this 4 machines are the same(of course ip is different)：</p>
  
  <p>core-site.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  &lt;configuration&gt;
      &lt;property&gt;
          &lt;name&gt;fs.default.name&lt;/name&gt;
          &lt;value&gt;hdfs://192.168.10.12:9000&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hadoop.tmp.dir&lt;/name&gt;
          &lt;value&gt;/var/hadoop/tmp&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>hdfs-site.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  &lt;!-- Put site-specific property overrides in this file. --&gt;
  &lt;configuration&gt;
       &lt;property&gt;
              &lt;name&gt;dfs.replication&lt;/name&gt;
                  &lt;value&gt;3&lt;/value&gt;
           &lt;/property&gt;
           &lt;property&gt;
          &lt;name&gt;dfs.name.dir&lt;/name&gt;
          &lt;value&gt;/var/hadoop/name&lt;/value&gt;
      &lt;/property&gt;
          &lt;property&gt;
          &lt;name&gt;dfs.data.dir&lt;/name&gt;
          &lt;value&gt;/var/hadoop/data&lt;/value&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>mapred-site.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  
  &lt;!-- Put site-specific property overrides in this file. --&gt;
  
  &lt;configuration&gt;
       &lt;property&gt;
                    &lt;name&gt;mapred.job.tracker&lt;/name&gt;
                    &lt;value&gt;http://192.168.10.12:9001&lt;/value&gt;
       &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>/etc/hosts in my master::</p>
  
  <pre><code>127.0.0.1       localhost
  192.168.10.12   mongodb
  192.168.10.12   localhost
  # The following lines are desirable for IPv6 capable hosts
  ::1     ip6-localhost ip6-loopback
  fe00::0 ip6-localnet
  ff00::0 ip6-mcastprefix
  ff02::1 ip6-allnodes
  ff02::2 ip6-allrouters
  </code></pre>
  
  <p>in line 2 for file /etc/hosts,mongodb is the hostname of the cluster,and the hostname of other three slaves is also mongodb(Because these machines are used to be used as mongodb cluster).</p>
  
  <p>I strongly suspect that it is  the tcp6 who causes the problems. So , how to start hadoop using tcp network instead of tcp6?</p>
  
  <p>So ,my question is:</p>
  
  <p>1.Is hadoop started in tcp6 instead of tcp  ok?</p>
  
  <p>2.All the cluster machine has the same hostname but different LAN ips is ok for hadoop?</p>
  
  <p>So ,any suggestions?</p>