title: Setting fs.default.name in core-site.xml Sets HDFS to Safemode
body: <p>I installed the Cloudera CDH4 distribution on a single machine in pseudo-distributed mode and successfully tested that it was working correctly (e.g. can run MapReduce programs, insert data on the Hive server, etc.) However, if I chance the <code>core-site.xml</code> file to have <code>fs.default.name</code> set to machine name rather than <code>localhost</code> and restart the NameNode service, the HDFS enters safe-mode.</p>
  
  <p>Before the change of <code>fs.default.name</code>, I ran the following to check the state of the HDFS:</p>
  
  <pre><code>$ hadoop dfsadmin -report
  ...
  Configured Capacity: 18503614464 (17.23 GB)
  Present Capacity: 13794557952 (12.85 GB)
  DFS Remaining: 13790785536 (12.84 GB)
  DFS Used: 3772416 (3.60 MB)
  DFS Used%: 0.03%
  Under replicated blocks: 2
  Blocks with corrupt replicas: 0
  Missing blocks: 0
  </code></pre>
  
  <p>Then I made the modification to <code>core-site.xml</code> (with the machine name being <code>hadoop</code>):</p>
  
  <pre><code>&lt;property&gt;
    &lt;name&gt;fs.default.name&lt;/name&gt;
    &lt;value&gt;hdfs://hadoop:8020&lt;/value&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>I restarted the service and reran the report.</p>
  
  <pre><code>$ sudo service hadoop-hdfs-namenode restart
  $ hadoop dfsadmin -report
  ...
  Safe mode is ON
  Configured Capacity: 0 (0 B)
  Present Capacity: 0 (0 B)
  DFS Remaining: 0 (0 B)
  DFS Used: 0 (0 B)
  DFS Used%: NaN%
  Under replicated blocks: 0
  Blocks with corrupt replicas: 0
  Missing blocks: 0
  </code></pre>
  
  <p>An interesting note is that I can still perform some HDFS commands. For example, I can run</p>
  
  <pre><code>$ hadoop fs -ls /tmp
  </code></pre>
  
  <p>However, if I try to read a file using <code>hadoop fs -cat</code> or try to place a file in the HDFS, I am told the NameNode is in safemode.</p>
  
  <pre><code>$ hadoop fs -put somefile .
  put: Cannot create file/user/hadinstall/somefile._COPYING_. Name node is in safe mode.
  </code></pre>
  
  <p>The reason I need the <code>fs.default.name</code> to be set to the machine name is because I need to communicate with this machine on port 8020 (the default NameNode port). If <code>fs.default.name</code> is left to <code>localhost</code>, then the NameNode service will not listen to external connection requests.</p>
  
  <p>I am at a loss as to why this is happening and would appreciate any help.</p>