Examples

Example: Using Beeline with no Encryption and no Authentication

hive --service beeline
Beeline version 2.3.3-mapr-1901 by Apache Hive
beeline> !connect jdbc:hive2://<hs2_hostname>:10000/default;
Connecting to jdbc:hive2://<hs2_hostname>:10000/default;
Enter username for jdbc:hive2://<hs2_hostname>:10000/default;: <username>
0: jdbc:hive2://<hs2_hostname>:10000/defau> 

Example: Using Beeline with Encryption and no Authentication

hive --service beeline
Beeline version 2.3.3-mapr-1901 by Apache Hive
beeline> !connect jdbc:hive2://<hs2_hostname>:10000/default;ssl=true;sslTrustStore=truststore.jks;sslTrustStorePassword=tsp
Connecting to jdbc:hive2://<hs2_hostname>:10000/default;ssl=true;sslTrustStore=truststore.jks;sslTrustStorePassword=tsp
Enter username for jdbc:hive2://<hs2_hostname>:10000/default;ssl=true;sslTrustStore=truststore.jks;sslTrustStorePassword=tsp: <user> 

Example: Connecting to HiveServer2 with MapR-SASL Authentication

hive --service beeline
Beeline version 2.3.3-mapr-1901 by Apache Hive
beeline> !connect jdbc:hive2://<hs2_hostname>:10000/default;auth=maprsasl;ssl=true
Connecting to jdbc:hive2://<hs2_hostname>:10000/default;auth=maprsasl;ssl=true
19/01/31 12:15:33 [main]: WARN maprsasl.MaprSaslClient: SASL Server qopProperty: auth-confis different from Client: auth-conf,auth-int,auth.Using Server one
Connected to: Apache Hive (version 2.3.3-mapr-1901)
Driver: Hive JDBC (version 2.3.3-mapr-1901)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://<hs2_hostname>:10000/defau>

Starting from MEP 6.0.0, with secure by default configuration, it is a default connection string for a secure cluster. For more information, see Configuring JDBC Connection String with SSL Encryption Enabled or Disabled.

Example: Using Beeline with PAM Authentication

hive --service beeline
Beeline version 2.3.3-mapr-1901 by Apache Hive 
beeline> !connect jdbc:hive2://<hs2_hostname>:10000/default; 
Connecting to jdbc:hive2://<hs2_hostname>:10000/default; 
Enter username for jdbc:hive2://<hs2_hostname>:10000/default;: mapr 
Enter password for jdbc:hive2://<hs2_hostname>:10000/default;: *******  
Connected to: Apache Hive (version 2.3.3-mapr-1901)
Driver: Hive JDBC (version 2.3.3-mapr-1901)
Transaction isolation: TRANSACTION_REPEATABLE_READ 

Example: Connecting to HiveServer2 with PAM Authentication and SSL Encryption

hive --service beeline
Beeline version 2.3.3-mapr-1901 by Apache Hive
beeline> !connect jdbc:hive2://<hs2_hostname>:10000/default;ssl=true;
Connecting to jdbc:hive2://<hs2_hostname>:10000/default;ssl=true;
Enter username for jdbc:hive2://<hs2_hostname>:10000/default: mapr
Enter password for jdbc:hive2://<hs2_hostname>:10000/default: ****
Connected to: Apache Hive (version 2.3.3-mapr)
Driver: Hive JDBC (version 2.3.3-mapr)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://<hs2_hostname>:10000/default>

Starting from MEP 6.0.0, with secure by default configuration, it is a default connection string for a secure cluster. For more information, see Configuring JDBC Connection String with SSL Encryption Enabled or Disabled.

Example: Using Beeline with Kerberos

Beeline must pass the Kerberos principal for HiveServer2 in the JDBC connection string. The connection strings you pass to Beeline must use the principal name that you configured for HiveServer2.

See below for a sample Beeline authentication with Kerberos:

hive --service beeline
Beeline version 2.3.3-mapr-1901 by Apache Hive
beeline> !connect jdbc:hive2://<hs2_hostname>:10000/default;principal=mapr<FQDN@REALM>
Connecting to jdbc:hive2://<hs2_hostname>:10000/default;principal=mapr/<FQDN@REALM>
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://<hs2_hostname>:10000/def> 
Connected to: Apache Hive (version 2.3.3-mapr)
Driver: Hive JDBC (version 2.3.3-mapr)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://<hs2_hostname>:10000/default>

Example: Using Beeline with Encryption but no Authentication (truststore parameters passed as JVM arguments)

Hive --service beeline
Beeline version 2.3.3-mapr-1901 by Apache Hive
beeline> !connect jdbc:hive2://<hs2_hostname>:1000/default;ssl=true
Connecting to jdbc:hive2://<hs2_hostname>:10000/default;ssl=true
Enter username for jdbc:hive2://<hs2_hostname>:10000/default;ssl=true: <username>
Enter password for jdbc:hive2://<hs2_hostname>:10000/default;ssl=true: ****
Connected to: Apache Hive (version 2.3.3-mapr)
Driver: Hive JDBC (version 2.3.3-mapr)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://<hs2_hostname>:10000/default>

Example: Generating a Kerberos Ticket

You use the kinit utility to generate the ticket and then use klist to verify that a ticket exists.

# kinit <username>/<FQDN@REALM>
# klist
 
Credentials cache: API:501:9
        Principal: username/<FQDN@REALM>
    Cache version: 0
 
Server: krbtgt/<FQDN@REALM>
Client: username/<FQDN@REALM>
Ticket etype: aes128-cts-hmac-sha1-96
Ticket length: 256
Auth time:  Jun 11 10:01:48 2014
End time:   Jun 12 18:01:34 2014
Renew till: Jun 18 10:01:48 2014
Ticket flags: pre-authent, initial, renewable, forwardable
Addresses: addressless