How do I install the "Beeline" Hive client?
Solution 1:
It is not necessary to install beeline/hive. All you have to do is collect the relevant jars from your system and copy them and place them in a single folder.
Suppose, we have a source system where you have beeline and a target system where you want to run beeline.
On the source system collect the relevant jars into one folder. The best way I have found to identify the exact jars involved is to use the jvm option: -verbose:class
I.e., you should be able to issue a java
command that will replicate a typical beeline command invocation on the source system.
Then copy those files into one folder on the target system. cd
to that folder to make the -classpath
reference later simple.
I use an HDP 2.5 Hortonworks distro. For me, the following invocation on the target system works:
java -Xmx1024m -classpath apache-log4j-extras-1.2.17.jar:avatica-1.8.0.2.5.0.0-1245.jar:calcite-core-1.2.0.2.5.0.0-1245.jar:calcite-linq4j-1.2.0.2.5.0.0-1245.jar:commons-cli-1.2.jar:commons-codec-1.4.jar:commons-collections-3.2.2.jar:commons-configuration-1.6.jar:commons-lang-2.6.jar:commons-logging-1.1.3.jar:curator-client-2.6.0.jar:curator-framework-2.6.0.jar:derby-10.10.2.0.jar:guava-14.0.1.jar:hadoop-annotations-2.7.3.2.5.0.0-1245.jar:hadoop-auth-2.7.3.2.5.0.0-1245.jar:hadoop-common-2.7.3.2.5.0.0-1245.jar:hadoop-mapreduce-client-core-2.7.3.2.5.0.0-1245.jar:hive-beeline-1.2.1000.2.5.0.0-1245.jar:hive-exec-1.2.1000.2.5.0.0-1245.jar:hive-jdbc-1.2.1000.2.5.0.0-1245.jar:hive-jdbc-1.2.1000.2.5.0.0-1245-standalone.jar:jce.jar:jline-2.12.jar:jsse.jar:log4j-1.2.16.jar:rt.jar:slf4j-log4j12-1.7.10.jar:sunec.jar:sunjce_provider.jar:super-csv-2.2.0.jar:xercesImpl-2.9.1.jar -Dhdp.version=2.5.0.0-1245 -Djava.net.preferIPv4Stack=true -Dhdp.version=2.5.0.0-1245 -Dhadoop.log.dir=/home/userid -Dhadoop.log.file=hadoop.log -Dhadoop.home.dir=/home/userid -Dhadoop.id.str=userid -Dhadoop.root.logger=INFO,console -Djava.library.path=:/home/userid -Dhadoop.policy.file=hadoop-policy.xml -Djava.net.preferIPv4Stack=true -Djava.util.logging.config.file=/home/userid/parquet-logging.properties -Dlog4j.configuration=beeline-log4j.properties -Dhadoop.security.logger=INFO,NullAppender org.apache.hadoop.util.RunJar /home/userid/hive-beeline-1.2.1000.2.5.0.0-1245.jar org.apache.hive.beeline.BeeLine -n userid -p pass -u "jdbc:hive2://knox.company.com:8000/;ssl=true;transportMode=http;httpPath=gateway/tdcprd/hive"
Some of the parameters are probably not necessary, but I kept them because that is how it is done on the source system. You should use source system's java invocation as a reference pattern.
Solution 2:
You can get beeline by installing Hive and Hadoop (Hadoop is a necessary dependency for Hive).
First download Hadoop common from http://www.apache.org/dyn/closer.cgi/hadoop/common/ . Unpack and set the variable HADOOP_HOME
to this location. Example:
$ wget https://apache.uib.no/hadoop/common/hadoop-3.3.1/hadoop-3.3.1.tar.gz
$ tar -xzvf hadoop-3.3.1.tar.gz
$ export HADOOP_HOME="$(pwd)/hadoop-3.3.1" # You may want set this var in your .bashrc
Second, for Hadoop to run, you need to make sure JAVA_HOME
is set:
# Find java home:
$ java -XshowSettings:properties -version 2>&1 | grep java.home
java.home = /usr/lib/jvm/java-11-openjdk-amd64
$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 # Replace with your JAVA_HOME
Third, download a bin version of Hive from https://hive.apache.org/downloads.html , unpack and then you can run bin/beeline
. Example:
$ wget https://apache.uib.no/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz
$ tar -xzvf apache-hive-3.1.2-bin.tar.gz
$ cd apache-hive-3.1.2-bin
$ /bin/beeline --version
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/mikaelol/projects/kerberos/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/mikaelol/projects/kerberos/hadoop-3.3.1/share/hadoop/common/lib/slf4j-log4j12-1.7.30.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]
Hive 3.1.2
Git git://HW13934/Users/gates/tmp/hive-branch-3.1/hive -r 8190d2be7b7165effa62bd21b7d60ef81fb0e4af
Compiled by gates on Thu Aug 22 15:01:18 PDT 2019
From source with checksum 0492c08f784b188c349f6afb1d8d9847