0

After running hive command it failed to create database

Following the official "Getting Started" guide on Apache website

NestedThrowables:
java.sql.SQLException: Unable to open a test connection to the given 
database. JDBC url = jdbc:derby:;databaseName=metastore_db;create=true,  
username = APP. Terminating connection pool (set lazyInit to true if you   
expect to start your database after your app). Original Exception: ------
java.sql.SQLException: Failed to create database 'metastore_db', see the  next exception for details.

Caused by: java.sql.SQLException: Directory /opt/hive/bin/metastore_db cannot be created.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
... 80 more
Caused by: ERROR XBM0H: Directory /opt/hive/bin/metastore_db cannot be created.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.services.monitor.StorageFactoryService$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.services.monitor.StorageFactoryService.createServiceRoot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.createPersistentService(Unknown Source)
at org.apache.derby.iapi.services.monitor.Monitor.createPersistentService(Unknown Source)
... 80 more
Sushil
  • 73
  • 3
  • 14

3 Answers3

1

I just realized in hive: hive-site.xml and in the installation steps to create /user/hive/warehouse:

"user" can be so easily confused with "usr" without any alert at all. so remember:

under hadoop fs, this is /user/hive/warehouse, which points to metadata_db folder, to create (NOT /usr/hive/warehouse)

r poon
  • 633
  • 7
  • 7
0

check the particular user have permission to create /opt/hive/bin/metastore_db

if not then add permission

sudo chmod -R 777 /opt/hive/bin/metastore_db

hope this helps

Nirmal Ram
  • 1,180
  • 2
  • 9
  • 18
0

use: chown -R hduser:hduser * xxxxxxxxx/hive/ (*or whatever username /usergroup you are using) to grant owner (hence full permission.....incl write/create)

(I dont know whether there is a default hive user/group named hive:hive, i created this but granting the ownership right to this hive user created wont work..)

basically the installation instruction assumes you (the hadoop and hence hive who inherit your right) have sufficient permissions.

(note: this is kind of equivalent to run command prompt in Admin Mode in windows, even though you are already admin). Linux tends to be flexible in many things so cause some chaos.

r poon
  • 633
  • 7
  • 7