clemlabprojects / ambari

Fork of Apache Ambari maintained by Clemlab Company
https://www.clemlab.com
Apache License 2.0
39 stars 15 forks source link

Hive Failed when connecting into mysql #60

Closed Meikelrizkyhartawan closed 5 months ago

Meikelrizkyhartawan commented 5 months ago

im installing hive with this odp repo : https://clemlabs.s3.eu-west-3.amazonaws.com/ubuntu22/odp-release/1.2.1.0-187/odp.list

but the hive show that it cannot connecting into mysql , i use this java connector jar for ubuntu 22 version 8.3.0 : https://dev.mysql.com/downloads/connector/j/

debug : i',m trying to test the connection into mysql with mysql client and it works , but i do not know why hive still can not access the database

image

Hive error : Traceback (most recent call last): File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 150, in _call_wrapper result = _call(command, **kwargs_copy) File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 314, in _call raise ExecutionFailed(err_msg, code, out, err) ExecutionFailed: Execution of '/usr/lib/jvm/java-8-openjdk-amd64/jre//bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/odp/current/hive-server2/lib/mysql-connector-java.jar org.apache.ambari.server.DBConnectionVerification 'jdbc:mysql://hdp-datanode03.maas.ph/hive?user=hive&password=rahasia2023' hive [PROTECTED] com.mysql.jdbc.Driver' returned 1. Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. ERROR: Unable to connect to the DB. Please check DB connection properties. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

The above exception was the cause of the following exception:

Traceback (most recent call last): File "/var/lib/ambari-agent/cache/stacks/ODP/1.0/services/HIVE/package/scripts/hive_server.py", line 143, in HiveServer().execute() File "/usr/lib/ambari-agent/lib/resource_management/libraries/script/script.py", line 352, in execute method(env) File "/var/lib/ambari-agent/cache/stacks/ODP/1.0/services/HIVE/package/scripts/hive_server.py", line 53, in start hive_service('hiveserver2', action = 'start', upgrade_type=upgrade_type) File "/var/lib/ambari-agent/cache/stacks/ODP/1.0/services/HIVE/package/scripts/hive_service.py", line 94, in hive_service validate_connection(params.hive_jdbc_target, params.hive_lib) File "/var/lib/ambari-agent/cache/stacks/ODP/1.0/services/HIVE/package/scripts/hive_service.py", line 150, in validate_connection path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', tries=5, try_sleep=10) File "/usr/lib/ambari-agent/lib/resource_management/core/base.py", line 166, in init self.env.run() File "/usr/lib/ambari-agent/lib/resource_management/core/environment.py", line 160, in run self.run_action(resource, action) File "/usr/lib/ambari-agent/lib/resource_management/core/environment.py", line 124, in run_action provider_action() File "/usr/lib/ambari-agent/lib/resource_management/core/providers/system.py", line 263, in action_run returns=self.resource.returns) File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 72, in inner result = function(command, kwargs) File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 102, in checked_call tries=tries, try_sleep=try_sleep, timeout_kill_strategy=timeout_kill_strategy, returns=returns) File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 150, in _call_wrapper result = _call(command, kwargs_copy) File "/usr/lib/ambari-agent/lib/resource_management/core/shell.py", line 314, in _call raise ExecutionFailed(err_msg, code, out, err) resource_management.core.exceptions.ExecutionFailed: Execution of '/usr/lib/jvm/java-8-openjdk-amd64/jre//bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/odp/current/hive-server2/lib/mysql-connector-java.jar org.apache.ambari.server.DBConnectionVerification 'jdbc:mysql://hdp-datanode03.maas.ph/hive?user=hive&password=rahasia2023' hive [PROTECTED] com.mysql.jdbc.Driver' returned 1. Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. ERROR: Unable to connect to the DB. Please check DB connection properties. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Meikelrizkyhartawan commented 5 months ago

Im solve the issues using this steps : https://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql

answer :

  1. change the url into 127.0.0.1 instead of localhost OR
  2. export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true" // run this command or store it into /etc/profile OR
  3. change the bind address of the mysql in path /etc/mysql/mysql.conf.d/mysqld.cnf

change

bind-address = 127.0.0.1

into

bind-address = 0.0.0.0

lucasbak commented 5 months ago

Hi @Meikelrizkyhartawan,

Thanks for your answer.

Best regards