Connect to Multiple Kerberos Realms
A VeloDB Cloud warehouse can query external Hadoop data sources that use different Kerberos realms and credentials. Coordinate the managed runtime and network requirements with VeloDB Cloud support before using this workflow for a SaaS or BYOC warehouse. Prepare credentials through an approved secure transfer path; do not put keytab contents or secrets in support tickets or SQL examples.
Take a large fund company as an example. Its internal data platform is divided into multiple functional clusters, maintained by different technical or business teams, each configured with independent Kerberos Realms for identity authentication and access control:
- Production cluster is used for daily net asset value calculations and risk assessments, with strictly isolated data that only allows authorized service access (Realm: PROD.FUND.COM).
- Analysis cluster is used for strategy research and model backtesting, where VeloDB Cloud implements temporary queries to this cluster through TVF (Realm: ANALYSIS.FUND.COM).
- Data lake cluster integrates Iceberg Catalog for archiving and analyzing large volumes of historical market data, logs, and other data (Realm: LAKE.FUND.COM).
Since these clusters have not established cross-domain trust relationships and authentication information cannot be shared, unified access to these heterogeneous data sources requires simultaneous support for authentication and context management of multiple Kerberos instances.
This document focuses on how to configure and access data sources in multi-Kerberos environments.
Note:
The authentication workflow described here is present in Core 26.1.3. Filesystem paths in catalog properties refer to the managed query runtime, not your laptop. Obtain the installed keytab paths from VeloDB Cloud support.
Configure multiple Kerberos realms
krb5.conf
krb5.conf contains Kerberos configuration information, KDC locations, some default values for Kerberos services, and hostname-to-Realm mapping information.
Prepare one krb5.conf that describes all required realms. Your external Hadoop administrators configure their own hosts. Coordinate installation and runtime paths on the VeloDB Cloud side with VeloDB Cloud support; warehouse users do not copy files into managed query nodes.
Realm definitions
Contains KDC and Kerberos networks of many clients, such as EXAMPLE.COM.
When configuring multiple clusters, you need to configure multiple Realms in one krb5.conf. KDC and admin_server can also be domain names.
[realms]
EMR-IP.EXAMPLE = {
kdc = <kdc-host>:88
admin_server = <kdc-host>
}
EMR-HOST.EXAMPLE = {
kdc = emr_hostname
admin_server = emr_hostname
}
Domain-to-realm mappings
Configures the mapping from domain to Realm for nodes where Kerberos services are located.
[libdefaults]
dns_lookup_realm = true
dns_lookup_kdc = true
[domain_realm]
<kdc-host> = EMR-IP.EXAMPLE
emr-host.example = EMR-HOST.EXAMPLE
For example, for principal emr1/domain_name@realm.com, when looking up KDC, use domain_name to find the corresponding Realm. If it doesn't match, the KDC for the Realm cannot be found.
You will typically see two types of errors in VeloDB Cloud's log/be.out or log/fe.out that are related to domain_realm:
* Unable to locate KDC for realm/Cannot locate KDC
* No service creds
Keytabs and principals
In multi-Kerberos cluster environments, keytab files usually use different paths, such as: /path/to/serverA.keytab, /path/to/serverB.keytab. When accessing different clusters, you need to use the corresponding keytab.
If the HDFS cluster has Kerberos authentication enabled, you can generally see the hadoop.security.auth_to_local property in the core-site.xml file, which is used to map Kerberos principals to shorter local usernames, and Hadoop reuses Kerberos syntax rules.
If not configured, you may encounter a NoMatchingRule("No rules applied to exception. See code:
Hadoop Kerberos name-mapping documentation
The hadoop.security.auth_to_local parameter contains a set of mapping rules that match principals against RULEs from top to bottom. When a matching mapping rule is found, it outputs a username and ignores unmatched rules. The specific configuration format:
RULE:[<principal translation>](acceptance filter)<short name substitution>
To match principals used by different Kerberos services in multi-cluster environments, the recommended configuration is:
<property>
<name>hadoop.security.auth_to_local</name>
<value>RULE:[1:$1@$0](^.*@.*$)s/^(.*)@.*$/$1/g
RULE:[2:$1@$0](^.*@.*$)s/^(.*)@.*$/$1/g
DEFAULT</value>
</property>
The mapping can be supplied as a supported catalog or operation property below. If the integration instead needs a runtime-wide core-site.xml setting, coordinate that managed configuration with VeloDB Cloud support.
If you need it to take effect separately in OUTFILE, EXPORT, Broker Load, Catalog (Hive, Iceberg, Hudi), TVF, and other functions, you can configure it directly in their properties:
"hadoop.security.auth_to_local" = "RULE:[1:$1@$0](^.*@.*$)s/^(.*)@.*$/$1/g
RULE:[2:$1@$0](^.*@.*$)s/^(.*)@.*$/$1/g
DEFAULT"
To verify whether mapping rules can match correctly, check if this error occurs when accessing different clusters:
NoMatchingRule: No rules applied to hadoop/domain\_name@EMR-REALM.COM
If it appears, it indicates unsuccessful matching.
Use the external Kerberos lab
The upstream Apache Doris Docker environment starts two external Hive/HDFS and KDC environments for a local lab. Run these external services on a host you manage, then configure the warehouse with network-reachable endpoints and managed keytab paths. The original loopback addresses in that lab are not warehouse endpoints.
Lab environment
-
The upstream lab provides two Hive/HDFS environments and two KDC services:
-
Docker startup directory:
docker/thirdparties -
krb5.conf template:
-
1. Prepare keytab files and permissions
On a secure external administration host, prepare the two keytab files. Coordinate their managed installation and permissions with VeloDB Cloud support. The local preparation commands are:
mkdir -p ~/doris-keytabs
cp <hive-presto-master.keytab> ~/doris-keytabs/
cp <other-hive-presto-master.keytab> ~/doris-keytabs/
Set file permissions to prevent authentication failure:
chmod 400 ~/doris-keytabs/*.keytab
2. Prepare krb5.conf file
-
Use the
krb5.conftemplate from the upstream Apache Doris lab -
If you need to access multiple Kerberos HDFS clusters simultaneously, you need to merge krb5.conf, with basic requirements:
-
[realms]: Write Realms and KDC IPs for all clusters. -
[domain_realm]: Write domain or IP to Realm mappings. -
[libdefaults]: Use encryption algorithms allowed by your KDC and security policy, such as supported AES ciphers. Do not enable weak cryptography to make a sample work.
-
-
Example:
[libdefaults]default_realm = LABS.TERADATA.COMdns_lookup_realm = truedns_lookup_kdc = true[realms]LABS.TERADATA.COM = {kdc = 127.0.0.1admin_server = 127.0.0.1}OTHERREALM.COM = {kdc = 127.0.0.1admin_server = 127.0.0.1}[domain_realm]presto-master.docker.cluster = LABS.TERADATA.COMhadoop-master-2 = OTHERREALM.COM.labs.teradata.com = LABS.TERADATA.COM.otherrealm.com = OTHERREALM.COM -
Copy
krb5.confto the corresponding Docker directory:cp doris-krb5.conf ~/doris-kerberos/krb5.conf
3. Start Docker Kerberos environment
-
Enter directory:
cd docker/thirdparties -
Start Kerberos environment:
./run-thirdparties-docker.sh -c kerberos -
Services after startup include:
- Hive Metastore 1:9583
- Hive Metastore 2:9683
- HDFS 1:8520
- HDFS 2:8620
4. Get container IP
Use command to view Docker IP:
docker inspect <container-name> | grep IPAddress
Use a hostname or address reachable from the warehouse, and expose the required metastore, HDFS, and KDC ports. 127.0.0.1 identifies the querying host itself and does not reach your external Docker host.
5. Create Kerberos Hive Catalog
-
Create the first Hive catalog.
CREATE CATALOG IF NOT EXISTS multi_kerberos_onePROPERTIES ("type" = "hms","hive.metastore.uris" = "thrift://<first-metastore-host>:9583","fs.defaultFS" = "hdfs://<first-hdfs-host>:8520","hadoop.kerberos.min.seconds.before.relogin" = "5","hadoop.security.authentication" = "kerberos","hadoop.kerberos.principal" = "hive/presto-master.docker.cluster@LABS.TERADATA.COM","hadoop.kerberos.keytab" = "<first-managed-keytab-path>","hive.metastore.sasl.enabled" = "true","hadoop.security.auth_to_local" = "RULE:[2:$1@$0](.*@LABS.TERADATA.COM)s/@.*//RULE:[2:$1@$0](.*@OTHERLABS.TERADATA.COM)s/@.*//RULE:[2:$1@$0](.*@OTHERREALM.COM)s/@.*//DEFAULT","hive.metastore.kerberos.principal" = "hive/hadoop-master@LABS.TERADATA.COM"); -
Create the second Hive catalog.
CREATE CATALOG IF NOT EXISTS multi_kerberos_twoPROPERTIES ("type" = "hms","hive.metastore.uris" = "thrift://<second-metastore-host>:9683","fs.defaultFS" = "hdfs://<second-hdfs-host>:8620","hadoop.kerberos.min.seconds.before.relogin" = "5","hadoop.security.authentication" = "kerberos","hadoop.kerberos.principal" = "hive/presto-master.docker.cluster@OTHERREALM.COM","hadoop.kerberos.keytab" = "<second-managed-keytab-path>","hive.metastore.sasl.enabled" = "true","hadoop.security.auth_to_local" = "RULE:[2:$1@$0](.*@OTHERREALM.COM)s/@.*//RULE:[2:$1@$0](.*@OTHERLABS.TERADATA.COM)s/@.*//DEFAULT","hive.metastore.kerberos.principal" = "hive/hadoop-master-2@OTHERREALM.COM");
Replace the sample principals and realm mapping rules with the identities issued by your KDC administrators. Query a permitted table through each catalog to verify that its own credentials and realm configuration work.
Test external connectivity
For verifying connectivity to external dependencies such as Kerberos, the open-source tool Pulse can be used.
Pulse is an independent open-source connectivity testing tool. For usage instructions, installation details, and release information, please refer to the project documentation.
- Documentation: Kerberos Connectivity Tool
- Release package: Kerberos Connectivity Tool v1.0.0
Common errors
For errors from a warehouse query, provide the query ID and error text to VeloDB Cloud support. The credential, DNS, clock, and KDC checks below apply to external systems you manage; VeloDB Cloud support handles Java configuration, managed host files, and service restarts. Do not change managed runtime files yourself.
-
javax.security.sasl.SaslException: No common protection layer between client and server
- Cause: The client's
hadoop.rpc.protectiondiffers from the HDFS cluster setting. - Fix: Align
hadoop.rpc.protectionbetween the client and HDFS server.
- Cause: The client's
-
No valid credentials provided (Mechanism level: Illegal key size)
- Cause: A restricted or older Java cryptography configuration can reject the encryption key size. This is not a universal restriction of current Java runtimes.
- Fix: Ask the administrator of the affected runtime to check its cryptography policy; involve VeloDB Cloud support for a managed warehouse runtime.
-
Encryption type AES256 CTS mode with HMAC SHA1-96 is not supported/enabled
- Cause: The current Java environment lacks AES256 support while Kerberos may use it.
- Fix: Align the KDC and client cipher policies using supported encryption types. Involve VeloDB Cloud support for the managed warehouse runtime.
-
No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)
- Cause: Kerberos cannot find a valid Ticket Granting Ticket (TGT). In a previously working setup, the ticket expired or the KDC restarted. In a new setup,
krb5.confor the keytab is incorrect or corrupted. - Fix: Verify
krb5.confand the keytab, ensure tickets are valid, and trykinitto obtain a new ticket.
- Cause: Kerberos cannot find a valid Ticket Granting Ticket (TGT). In a previously working setup, the ticket expired or the KDC restarted. In a new setup,
-
Failure unspecified at GSS-API level (Mechanism level: Checksum failed)
- Cause: GSS-API checksum failure; wrong password used with
kinit; keytab is invalid or has an outdated key version so JVM falls back to password login. - Fix: Use the correct password with
kinitand ensure the keytab is current and valid.
- Cause: GSS-API checksum failure; wrong password used with
-
Receive timed out
- Cause: Using UDP to talk to the KDC on unstable networks or with large packets.
- Fix: Force Kerberos to use TCP by adding in
/etc/krb5.conf:
[libdefaults]
udp_preference_limit = 1
-
javax.security.auth.login.LoginException: Unable to obtain password from user
- Cause: Principal does not match the keytab, or the application cannot read
krb5.confor the keytab. - Fix:
- Use
klist -kt <keytab_file>andkinit -kt <keytab_file> <principal>to validate the keytab and principal. - Check paths and permissions for
krb5.confand the keytab so the runtime user can read them. - Ensure JVM startup options specify the correct config paths.
- Use
- Cause: Principal does not match the keytab, or the application cannot read
-
Principal not found or Could not resolve Kerberos principal name
- Causes:
- The hostname in the principal cannot be resolved.
- The
_HOSTplaceholder expands to a hostname unknown to the KDC. - DNS or
/etc/hostsis misconfigured.
- Fix:
- Verify the principal spelling.
- Check DNS and hostname mappings on your external services; ask VeloDB Cloud support to check resolution from the warehouse runtime.
- Causes:
-
Cannot find KDC for realm "XXX"
- Cause: The specified realm has no KDC configured in
krb5.conf. - Fix:
- Check the realm name under
[realms]. - Confirm the
kdcaddress. - Coordinate any managed runtime reload or restart with VeloDB Cloud support.
- Check the realm name under
- Cause: The specified realm has no KDC configured in
-
Request is a replay
- Cause: KDC thinks the auth request is duplicated. Typical reasons: clock skew across nodes or multiple services sharing the same principal.
- Fix:
- Enable NTP on all nodes to keep time in sync.
- Use unique principals per service instance, such as
service/_HOST@REALM, to avoid sharing.
- Client not found in Kerberos database
- Cause: The client principal does not exist in the Kerberos database.
- Fix: Create the principal in the KDC.
- Message stream modified (41)
- Cause: Known issue for certain OS (e.g., CentOS 7) with Kerberos/Java combinations.
- Fix: Apply vendor patches or security updates.
- Pre-authentication information was invalid (24)
- Causes:
- Invalid pre-auth data.
- Clock skew between client and KDC.
- JDK cipher configuration mismatches the KDC.
- Fix:
- Sync time across all nodes.
- Align cipher configurations.
Clean up the external lab
Stop the Docker test services after use, and remove only lab credentials and data that are no longer needed. Delete temporary copies of keytabs through your credential-handling process. Warehouse queries use compute; see Billing Overview.