There's no easy way to submit a fix to this doc https://hive.apache.org/developement/quickstart/ so I'm writing my fix here.
In doc it says:
docker run -d -p 10000:10000 -p 10002:10002 --env SERVICE_NAME=hiveserver2 --name hive4 apache/hive:${HIVE_VERSION}
docker exec -it hiveserver2 beeline -u 'jdbc:hive2://hiveserver2:10000/'
- There seems to be a mismatch on the container name:
hive4 != hiveserver2
- URI
hiveserver2
does not seem to be defined -> uselocahost
Fix the issues above by using:
docker run -d -p 10000:10000 -p 10002:10002 --env SERVICE_NAME=hiveserver2 --name hiveserver2 apache/hive:${HIVE_VERSION}
docker exec -it hiveserver2 beeline -u 'jdbc:hive2://localhost:10000/'
Error happens at:
STEP 4: Connect to beeline
docker exec -it hiveserver2 beeline -u 'jdbc:hive2://hiveserver2:10000/'
Hopefully the error message helps people find this fix:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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://hiveserver2:10000/
23/10/17 00:53:55 [main]: WARN jdbc.Utils: Could not retrieve canonical hostname for hiveserver2
java.net.UnknownHostException: hiveserver2: Temporary failure in name resolution
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[?:1.8.0_342]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929) ~[?:1.8.0_342]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1330) ~[?:1.8.0_342]
at java.net.InetAddress.getAllByName0(InetAddress.java:1283) ~[?:1.8.0_342]
at java.net.InetAddress.getAllByName(InetAddress.java:1199) ~[?:1.8.0_342]
at java.net.InetAddress.getAllByName(InetAddress.java:1127) ~[?:1.8.0_342]
at java.net.InetAddress.getByName(InetAddress.java:1077) ~[?:1.8.0_342]
at org.apache.hive.jdbc.Utils.getCanonicalHostName(Utils.java:701) [hive-jdbc-3.1.3.jar:3.1.3]
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:178) [hive-jdbc-3.1.3.jar:3.1.3]
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107) [hive-jdbc-3.1.3.jar:3.1.3]
at java.sql.DriverManager.getConnection(DriverManager.java:664) [?:1.8.0_342]
at java.sql.DriverManager.getConnection(DriverManager.java:208) [?:1.8.0_342]
at org.apache.hive.beeline.DatabaseConnection.connect(DatabaseConnection.java:145) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.DatabaseConnection.getConnection(DatabaseConnection.java:209) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.Commands.connect(Commands.java:1641) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.Commands.connect(Commands.java:1536) [hive-beeline-3.1.3.jar:3.1.3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_342]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_342]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_342]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_342]
at org.apache.hive.beeline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:56) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.BeeLine.execCommandWithPrefix(BeeLine.java:1384) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:1423) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.BeeLine.connectUsingArgs(BeeLine.java:900) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.BeeLine.initArgs(BeeLine.java:795) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.BeeLine.begin(BeeLine.java:1048) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:538) [hive-beeline-3.1.3.jar:3.1.3]
at org.apache.hive.beeline.BeeLine.main(BeeLine.java:520) [hive-beeline-3.1.3.jar:3.1.3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_342]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_342]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_342]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_342]
at org.apache.hadoop.util.RunJar.run(RunJar.java:308) [hadoop-common-3.1.0.jar:?]
at org.apache.hadoop.util.RunJar.main(RunJar.java:222) [hadoop-common-3.1.0.jar:?]
23/10/17 00:53:55 [main]: WARN jdbc.HiveConnection: Failed to connect to hiveserver2: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://hiveserver2:10000/: java.net.UnknownHostException: hiveserver2 (state=08S01,code=0)
Beeline version 3.1.3 by Apache Hive
[WARN] Failed to create directory: /home/hive/.beeline
No such file or directory