Installing the Hive JDBC Driver on Clients in CDH
To access the Hive server with JDBC clients, such as Beeline, install the JDBC driver for HiveServer2 that is defined in org.apache.hive.jdbc.HiveDriver.
To install only the JDBC driver on your Hive clients, proceed as follows.
Note:
The CDH 5.2 Hive JDBC driver is not wire-compatible with the CDH 5.1 version of HiveServer2. Make sure you upgrade Hive clients and all other Hive hosts in tandem: the server first, and then the clients.
- Install the package (it is included in CDH packaging). Use one of the following commands, depending on the target operating system:
- On Red-Hat-compatible systems:
$ sudo yum install hive-jdbc
- On SLES systems:
$ sudo zypper install hive-jdbc
- On Ubuntu or Debian systems:
$ sudo apt-get install hive-jdbc
- On Red-Hat-compatible systems:
- Add /usr/lib/hive/lib/*.jar and /usr/lib/hadoop/*.jar to your classpath.
You are now ready to run your JDBC client. HiveServer2 has a new JDBC driver that supports both embedded and remote access to HiveServer2. The connection URLs are also different from those in previous versions of Hive.
For more information see the HiveServer2 Client document.
Connection URLs
The HiveServer2 connection URL has the following format:
jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;sess_var_list?hive_conf_list#hive_var_list
where:
- <host1>:<port1>,<host2>:<port2> is a server instance or a comma separated list of server instances to connect to (if dynamic service discovery is enabled). If no server is mentioned here, the embedded server will be used.
- dbName is the name of the initial database.
- sess_var_list is a semicolon separated list of key=value pairs of session variables. For example, user=foo;password=bar.
- hive_conf_list is a semicolon separated list of key=value pairs of Hive configuration variables for this session. For example, hive.server2.transport.mode=http;hive.server2.thrift.http.path=hs2.
- hive_var_list is a semicolon separated list of key=value pairs of Hive variables for this session.
Connection URLs for Remote or Embedded Mode: For remote or embedded access, the JDBC Driver class is org.apache.hive.jdbc.HiveDriver.
- For a remote server, the URL format is jdbc:hive2://<host>:<port>/<db>. The default HiveServer2 port is 10000).
- For an embedded server, the URL format is jdbc:hive2:// (no host or port).
Connection URLs in HTTP Mode:
jdbc:hive2://<host>:<port>/<db>?hive.server2.transport.mode=http;hive.server2.thrift.http.path=<http_endpoint>where <http_endpoint> is the corresponding HTTP endpoint configured in hive-site.xml. The default value for the endpoint is cliservice. The default port for HTTP transport mode is 10001.
Connection URLs with SSL Enabled:
jdbc:hive2://<host>:<port>/<db>;ssl=true;sslTrustStore=<trust_store_path>;trustStorePassword=<trust_store_password>where:
- <trust_store_path> is the path where client's truststore file is located.
- <trust_store_password> is the password to access the truststore.
In HTTP mode with SSL enabled, the URL is of the format:
jdbc:hive2://<host>:<port>/<db>;ssl=true;sslTrustStore=<trust_store_path>;trustStorePassword=<trust_store_password>?hive.server2.transport.mode=http;hive.server2.thrift.http.path=<http_endpoint>
Page generated May 18, 2018.
<< Using the Hive Schema Tool in CDH | ©2016 Cloudera, Inc. All rights reserved | Setting HADOOP_MAPRED_HOME for Apache Hive in CDH >> |
Terms and Conditions Privacy Policy |