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/", 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(
	at org.apache.hive.beeline.HiveSchemaTool.getConnectionToMetastore(
	at org.apache.hive.beeline.HiveSchemaTool.testConnectionToMetastore(
	at org.apache.hive.beeline.HiveSchemaTool.doInit(
	at org.apache.hive.beeline.HiveSchemaTool.doInit(
	at org.apache.hive.beeline.HiveSchemaTool.main(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.apache.hadoop.util.RunJar.main(
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(
	at org.apache.hive.beeline.HiveSchemaHelper.getConnectionToMetastore(
	... 11 more
*** schemaTool failed ***

@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!

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.