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

Hive-server2 DB connection issue

recently upgraded to ambari 2.4 got though a previous oozie issue and now when im restarting hive i get this error for hiver-server2:

stderr:   /var/lib/ambari-agent/data/errors-4864.txt

Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server.py", line 211, in <module>
    HiveServer().execute()
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 280, in execute
    method(env)
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 720, in restart
    self.start(env, upgrade_type=upgrade_type)
  File "/var/lib/ambari-agent/cache/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server.py", line 88, in start
    hive_service('hiveserver2', action = 'start', upgrade_type=upgrade_type)
  File "/usr/lib/python2.6/site-packages/ambari_commons/os_family_impl.py", line 89, in thunk
    return fn(*args, **kwargs)
  File "/var/lib/ambari-agent/cache/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py", line 106, in hive_service
    validate_connection(params.hive_jdbc_target, params.hive_lib)
  File "/var/lib/ambari-agent/cache/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py", line 162, in validate_connection
    path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', tries=5, try_sleep=10)
  File "/usr/lib/python2.6/site-packages/resource_management/core/base.py", line 155, in __init__
    self.env.run()
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 160, in run
    self.run_action(resource, action)
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 124, in run_action
    provider_action()
  File "/usr/lib/python2.6/site-packages/resource_management/core/providers/system.py", line 273, in action_run
    tries=self.resource.tries, try_sleep=self.resource.try_sleep)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 71, in inner
    result = function(command, **kwargs)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 93, in checked_call
    tries=tries, try_sleep=try_sleep)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 141, in _call_wrapper
    result = _call(command, **kwargs_copy)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 294, in _call
    raise Fail(err_msg)
resource_management.core.exceptions.Fail: Execution of '/usr/jdk64/jdk1.8.0_40/bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar org.apache.ambari.server.DBConnectionVerification 'jdbc:mysql://<server name removed>/hive?createDatabaseIfNotExist=true' hive [PROTECTED] com.mysql.jdbc.Driver' returned 1. ERROR: Unable to connect to the DB. Please check DB connection properties.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

i inherited this cluster so i have no idea what DB it was connecting and i cant for the life of me find anything about it in the documentation i was left.

knox and ranger are not enabled but it seems kerberos is but nothing has changed with that.

1 ACCEPTED SOLUTION

Accepted Solutions

Super Mentor

@steve coyle

As the error seems to be related to missing mysql driver class:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

- Can you please check if you have copied the "mysql-connector.jar" inside the following location?

# cp  -r  /usr/lib/hive/lib/mysql-connector-java.jar   /usr/share/java/

.

Additionally please refer to: https://docs.hortonworks.com/HDPDocuments/Ambari-2.4.0.1/bk_ambari-reference/content/using_hive_with...

# yum install mysql-connector-java*
# ls -l /usr/share/java/mysql-connector-java.jar
# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar

.

View solution in original post

2 REPLIES 2

Super Mentor

@steve coyle

As the error seems to be related to missing mysql driver class:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

- Can you please check if you have copied the "mysql-connector.jar" inside the following location?

# cp  -r  /usr/lib/hive/lib/mysql-connector-java.jar   /usr/share/java/

.

Additionally please refer to: https://docs.hortonworks.com/HDPDocuments/Ambari-2.4.0.1/bk_ambari-reference/content/using_hive_with...

# yum install mysql-connector-java*
# ls -l /usr/share/java/mysql-connector-java.jar
# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar

.

View solution in original post

ahhhhh yes!

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

ran that command and it worked. guess when it was updated it broke that connection? either way its working now! thanks so much!