Troubleshooting the Kerberos Configuration Issues in Ambari
This documentation provides detailed guidance to diagnose and resolve the Kerberos configuration issues in Ambari. It is intended to support both technical teams and system administrators in efficiently troubleshooting failures when disabling Kerberos or when the service is missing or partially uninstalled.
This troubleshooting page aims to provide a structured approach to:
- Quickly identify and diagnose common Kerberos issues in Ambari.
- Systematically resolve problems by using detailed log analysis, DNS validation, connectivity checks, and service restoration commands.
- Streamline the support process by including clear steps and commands to address the Kerberos-related failures.
- Minimize downtime by enabling technical teams to act on issues without needing extensive external support.
Issue Overview
- Kerberos Disable Failure: Service startup might be affected if the process to disable Kerberos in Ambari is not completed successfully.
- Kerberos Service Missing: In some cases, even if the disable operation appears partially successful, the Kerberos service might be removed from the cluster configuration.
The following steps outline the procedures to identify the root cause, correct configuration issues, and restore the Kerberos setup.
Verify the Kerberos Disable Failure
Check the Ambari UI and Server Logs:
- Ambari UI: Navigate to the Ambari Operations (OPS) section and look for the failed operation that indicates the Kerberos disable failure.
- Ambari Server Logs: Check the Ambari server logs (
/var/log/ambari-server/ambari-server.log
) to identify the cause of the failure. Look for errors related to Kerberos operations or authentication issues. - Possible Cause: If the issue is related to authentication failure (e.g., Authfailed in the Zookeeper zone), it may be necessary to temporarily add the
skipacl
property to bypass the ACL checks.
Fix Kerberos Disable Failure:
- If the Kerberos disable fails due to an authentication issue, perform the following steps to add the
skipacl
property. Once Kerberos is successfully disabled, you can remove theskipacl
setting.
- If the Kerberos disable fails due to an authentication issue, perform the following steps to add the
Check the DNS Configuration: Ensure that all nodes in the cluster have correct DNS settings, as DNS issues can significantly affect the Kerberos authentication.
Forward and Reverse DNS Lookups:
- Verify the hostname to IP address resolution:
nslookup <hostname>
- Verify the IP address to hostname resolution:
nslookup <IP-address>
- Verify the hostname to IP address resolution:
Hostname Consistency:
- Ensure that the reverse DNS lookup result matches the fully qualified domain name (FQDN) used by the Kerberos service.
Update /etc/hosts (if necessary): If DNS inconsistencies are found, update the
/etc/hosts
file on each node to include accurate IP-to-hostname mappings to ensure smooth communication.
Configure the Database Adjustments:
Set Security Type to Kerberos
- Log in to the Ambari database and check the current security type:
SELECT security_type FROM clusters;.
- Update the security type to Kerberos:
UPDATE clusters SET security_type='KERBEROS';.
- Log in to the Ambari database and check the current security type:
Update the
kerberos-env
Configuration:- Check the current configuration for
kerberos-env
:SELECT version_tag, type_name, selected, create_timestamp FROM clusterconfig WHERE type_name = 'kerberos-env';.
- Update to the latest version tag for kerberos-env:
- Check the current configuration for
SET @latest_version_tag := (
SELECT version_tag
FROM clusterconfig
WHERE type_name = 'kerberos-env'
ORDER BY create_timestamp DESC
LIMIT 1
);
UPDATE clusterconfig
SET selected = 1
WHERE type_name = 'kerberos-env' AND version_tag = @latest_version_tag;
- Update the
krb5-conf
Configuration:- Check the current configuration for
krb5-conf
:SELECT
version_tag, type_name, selected, create_timestamp
FROM
clusterconfig
WHERE
type_name = 'krb5-conf';.
- Update to the latest version tag for
krb5-conf
:
- Check the current configuration for
SET @latest_version_tag := (
SELECT version_tag
FROM clusterconfig
WHERE type_name = 'krb5-conf'
ORDER BY create_timestamp DESC
LIMIT 1
);
UPDATE clusterconfig
SET selected = 1
WHERE type_name = 'krb5-conf' AND version_tag = @latest_version_tag;
Restart the Ambari Server
After updating the configurations, restart the Ambari Server to apply the changes.
ambari-server restart
Adding the Kerberos Service using the Curl Commands
- Retrieve the Cluster Name Automatically: Use the following command to dynamically retrieve the cluster name and store it in a variable to be used in the subsequent steps:
# Retrieve the cluster name dynamically
CLUSTER_NAME=$(curl -s -u admin:admin -H 'X-Requested-By: ambari' -X GET http://$(hostname -f):8080/api/v1/clusters | grep -oP '(?<="cluster_name" : ")[^"]*')
# Check if the cluster name was retrieved successfully
if [ -z "$CLUSTER_NAME" ]; then
echo "Error: Could not retrieve the cluster name. Please check Ambari connectivity."
exit 1
else
echo "Cluster Name: $CLUSTER_NAME"
fi
- Add the Kerberos Service and Components: Execute the following curl commands to add the Kerberos service back to your cluster using the automatically retrieved cluster name.
# Add Kerberos service to the cluster
curl -u admin:admin -i -H "X-Requested-By: ambari" -X POST -d '{"ServiceInfo":{"service_name":"KERBEROS"}}' http://$(hostname -f):8080/api/v1/clusters/$CLUSTER_NAME/services
# Add Kerberos client component to the service
curl -u admin:admin -H "X-Requested-By: ambari" -X POST http://$(hostname -f):8080/api/v1/clusters/$CLUSTER_NAME/services/KERBEROS/components/KERBEROS_CLIENT
# Get the list of hosts and save to a file
curl -s -u admin:admin http://$(hostname -f):8080/api/v1/hosts | grep host_name | sed -n 's/.*"host_name" : "\([^\"]*\)".*/\1/p' > hostcluster.txt
# Add Kerberos client component to each host in the cluster
for i in $(cat hostcluster.txt); do
curl -u admin:admin -H "X-Requested-By: ambari" -X POST http://$(hostname -f):8080/api/v1/clusters/$CLUSTER_NAME/hosts/$i/host_components/KERBEROS_CLIENT;
done
Ex:
curl -H "X-Requested-By:ambari" -u admin:admin -X POST -d '{ "Credential" : { "principal" : "admin/admin@DOMAIN.COM", "key" : "PASSW0RD", "type" : "temporary" } }' http://$(hostname -f):8080/api/v1/clusters/$CLUSTER_NAME/credentials/kdc.admin.credential
Setting Up the Temporary KDC Credentials: To proceed with further Kerberos operations, follow these steps to set up temporary KDC credentials:
Access the Ambari UI:
- Navigate to HOSTS.
- Go to the Kerberos Client section.
- Click on Install.
Store Kerberos Credentials:
- This process prompts you for Kerberos credentials.
- Once the credentials are successfully stored in Ambari, proceed with the following command.
# Retrieve the cluster name dynamically
CLUSTER_NAME=$(curl -s -u admin:admin -H 'X-Requested-By: ambari' -X GET http://$(hostname -f):8080/api/v1/clusters | grep -oP '(?<="cluster_name" : ")[^"]*')
# Check if the cluster name was retrieved successfully
if [ -z "$CLUSTER_NAME" ]; then
echo "Error: Could not retrieve the cluster name. Please check Ambari connectivity."
exit 1
else
echo "Cluster Name: $CLUSTER_NAME"
fi
Final Step: Adding the Clients back to the Ambari UI
After setting up the temporary KDC credentials, execute the following commands to add the clients back to the Ambari UI:
# Set the host components state to INSTALLED
curl -u admin:admin -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state":"INSTALLED"}}' http://$(hostname -f):8080/api/v1/clusters/$CLUSTER_NAME/host_components?HostRoles/state=INIT
# optional
# Set the cluster's security type back to Kerberos and regenerate keytabs
curl -u admin:admin -H "X-Requested-By: ambari" -X PUT \
-d '{"Clusters": {"security_type": "KERBEROS"}}' \
http://$(hostname -f):8080/api/v1/clusters/$CLUSTER_NAME?regenerate_keytabs=all
Conclusion
This documentation provides a step-by-step approach to resolve the Kerberos configuration issues in Ambari. It includes automated steps to fetch the cluster name, diagnose the failure to disable Kerberos, correct the database settings, restore the Kerberos service, and ensure that all necessary components are added back to the cluster.
If these steps do not fully resolve the issue, further investigation into Ambari server logs and network settings might be necessary.
Additional Troubleshooting Steps
Do the detailed Log Analysis
Check the Ambari Server Logs
- The location of logs:
/var/log/ambari-server/ambari-server.log
- Look for specific error messages related to the Kerberos setup or service failures.
- Common errors to search for:
- Authfailed
- Kerberos authentication failed
- Unable to communicate with KDC
- The location of logs:
Check the Kerberos Client Logs
- The Kerberos client logs might contain valuable information if the client fails to communicate with the KDC.
- The location of logs:
/var/log/krb5kdc.log and /var/log/kadmin.log
on the KDC server. - Search for errors related to authentication, ticket expiration, or encryption.
Validate the Kerberos Ticket Granting
Check Kerberos Ticket Availability
- Ensure that a valid Kerberos ticket is available for the current session.
- Use the this command to check if a ticket is present:
klist
- If no ticket is listed, obtain a new Kerberos ticket using:
kinit admin/admin@YOUR_REALM
- If ticket acquisition fails, it may indicate an issue with the KDC or the credentials provided.
Check Keytab File Permissions
- Verify that the keytab files have the correct permissions and are accessible to the Ambari services.
- The common keytab file locations:
/etc/security/keytabs/.
- Ensure that the permissions allow the Ambari user to access these files:
ls -l /etc/security/keytabs/.
Verify the Network Connectivity
Verify the connectivity to KDC
- Ensure that all nodes can communicate with the Kerberos Key Distribution Center (KDC).
- Use the this command to check connectivity:
nc -zv <
KDC-Hostname
> 88.
The port 88 is the default port for Kerberos communication. - If connectivity fails, check the firewall settings or network restrictions between nodes.
Validate the DNS Configuration
- Ensure that all nodes in the cluster have proper DNS resolution, as Kerberos heavily relies on DNS.
- Forward and Reverse the DNS Lookups.
nslookup <hostname>
nslookup <IP-address>
Make sure that both forward and reverse DNS lookups return the consistent results.
Verify the Ambari Configuration
Confirm the Kerberos Properties in Ambari:
- Validate that the Kerberos-related properties are correctly configured in Ambari.
- Navigate to Ambari Web UI > Admin > Kerberos and check the following properties:
- KDC Host
- Realm Name
- Kadmin Host
- Encryption Types
Check for the Missing or Incorrect Kerberos Components:
- Ensure that all necessary components are installed:
- Kerberos client packages (krb5-workstation, krb5-libs)
- Proper entries in
/etc/krb5.conf
- Ensure that all necessary components are installed:
Synchronize the Time across Nodes:
- The Time synchronization is critical for the Kerberos authentication.
- Use ntp or chrony to ensure that all nodes in the cluster have synchronized clocks:
ntpq -p.
- The difference in time between nodes can cause the Kerberos ticket validation errors.
Common Kerberos Configuration Issues for MIT KDC
Check for Duplicate Service Principal Names (SPNs):
- Duplicate SPNs can cause authentication failures.
- List all principals in the KDC database:
kadmin.local -q "listprincs".
- Ensure that there are no duplicate entries for the same service.
Validate the Encryption Types:
- Verify that the encryption types used by Kerberos are compatible with your cluster's security settings.
- Check the supported encryption types in /etc/krb5.conf:
[libdefaults]
default_tkt_enctypes = aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96
default_tgs_enctypes = aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96
- Re-initializing the Kerberos Configuration in Ambari
- Reset and reconfigure kerberos in Ambari: If other troubleshooting steps fail, it might be necessary to completely re-initialize the Kerberos configuration in Ambari:
- Disable Kerberos in Ambari from the Admin > Kerberos section.
- Remove Kerberos-related configurations from
/etc/krb5.conf and /etc/security/keytabs/
. - Re-enable Kerberos in Ambari using the setup wizard to ensure that all necessary configurations are applied correctly.
- Reset and reconfigure kerberos in Ambari: If other troubleshooting steps fail, it might be necessary to completely re-initialize the Kerberos configuration in Ambari: