Starting, Stopping, and Using HiveServer2
HiveServer2 is an improved version of HiveServer that supports Kerberos authentication and multi-client concurrency.
If you are running the metastore in Remote mode, you must start the Hive metastore before you start HiveServer2. HiveServer2 tries to communicate with the metastore as part of its initialization bootstrap. If it is unable to do this, it fails with an error.
To start HiveServer2:
$ sudo service hive-server2 start
To stop HiveServer2:
$ sudo service hive-server2 stop
To confirm that HiveServer2 is working, start the beeline CLI and use it to execute a SHOW TABLES query on the HiveServer2 process:
$ /usr/lib/hive/bin/beeline beeline> !connect jdbc:hive2://localhost:10000 username password org.apache.hive.jdbc.HiveDriver 0: jdbc:hive2://localhost:10000> SHOW TABLES; show tables; +-----------+ | tab_name | +-----------+ +-----------+ No rows selected (0.238 seconds) 0: jdbc:hive2://localhost:10000>
Using the Beeline CLI
Beeline is the CLI (command-line interface) developed specifically to interact with HiveServer2. It is based on the SQLLine CLI written by Marc Prud'hommeaux.
Cloudera does not currently support using the Thrift HTTP protocol to connect Beeline to HiveServer2 (meaning that you cannot set hive.server2.transport.mode=http). Use the Thrift TCP protocol.
Use the following commands to start beeline and connect to a running HiveServer2 process. In this example the HiveServer2 process is running on localhost at port 10000:
$ beeline beeline> !connect jdbc:hive2://localhost:10000 username password org.apache.hive.jdbc.HiveDriver 0: jdbc:hive2://localhost:10000>
If you are using HiveServer2 on a cluster that does not have Kerberos security enabled, then the password is arbitrary in the command for starting Beeline.
If you are using HiveServer2 on a cluster that does have Kerberos security enabled, see HiveServer2 Security Configuration.
- Beeline does not show query logs like the Hive CLI
- When adding JARs to HiveServer2 with Beeline, the JARs must be on the HiveServer2 host.
At present the best source for documentation on Beeline is the original SQLLine documentation.
<< File System Permissions | ©2016 Cloudera, Inc. All rights reserved | Starting HiveServer1 and the Hive Console >> |
Terms and Conditions Privacy Policy |