0

I'm trying to connect to hive-server in my docker container with the command beeline -u jdbc:hive2://localhost:10000, but i get the erros:

root@hive_server:/opt# beeline -u jdbc:hive2://localhost:10000
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://localhost:10000
21/08/30 12:36:56 [main]: WARN jdbc.HiveConnection: Failed to connect to localhost:10000
Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the administrator to check the server status.
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000: java.net.ConnectException: Connection refused (Connection refused) (state=08S01,code=0)
Beeline version 2.3.2 by Apache Hive

So i tryed to use beeline -r, and got this:

root@hive_server:/opt#
root@hive_server:/opt# beeline -r
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Beeline version 2.3.2 by Apache Hive
beeline> root@hive_server:/opt# beeline -u jdbc:hive2://localhost:10000
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://localhost:10000
21/08/29 18:42:19 [main]: WARN jdbc.HiveConnection: Failed to connect to localhost:10000
Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the administrator to check the server status.
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000: java.net.ConnectException: Connection refused (Connection refused) (state=08S01,code=0)
Beeline version 2.3.2 by Apache Hive
beeline>

with beeline -help i tryed to use another way to connect, which is beeline -n username -p password -u jdbc:hive2://hs2.local:10012 , and got this:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://hs2.local:10012
21/08/30 12:54:25 [main]: WARN jdbc.HiveConnection: Failed to connect to hs2.local:10012
Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the administrator to check the server status.
Error: Could not open client transport with JDBC Uri: jdbc:hive2://hs2.local:10012: java.net.UnknownHostException: hs2.local (state=08S01,code=0)
Beeline version 2.3.2 by Apache Hiv

So idk what is going on and how to solve this problem. What am i missing?

Daniel Dantas
  • 145
  • 3
  • 15

2 Answers2

1

If you are running hive server in a docker and trying to connect within the docker then you should not use host name as localhost. Use container name of hive server as hostname.

beeline -u jdbc:hive2://<container_name>:10000
Mohana B C
  • 5,021
  • 1
  • 9
  • 28
  • Hi @Mohana, thank you for your answer. I tried this, but no results... `beeline -u jdbc:hive2://hive-server:10000` resulted in: `WARN jdbc.HiveConnection: Failed to connect to hive-server:10000 Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the administrator to check the server status. Error: Could not open client transport with JDBC Uri: jdbc:hive2://hive-server:10000: java.net.ConnectException: Connection refused (Connection refused) (state=08S01,code=0)` – Daniel Dantas Aug 31 '21 at 12:20
  • Is hive server running? `hive --service hiveserver2` – Mohana B C Aug 31 '21 at 12:27
  • That's a good question. The hive server soon or later stops, idk why. – Daniel Dantas Aug 31 '21 at 12:29
  • here are: ` hive --service hiveserver2 2021-08-31 12:28:36: Starting HiveServer2 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]` – Daniel Dantas Aug 31 '21 at 12:30
  • Which docker image are you using? did you set up on your local laptop? – Mohana B C Aug 31 '21 at 12:31
  • I'm using a image provided by a course i'm taking. And yes, i have set up it. – Daniel Dantas Aug 31 '21 at 12:33
  • I thought it would be the Java jdk, but i've intalled it and yet dont work. – Daniel Dantas Aug 31 '21 at 12:35
  • If the container is stopping, try increasing memory of docker. – Mohana B C Aug 31 '21 at 12:35
  • That's a good sugestion, i'll search how to do that. Thank you – Daniel Dantas Aug 31 '21 at 12:36
  • It's just about a couple of clicks if you are using docker desktop. – Mohana B C Aug 31 '21 at 12:37
  • Yeah... I discovered that i have to configurate a file: "You are using the WSL 2 backend, so resource limits are managed by Windows. You can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a .wslconfig file." – Daniel Dantas Aug 31 '21 at 12:42
0

After research and help of colleagues (https://github.com/rbonela), found out that the problem was with permissions beeing denied in the directory: /var/lib/postgresql/data

So, the solution was kill all containers, edit docker-compose.yml file, on the hive-metastore-postgresql configuration section, change the directory /var/lib/postgresql/datato another one you like.

Test it out again. This worked for me.

Daniel Dantas
  • 145
  • 3
  • 15