This topic describes how to connect to Hive from an E-MapReduce (EMR) cluster.

Method 1: Use the Hive client

  • For a common cluster, run the following command:
    hive
    The following information is returned:
    Logging initialized using configuration in file:/etc/ecm/hive-conf-2.3.5-2.0.3/hive-log4j2.properties Async: true
    Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
  • For a high-security cluster, perform the following steps:
    1. Run the following command to perform authentication:
      kinit -kt /etc/ecm/hive-conf/hive.keytab hive/emr-header-1.cluster-xxx@EMR.xxx.COM

      Replace xxx in the command with the hostname of the emr-header-1 node. You can run the hostname command on emr-header-1 to obtain the hostname.

      Alternatively, you can use the user management feature to create a user. Then, before you use Hive, you can run the kinit username command and enter the password of the user to perform authentication. For more information about how to create a user, see Manage user accounts.
      1. Run the following command to perform authentication:
        kinit username
      2. Enter the password of the user.
        Password for username @ EMR.xxx.COM:
    2. Connect to Hive.
      hive
      The following information is returned:
      Logging initialized using configuration in file:/etc/ecm/hive-conf-2.3.5-2.0.3/hive-log4j2.properties Async: true
      Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.

Method 2: Use Beeline

  • For a common cluster, run the following command:
    beeline -u jdbc:hive2://emr-header-1:10000
    The following information is returned:
    Connecting to jdbc:hive2://emr-header-1:10000
    Connected to: Apache Hive (version 2.3.5)
    Driver: Hive JDBC (version 2.3.5)
    Transaction isolation: TRANSACTION_REPEATABLE_READ
    Beeline version 2.3.5 by Apache Hive
    0: jdbc:hive2://emr-header-1:10000>
  • For a high-security cluster, perform the following steps:
    1. Run the following command to perform authentication:
      kinit -kt /etc/ecm/hive-conf/hive.keytab hive/emr-header-1.cluster-xxx@EMR.xxx.COM

      Replace xxx in the command with the hostname of the emr-header-1 node. You can run the hostname command on emr-header-1 to obtain the hostname.

      Alternatively, you can use the user management feature to create a user. Then, before you connect to Beeline, you can run the kinit username command and enter the password of the user to perform authentication. For more information about how to create a user, see Manage user accounts.
      1. Run the following command to perform authentication:
        kinit username
      2. Enter the password of the user.
        Password for username @ EMR.xxx.COM:
    2. Connect to Beeline.
      beeline -u "jdbc:hive2://emr-header-1:10000/;principal=hive/emr-header-1.cluster-xxx@EMR.xxx.COM"
      Note The JDBC URL must be enclosed in a pair of double quotation marks (").
      The following information is returned:
      Connecting to jdbc:hive2://emr-header-1:10000/;principal=hive/emr-header-1.cluster-202618@EMR.202618.COM
      Connected to: Apache Hive (version 2.3.5)
      Driver: Hive JDBC (version 2.3.5)
      Transaction isolation: TRANSACTION_REPEATABLE_READ
      Beeline version 2.3.5 by Apache Hive
      0: jdbc:hive2://emr-header-1:10000/>