Each service in HDP must have its own principal. A principal name in a given realm is comprised of the primary and an instance (for example, primary/instance@REALM). Because services do not login with a password to acquire Kerberos tickets, the principal authentication key is stored in a keytab file. This keytab file is generated from the Kerberos database and stored locally on the service component host.
First you must create the principal, using mandatory naming conventions. Then you must create the keytab file with that principal's information and copy the file to the keytab directory on the appropriate service host.
![]() | Note |
|---|---|
Principals can be created either on the KDC machine itself or through the network, using a
previously created “admin” principal. The following instructions assume you are
using the KDC machine and using the |
Open the
kadmin.localutility on the KDC machine/usr/sbin/kadmin.local
Create a service principal using the
kadminutility:kadmin: addprinc -randkey $principal_name/$fully.qualified.domain.name@YOUR-REALM.COM
You must have a principal with administrative permissions to use this command. The randkey is used to generate the password.
Note that in the example each service principal's name has appended to it the fully qualified domain name of the host on which it is running. This ensures that each service has a unique principal name.
The addition of the hostname serves to distinguish, for example, a request from DataNode A from a request from DataNode B. This is important for two reasons:
If the Kerberos credentials for one DataNode are compromised, it does not automatically lead to all DataNodes being compromised
If multiple DataNodes have exactly the same principal and are simultaneously connecting to the NameNode, and if the Kerberos authenticator being sent happens to have same timestamp, then the authentication would be rejected as a replay request.
The
$principal_namepart of the name must match the values in the table below:Note that the NameNode, Secondary NameNode, and Oozie require two principals each.
Table 15.2. Service Principal Names
Service Name Component Mandatory Principal Name HDFS
NameNode
nn/$FQDNHDFS
NameNode HTTP
HTTP/$FQDNHDFS
Secondary NameNode
nn/$FQDNHDFS
Secondary NameNode HTTP
HTTP/$FQDNHDFS
DataNode
dn/$FQDNMapReduce
JobTracker
jt/$FQDNMapReduce
TaskTracker
tt/$FQDNHBase
MasterServer
hbase/$FQDNHBase
RegionServer
hbase/$FQDNZooKeeper
ZooKeeper
zookeeper/$FQDNHive
Hive Metastore HiveServer2
hive/$FQDNHive
WebHCat
HTTP/$FQDNOozie
Oozie Server
oozie/$FQDNOozie
Oozie HTTP
HTTP/$FQDNHue hueFor example: To create the principal for a DataNode service, execute the following command:
kadmin: addprinc -randkey dn/$DataNode_Host_FQDN@EXAMPLE.COM
After the principals are created in the database, extract related keytab files for transfer to the appropriate host:
For RHEL/CentOS 5.x:
kadmin: xst -k $keytab_file_name $principal_name/fully.qualified.domain.name
For RHEL/CentOS 6.x:
kadmin: xst -norandkey -k $keytab_file_name $principal_name/fully.qualified.domain.name
For SLES:
kadmin: xst -norandkey -k $keytab_file_name $principal_name/fully.qualified.domain.name
You must use the mandatory names for the
$keytab_file_namevariable as shown in this table.Table 15.3. Service Keytab File Names
Component Mandatory Principal Name Mandatory Keytab File Name NameNode
nn/$FQDNnn.service.keytabNameNode HTTP
HTTP/$FQDNspnego.service.keytabSecondary NameNode
nn/$FQDNnn.service.keytabSecondary NameNode HTTP
HTTP/$FQDNspnego.service.keytabDataNode
dn/$FQDNdn.service.keytabJobTracker
jt/$FQDNjt.service.keytabTaskTracker
tt/$FQDNtt.service.keytabHBase MasterServer
hbase/$FQDNhbase.service.keytabHBase RegionServer
hbase/$FQDNhbase.service.keytabZooKeeper
zookeeper/$FQDNzk.service.keytabHive Metastore HiveServer2
hive/$FQDNhive.service.keytabWebHCat
HTTP/$FQDNspnego.service.keytabOozie Server
oozie/$FQDNoozie.service.keytabOozie HTTP
HTTP/$FQDNspnego.service.keytabHue huehue.service.keytabFor example: To create the keytab files for the NameNode, issue these commands:
kadmin: xst -k nn.service.keytab nn/<$NameNode_Host_FQDN> kadmin: xst -k spnego.service.keytab HTTP/<$NameNode_Host_FQDN>
When you have created the keytab files, copy them to the
keytabdirectory of the respective service hosts.When the keytab files have been created, on each host create a directory for them and set appropriate permissions.
mkdir -p /etc/security/keytabs/ chown root:$HADOOP_GROUP /etc/security/keytabs chmod 750 /etc/security/keytabs
where
$HADOOP_GROUPis a common group shared by services. For example,hadoop.Set appropriate permissions for the keytabs.
On the NameNode and Secondary NameNode hosts, execute the following command:
chown $HDFS_USER:$HADOOP_GROUP /etc/security/keytabs/nn.service.keytab chmod 400 /etc/security/keytabs/nn.service.keytab chown root:$HADOOP_GROUP /etc/security/keytabs/spnego.service.keytab chmod 440 /etc/security/keytabs/spnego.service.keytabExecute the following command on all the slave nodes (DataNodes).
chown $HDFS_USER:$HADOOP_GROUP /etc/security/keytabs/dn.service.keytab chmod 400 /etc/security/keytabs/*.service.keytab
On JobTracker:
chown $MAPRED_USER:$HADOOP_GROUP /etc/security/keytabs/jt.service.keytab chmod 400 /etc/security/keytabs/*.service.keytab
On all the slave nodes (TaskTrackers).
chown $MAPRED_USER:$HADOOP_GROUP /etc/security/keytabs/tt.service.keytab chmod 400 /etc/security/keytabs/*.service.keytab
On HBase MasterServer, RegionServers, and ZooKeeper hosts:
chown $HBASE_USER:$HADOOP_GROUP /etc/security/keytabs/hbase.service.keytab chmod 400 /etc/security/keytabs/hbase.service.keytab chown $ZOOKEEPER_USER:$HADOOP_GROUP /etc/security/keytabs/zk.service.keytab chmod 400 /etc/security/keytabs/zk.service.keytab
On the host that runs the Hive Metastore, HiveServer2 and WebHCat:
chown $HIVE_USER:$HADOOP_GROUP /etc/security/keytabs/hive.service.keytab chmod 400 /etc/security/keytabs/hive.service.keytab chown root:$HADOOP_GROUP /etc/security/keytabs/spnego.service.keytab chmod 440 /etc/security/keytabs/spnego.service.keytab
On the Oozie server:
chown $OOZIE_USER:$HADOOP_GROUP /etc/security/keytabs/oozie.service.keytab chmod 400 /etc/security/keytabs/oozie.service.keytab chown root:$HADOOP_GROUP /etc/security/keytabs/spnego.service.keytab chmod 440 /etc/security/keytabs/spnego.service.keytab
On the Hue server:
chown hue:$HADOOP_GROUP /etc/security/hue.service.keytab chmod 600 /etc/security/hue.service.keytab
where
$HDFS_USERis the user owning the HDFS services. For example,hdfs.$MAPRED_USERis the user owning the MapRed services. For example,mapred.$HBASE_USERis the user owning the HBase services. For example,hbase.$ZOOKEEPER_USERis the user owning the ZooKeeper services. For example,zookeeper.$HIVE_USERis the user owning the Hive services. For example,hive.$OOZIE_USERis the user owning the Oozie services. For example,oozie.$HADOOP_GROUPis a common group shared by services. For example,hadoop.
Confirm that the correct keytab files and principals are associated with the correct service using the
klistcommand. For example, on the NameNode:klist –k -t /etc/security/nn.service.keytab
Do this on each respective service in your cluster.

![[Note]](../common/images/admon/note.png)
