Support Questions
Find answers, ask questions, and share your expertise

Ambari- unable to start Hive Metstore and HiveServer2

New Contributor

Unable to start Hive Metastore and Hive Server2

ile "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 303, in _call
    raise ExecutionFailed(err_msg, code, out, err)
resource_management.core.exceptions.ExecutionFailed: Execution of 'export HIVE_CONF_DIR=/usr/hdp/current/hive-metastore/conf/conf.server ; /usr/hdp/current/hive-server2-hive2/bin/schematool -initSchema -dbType mysql -userName hive -passWord [PROTECTED] -verbose' returned 1. Metastore connection URL:	 jdbc:mysql://hwx02.ecs.spoc/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 hive
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
Underlying cause: java.lang.ClassNotFoundException : com.mysql.jdbc.Driver
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
	at org.apache.hive.beeline.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:82)
	at org.apache.hive.beeline.HiveSchemaTool.getConnectionToMetastore(HiveSchemaTool.java:133)
	at org.apache.hive.beeline.HiveSchemaTool.testConnectionToMetastore(HiveSchemaTool.java:187)
	at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:291)
	at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:277)
	at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:526)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:233)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at org.apache.hive.beeline.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:73)
	... 11 more
*** schemaTool failed ***
3 REPLIES 3

@Denise O Regan,

Can you try running these commands on the ambari server node and mysql node where hive metastore is pointing and see if it works

# yum install mysql-connector-java
# ls /usr/share/java/mysql-connector-java.jar

Run this command only on ambari server node

# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar

.

If this works, please take a moment to login and "Accept" the answer 🙂

This looks to related to a mismatch of the mysql-connector-java.jar in the /hive-server2 path, this can be checked with a md5sum of the following files.


[root@centos-01 ~]# md5sum /usr/hdp/current/hive-server2/lib/mysql-connector-java.jar

58b13db709389ba2aea16b341c2eb1ff /usr/hdp/current/hive-server2/lib/mysql-connector-java.jar


[root@centos-01 ~]# md5sum /usr/share/java/mysql-connector-java.jar

1481ba2874b337223d4f11834038aae0 /usr/share/java/mysql-connector-java.jar


Resolve by copying the /usr/share/java/mysql-connector-java.jar to the /usr/hdp/current/hive-server2/lib/ directory and restarting hive services.

New Contributor

Thank you! This worked for me.

 

Apparently a wrong version of the connector was distributed during my setup (probably my fault),

so on each host running mysql services i had to install the connector:

yum install mysql-connector-java

and then overwrite the faulty jar with the right one.

cp /usr/share/java/mysql-connector-java.jar /usr/hdp/current/hive-server2/lib/

 

Now things are up and running!