title: Hadoop Metastore Will Not Initialize
body: <p>preamble:  i'm new to hadoop / hive.  have installed standalone hadoop and now am trying to get hive to work.  i keep getting an error about initializing the metastore and cannot seem to figure out how to resolve.   (hadoop 2.7.2 and hive 2.0)</p>
  
  <p>HADOOP_HOME AND HIVE_HOME ARE SET </p>
  
  <pre><code>ubuntu15-laptop: ~ $&gt;echo $HADOOP_HOME
  /usr/hadoop/hadoop-2.7.2
  
  ubuntu15-laptop: ~ $&gt;echo $HIVE_HOME
  /usr/hive
  </code></pre>
  
  <p>hdfs is working</p>
  
  <pre><code>ubuntu15-laptop: ~ $&gt;hadoop fs -ls /
  Found 2 items
  drwxrwxr-x   - testuser supergroup          0 2016-04-13 21:37 /tmp
  drwxrwxr-x   - testuser supergroup          0 2016-04-13 21:38 /user
  
  ubuntu15-laptop: ~ $&gt;hadoop fs -ls /user
  Found 1 items
  drwxrwxr-x   - testuser supergroup          0 2016-04-13 21:38 /user/hive
  
  ubuntu15-laptop: ~ $&gt;hadoop fs -ls /user/hive
  Found 1 items
  drwxrwxr-x   - testuser supergroup          0 2016-04-13 21:38 /user/hive/warehouse
  
  ubuntu15-laptop: ~ $&gt;groups
  testuser adm cdrom sudo dip plugdev lpadmin sambashare
  </code></pre>
  
  <p>hive is not working.  says i need to initialize my metastore</p>
  
  <pre><code>ubuntu15-laptop: ~ $&gt;hive
  
  Logging initialized using configuration in
  jar:file:/usr/hive/lib/hive-common-2.0.0.jar!/hive-log4j2.properties
  Exception in thread "main" java.lang.RuntimeException: Hive metastore database
  is not initialized. Please use schematool (e.g. ./schematool -initSchema
  -dbType ...) to create the schema. If needed, don't forget to include the 
  option to auto-create the underlying database in your JDBC connection string
  (e.g. ?createDatabaseIfNotExist=true for mysql)
  </code></pre>
  
  <p>so i try to initialize it useing postgres - but schematool tries to use derby</p>
  
  <pre><code>ubuntu15-laptop: ~ $&gt;schematool -initSchema -dbType postgres
  Metastore connection URL:  jdbc:derby:;databaseName=metastore_db;create=true
  Metastore Connection Driver :  org.apache.derby.jdbc.EmbeddedDriver
  Metastore connection User:   APP
  Starting metastore schema initialization to 2.0.0
  Initialization script hive-schema-2.0.0.postgres.sql
  Error: Syntax error: Encountered "statement_timeout" at line 1, column 5.
  (state=42X01,code=30000)
  org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization
  FAILED! Metastore state would be inconsistent !!
  *** schemaTool failed ***
  </code></pre>
  
  <p>so i change hive-site.xml to use postgres drivers etc.  but because i don't
  have the drivers installed, it fails</p>
  
  <pre><code>ubuntu15-laptop: ~ $&gt;cp /usr/hive/conf/hive-site.xml.templ /usr/hive/conf/hive-site.xml
  ubuntu15-laptop: ~ $&gt;schematool -initSchema -dbType postgres
  Metastore connection URL:  jdbc:postgresql://localhost:5432/hivedb
  Metastore Connection Driver :  org.postgresql.Driver
  Metastore connection User:   123456
  org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
  *** schemaTool failed ***
  </code></pre>
  
  <p>so then i try to use derby
  first move the hive-site.xml out of the way again so default is derby</p>
  
  <pre><code>ubuntu15-laptop: ~ $&gt;mv /usr/hive/conf/hive-site.xml /usr/hive/conf/hive-site.xml.templ
  </code></pre>
  
  <p>then i try intializing again with derby but it appears to already be
  initialized per the error "Error:  FUNCTION 'NUCLEUS_ASCII' already exists"</p>
  
  <pre><code>ubuntu15-laptop: ~ $&gt;schematool -initSchema -dbType derby
  Metastore connection URL:  jdbc:derby:;databaseName=metastore_db;create=true
  Metastore Connection Driver :  org.apache.derby.jdbc.EmbeddedDriver
  Metastore connection User:   APP
  Starting metastore schema initialization to 2.0.0
  Initialization script hive-schema-2.0.0.derby.sql
  Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000)
  org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization
  FAILED! Metastore state would be inconsistent !!
  *** schemaTool failed ***
  </code></pre>
  
  <p>I've been at this for two days.  Any help would be very much appreciated.</p>