While the user may use any client program to connect to HiveServer2, the MR3 release provides a script for creating Beeline connections based on the configuration files in the installation.

Updating env.sh for running Beeline

Running Beeline on the same node where HiveServer2 runs does not require any change to env.sh. In order to run Beeline on a different node, however, the user should install Hive on MR3 on the new node and set the following environment variables in env.sh:

# set JAVA_HOME if not set yet 
export JAVA_HOME=/usr/apps/java/default
export PATH=$JAVA_HOME/bin:$PATH

HIVE3_SERVER2_HOST=red0
HIVE3_SERVER2_PORT=9832

HIVE4_SERVER2_HOST=red0
HIVE4_SERVER2_PORT=9842

HIVE_SERVER2_AUTHENTICATION=KERBEROS
HIVE_SERVER2_KERBEROS_PRINCIPAL=hive/red0@RED

HIVE_CLIENT_HEAPSIZE=2048

LOG_LEVEL=INFO
  • HIVE3_SERVER2_HOST and HIVE3_SERVER2_PORT specify the address of HiveServer2 based on Hive 3. Note that $HOSTNAME should not be used for HIVE3_SERVER2_HOST if Beeline is running on a different node. Similarly for HIVE4_SERVER2_HOST.
  • HIVE_SERVER2_AUTHENTICATION specifies the authentication option for HiveServer2: NONE, NOSASL, KERBEROS, LDAP, PAM, and CUSTOM.
  • HIVE_SERVER2_KERBEROS_PRINCIPAL specifies the principal for HiveServer2 when HIVE_SERVER2_AUTHENTICATION is set to KERBEROS. Note that HIVE_SERVER2_KERBEROS_KEYTAB for the keytab file for HiveServer2 is not used for running Beeline.
  • HIVE_CLIENT_HEAPSIZE specifies the heap size (in MB) for Beeline.
  • LOG_LEVEL specifies the logging level.

Running Beeline

In order to start a Beeline connection, execute hive/run-beeline.sh with the following options:

--local                   # Run jobs with configurations in conf/local/ (default).
--cluster                 # Run jobs with configurations in conf/cluster/.
--tpcds                   # Run jobs with configurations in conf/tpcds/.
--hivesrc3                # Choose hive3-mr3 (based on Hive 3.1.3)
--hivesrc4                # Choose hive4-mr3 (based on Hive 4.0.0, default)
--hiveconf <key>=<value>  # Add a configuration key/value; may be repeated at the end.
<Beeline option>          # Add a Beeline option; may be repeated at the end.

The user can append as many Beeline options (for the command beeline from Hive) as necessary to the command.

An optional environment variable HIVE_SERVER2_JDBC_OPTS specifies a string to be appended to the JDBC connection string.

  • If SSL is enabled, it should contain, e.g., ssl=true;sslTrustStore=/home/hive/mr3-run/beeline-ssl.jks;trustStorePassword=beelinepasswd1.
  • If HTTP transport is used, it should contain transportMode=http;httpPath=/cliservice.