一个Java应用如何连接两个独立的、使用Kerberos认证的Hadoop集群?

目前项目中需要连接两个不同的带认证的Hadoop集群,但是每次只能连接到一个集群,另一个集群总是认证失败,代码如下:

 public Configuration getConf(int platform) throws IOException {
        if (platform == 1 || platform == 3) {
            return initConfiguration(A_CLUSTER_CONFIG_PATH);
        } else {
            return initConfiguration(B_CLUSTER_CONFIG_PATH);
        }
    }

    private Configuration initConfiguration(String clusterConfigPath) {
        System.setProperty("java.security.krb5.conf", clusterConfigPath + "krb5.conf");
        conf = new Configuration();
        conf.set("hadoop.security.authentication", "Kerberos");
        conf.addResource(new Path(clusterConfigPath + "core-site.xml"));
        conf.addResource(new Path(clusterConfigPath + "hdfs-site.xml"));
        conf.set("fs.hdfs.impl", DistributedFileSystem.class.getName());
        conf.setBoolean("fs.hdfs.impl.disable.cache", true);
        kerberosAuthentication(conf, clusterConfigPath + "hiveConfig.properties", clusterConfigPath + "bd_user.keytab");
        return conf;
    }

    private void kerberosAuthentication(Configuration conf, String propPath, String keytabPath) {
        try {
            UserGroupInformation.setConfiguration(conf);
            PropertiesUtil.loadFromFileSystem(propPath);
            UserGroupInformation.loginUserFromKeytab(PropertiesUtil.getString("hadoop.kerberos.principal"), keytabPath);
        } catch (IOException e) {
            LogBetter.instance(LOGGER).setLevel(LogLevel.ERROR).setMsg("[ClusterConnectionManager]:Hadoop认证失败").setException(e).log();
        }
    }
两个集群的krb5.conf中的default_realm不一样吗?

java kerberos会读/etc/krb5.conf里的default_realm, 还有报啥错你也没说

大佬,解决了吗?

大佬,解决了吗??

大佬,解决了吗??