客户端无法通过[TOKEN,KERBEROS]进行身份验证



我正在使用YarnClient以编程方式启动作业。我运行的集群已被kerberos化。

普通地图减少通过"yarn jar examples.jar wordcount…"工作提交的作业。

我尝试以编程方式提交的作业没有。我得到这个错误:

14/09/04 21:14:29错误客户端。ClientService:提交应用程序期间发生错误:应用程序application_1409863263326_0002失败2次,原因是appattempt_1409863263326/0002_ 000002的AM容器退出exitCode:-1000,原因是:本地异常java.io.IOException:org.apache.hadoop.security.AccessControlException:客户端无法通过[TOKEN,KERBEROS]进行身份验证;主机详细信息:本地主机为:"yarn-c1-n1.clouddev.snaplogic.com/10.184.28.108";目标主机为:"yarn-c1-cdh.clouddev.snaplogic.com":8020;。尝试失败。。应用程序失败。14/09/04 21:14:29错误客户端。YClient:应用程序提交失败

代码看起来像这样:

ClientContext context = createContextFrom(args);
YarnConfiguration configuration = new YarnConfiguration();
YarnClient yarnClient = YarnClient.createYarnClient();
yarnClient.init(configuration);
ClientService client = new ClientService(context, yarnClient, new InstallManager(FileSystem.get(configuration)));
LOG.info(Messages.RUNNING_CLIENT_SERVICE);
boolean result = client.execute();

我曾想过,也许会在的效果上添加一些东西

yarnClient.getRMDelegationToken(new Text(InetAddress.getLocalHost().getHostAddress()));

也许可以减轻我的痛苦,但这似乎也无济于事。如有任何帮助,我们将不胜感激。

好吧,经过一个小时又一个小时,我们已经弄清楚了。对于接下来的几代程序员,他们一直受到hadoop缺乏文档的困扰:

您必须通过调用从UserGroupInformation对象获取令牌以获取凭据。然后必须在ContainerLaunchContext上设置标记。

不兼容的hadoop工件版本也出现了同样的错误。

工作示例:

public static final String CONF_CORE_SITE = "/etc/hadoop/conf/core-site.xml";
public static final String CONF_HDFS_SITE = "/etc/hadoop/conf/hdfs-site.xml";
/**
 * Pick the config files from class path
 */
private static Configuration getHdfsConfiguration() throws IOException {
    Configuration configuration = new Configuration();
    configuration.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
    configuration.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
    File hadoopCoreConfig = new File(CONF_CORE_SITE);
    File hadoopHdfsConfig = new File(CONF_HDFS_SITE);
    if (! hadoopCoreConfig.exists() || ! hadoopHdfsConfig.exists()) {
        throw new FileNotFoundException("Files core-site.xml or hdfs-site.xml are not found. Check /etc/hadoop/conf/ path.");
    }
    configuration.addResource(new Path(hadoopCoreConfig.toURI()));
    configuration.addResource(new Path(hadoopHdfsConfig.toURI()));
    //Use existing security context created by $ kinit
    UserGroupInformation.setConfiguration(configuration);
    UserGroupInformation.loginUserFromSubject(null);
    return configuration;
}

pom.xml

<properties>
  <hadoop.version>2.6.0</hadoop.version>
  <hadoop.release>cdh5.14.2</hadoop.release>
</properties>

<dependency>
  <groupId>org.apache.hadoop</groupId>
  <artifactId>hadoop-core</artifactId>
  <version>${hadoop.version}-mr1-${hadoop.release}</version>
</dependency>
<dependency>
  <groupId>org.apache.hadoop</groupId>
  <artifactId>hadoop-hdfs</artifactId>
  <version>${hadoop.version}-${hadoop.release}</version>
</dependency>
<dependency>
  <groupId>org.apache.hadoop</groupId>
  <artifactId>hadoop-common</artifactId>
  <version>${hadoop.version}-${hadoop.release}</version>
</dependency>

如果在任何hdfs路径中使用实际名称节点而不是HA的逻辑URI,也会出现此错误。

这是因为,如果它找到了namenode uri而不是逻辑uri,那么它将创建非HA文件系统,该系统将尝试使用简单的UGI而不是kerberos UGI。

相关内容

最新更新