2
votes

I'm trying to do a hadoop single node installation.

I am following this article for hadoop installation instructions. One of the steps I need to do is to format the hadoop file system using the command

hduser@dbserver:~/hadoop/conf$ /home/hduser/hadoop/bin/hadoop namenode -format

hduser@dbserver:~/hadoop/conf$ /home/hduser/hadoop/bin/hadoop namenode -format
12/02/06 18:24:31 INFO namenode.NameNode: STARTUP_MSG: 
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = dbserver/127.0.1.1
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 0.20.203.0
STARTUP_MSG:   build = http://svn.apache.org/repos/asf/hadoop/common/branches/branch-    0.20-security-203 -r 1099333; compiled by 'oom' on Wed May  4 07:57:50 PDT 2011
 ************************************************************/
 [Fatal Error] core-site.xml:6:1: Content is not allowed in prolog.
 12/02/06 18:24:31 FATAL conf.Configuration: error parsing conf file:  org.xml.sax.SAXParseException: Content is not allowed in prolog.
 12/02/06 18:24:31 ERROR namenode.NameNode: java.lang.RuntimeException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:1237)
at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:1093)
at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:1037)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:438)
at org.apache.hadoop.hdfs.server.namenode.NameNode.setStartupOption(NameNode.java:1124)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1141)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1162)
 Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)
at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:1142)
... 6 more

    12/02/06 18:24:31 INFO namenode.NameNode: SHUTDOWN_MSG: 
    /************************************************************
      SHUTDOWN_MSG: Shutting down NameNode at dbserver/127.0.1.1
    ************************************************************/

i get the above error message when trying to format

Any suggestions to fix this issue are welcome :) .

the core-site.xml file is here for your reference @zensen

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

 <!-- Put site-specific property overrides in this file. -->

  n: conf/core-site.xml -->
  <property>
  <name>hadoop.tmp.dir</name>
  <value>/app/hadoop/tmp</value>
  <description>A base for other temporary directories.</description>
  </property>

    <property>
    <name>fs.default.name</name>
    <value>hdfs://localhost:54310</value>
    <description>The name of the default file system.  A URI whose
    scheme and authority determine the FileSystem implementation.  The
    uri's scheme determines the config property (fs.SCHEME.impl) naming
     the FileSystem implementation class.  The uri's authority is used to
    determine the host, port, etc. for a filesystem.</description>
   </property><configuration>

~

2

2 Answers

5
votes

Well this isn't really a Hadoop problem.

org.xml.sax.SAXParseException: Content is not allowed in prolog.

Means that your XML file is incorrect. And to be more precise it contains some characters before <?xml. Are there any characters in core-site.xml at the very beginning before <?xml? If so then remove them. Remember that those might not show in all editors (depending on the encoding).

1
votes

Error:

[Fatal Error] core-site.xml:1:36: Element type "xml" must be followed by either attribute specifications, ">" or "/>".
16/09/05 13:59:48 FATAL conf.Configuration: error parsing conf core-site.xml
org.xml.sax.SAXParseException; systemId: file:/home/amtex/Documents/installed/hadoop/etc/hadoop/core-site.xml; lineNumber: 1; columnNumber: 36; Element type "xml" must be followed by either attribute specifications, ">" or "/>".
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:150)
    at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2480)
    at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2468)
    at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2539)
    at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2492)
    at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2405)
    at org.apache.hadoop.conf.Configuration.set(Configuration.java:1143)
    at org.apache.hadoop.conf.Configuration.set(Configuration.java:1115)
    at org.apache.hadoop.conf.Configuration.setBoolean(Configuration.java:1451)
    at org.apache.hadoop.util.GenericOptionsParser.processGeneralOptions(GenericOptionsParser.java:321)
    at org.apache.hadoop.util.GenericOptionsParser.parseGeneralOptions(GenericOptionsParser.java:487)
    at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:170)
    at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:153)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1422)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1559)
16/09/05 13:59:48 ERROR namenode.NameNode: Failed to start namenode.
java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: file:/home/amtex/Documents/installed/hadoop/etc/hadoop/core-site.xml; lineNumber: 1; columnNumber: 36; Element type "xml" must be followed by either attribute specifications, ">" or "/>".
    at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2645)
    at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2492)
    at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2405)
    at org.apache.hadoop.conf.Configuration.set(Configuration.java:1143)
    at org.apache.hadoop.conf.Configuration.set(Configuration.java:1115)
    at org.apache.hadoop.conf.Configuration.setBoolean(Configuration.java:1451)
    at org.apache.hadoop.util.GenericOptionsParser.processGeneralOptions(GenericOptionsParser.java:321)
    at org.apache.hadoop.util.GenericOptionsParser.parseGeneralOptions(GenericOptionsParser.java:487)
    at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:170)
    at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:153)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1422)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1559)
Caused by: org.xml.sax.SAXParseException; systemId: file:/home/amtex/Documents/installed/hadoop/etc/hadoop/core-site.xml; lineNumber: 1; columnNumber: 36; Element type "xml" must be followed by either attribute specifications, ">" or "/>".
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:150)
    at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2480)
    at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2468)
    at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2539)
    ... 11 more
16/09/05 13:59:48 INFO util.ExitUtil: Exiting with status 1
16/09/05 13:59:48 INFO namenode.NameNode: SHUTDOWN_MSG: 

Check the xml syntax in core-site.xml

Solution:

<xml version="1.0" encoding="UTF-8"?>
to 
<?xml version="1.0" encoding="UTF-8"?>