Connecting to the Apache Livy Thrift Server

You can connect to the Apache Livy Thrift Server using the Beeline client that is included with Apache Hive.

The Livy Thrift Server is disabled by default. Make sure that you have enabled it before proceeding. For instructions, see Configuring the Livy Thrift Server.

The information required to form a JDBC URL is included in the Livy client configuration file, /etc/livy/conf/livy-client.conf. Make sure that you are on a gateway cluster host managed by Cloudera Manager to ensure that the client configuration is included. You can designate a cluster host as a Livy client by assigning it the Gateway role in the Livy service configuration. For more information about role assignments, see Managing Roles.

  1. On a host designated as a Livy Gateway, view the /etc/livy/conf/livy-client.conf file and note the values of the following configuration parameters:
    This is the URI for the Livy server. The hostname in this URI is the hostname to use for the Thrift server connection.
    This is the port to use in the JDBC connection URL.
    This specifies the transport mode (either binary or http).
  2. Determine the JDBC connection URL using the following table:
    Connection ModeJDBC Connection URL
    binary jdbc:hive2://<livy_host>:<port>/<database>
    binary with Kerberos jdbc:hive2://<livy_host>:<port>/<database>;principal=livy/<livy_host>@<REALM>
    binary with Kerberos and TLS jdbc:hive2://<livy_host>:<port>/<database>;principal=livy/<livy_host>@<REALM>;ssl=true;sslTrustStore=<path_to_truststore>
    http jdbc:hive2://<livy_host>:<port>/<database>;transportMode=http;httpPath=cliservice
    http with Kerberos jdbc:hive2://<livy_host>:<port>/<database>;principal=HTTP/<livy_host>@<REALM>;transportMode=http;httpPath=cliservice
    http with Kerberos and TLS jdbc:hive2://<livy_host>:<port>/<database>;principal=HTTP/<livy_host>@<REALM>;ssl=true;sslTrustStore=<path_to_truststore>;\


  3. Run the beeline command.
  4. At the Beeline prompt, enter !connect <jdbc_url>
    You can set configuration options by appending ?<configuration_list> to the JDBC connection URL. Separate multiple options with a semi-colon (;). Supported options are:
    • livy.session.driverMemory
    • livy.session.driverCores
    • livy.session.executorMemory
    • livy.session.executorCores
    • livy.session.numExecutors
    • livy.session.queue
    • livy.session.heartbeatTimeoutInSecond
    For example:
    beeline> !connect jdbc:hive2://;livy.session.driverCores=2