Kerberos is an authentication protocol that uses symmetric-key cryptography to verify identities for other services. This topic describes how to access a Hive client when Kerberos authentication is enabled.
Prerequisites
A cluster must be created, and on the Software Configuration page, in the Advanced Settings section, the Kerberos Authentication switch must be enabled. For more information, see Create a cluster.
Procedure
-
Log on to the cluster over SSH. For more information, see Log on to a cluster.
-
Run the following command to start the Kerberos admin.local tool.
-
If you log on to the master-1-1 node where the Kerberos Key Distribution Center (KDC) server runs as the
rootuser, you can run the following command to directly access the admin tool.kadmin.localThe following output indicates that you have entered the
kadmin.localcommand-line interface:Authenticating as principal hadoop/admin@EMR.C-85D4B8D74296****.COM with password. kadmin.local: -
If you log on to another node or use a gateway, run the following command to access the admin tool.
kadmin -p <admin-user> -w <admin-password>NoteIf you use the KDC provided by E-MapReduce, note the following parameters:
-
<admin-user>: The value is fixed toroot/admin. -
<admin-password>: In the E-MapReduce console, go to the Configure tab of the Kerberos service to get the value of the admin_pwd parameter.
The following output indicates that you have entered the
kadmincommand-line interface:Authenticating as principal root/admin with password. kadmin: -
-
-
Run the following command to create a principal named
test.In this example, the password is
123456.addprinc -pw 123456 testThe following output indicates that the principal was created successfully:
Principal "test@EMR.C-85D4B8D74296****.COM" created.NoteRecord the username and password. You will need them to create a ticket-granting ticket (TGT).
Run the
quitcommand to exit the Kerberos admin.local tool. -
Log on to the machine where you want to run the Hive client, and run the following commands to create and switch to the
testuser.useradd test su test -
Run the following command to create a TGT.
kinitPress Enter and enter the password for the
testuser. In this example, the password is123456. -
Connect to the Hive client.
-
Method 1: Run the
hivecommand to access the Hive client.hive -
Method 2: Use Beeline to access the Hive client.
beeline -u "jdbc:hive2://master-1-1.c-56187feb57f0****.cn-hangzhou.emr.aliyuncs.com:10000/;principal=hive/_HOST@EMR.c-56187feb57f0****.COM"Replace the following placeholders with your information:
-
master-1-1.c-56187feb57f0****.cn-hangzhou.emr.aliyuncs.com: The fully qualified hostname, including the domain name. You can obtain the hostname by running thehostname -fcommand on the node where the HiveServer2 service runs (typically the master-1-1 node). -
EMR.c-56187feb57f0****.COM: The realm name. In the E-MapReduce console, go to the Configure tab for the Kerberos service to find the value of therealmparameter.
-
-
Related documents
-
For more information about creating a principal, see Database administration.
-
For more information about creating a TGT, see Kinit.