我的程序使用kerberos身份验证连接到配置单元并从配置单元获取查询结果。
工作流程目录(HDFS):
| lib/javaCode.jar
| workflow.xml
| jaas.conf
| job.properties
在workflow.xml中的我的Java动作
<action name="run_java_script" cred="hcat_creds">
<java>
<configuration>
<property>
<name>mapreduce.job.queuename</name>
<value>${queueName}</value>
</property>
</configuration>
<main-class>GetData</main-class>
<arg>${filepath}</arg>
<arg>${url}</arg>
</java>
<ok to="end" />
<error to="end" />
</action>
我的Job.properties文件是正确的。
的Jaas.conf
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
useTicketCache=true
principal="host@EXAMPLE.COM"
doNotPrompt=true
keyTab="path_to_keytab/hos.keytab"
debug=true;
};
GetData.java
public class GetData extends Configured implements Tool {
public static void main(String[] args) throws Exception {
int res = ToolRunner.run(new Configuration(), new GetData(), args);
System.exit(res);
}
@Override
public int run(String[] args) throws Exception {
String jaas_file = args[0];
String url_connect = args[1];
Class.forName("org.apache.hive.jdbc.HiveDriver");
System.setProperty("java.security.auth.login.config", jaas_file);
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
System.out.println("getting connection");
String JDBC_DB_URL = url_connect;
Connection con = DriverManager.getConnection(JDBC_DB_URL);
System.out.println("got connection");
Statement stmt = con.createStatement();
System.out.println(execute(con, "show databases"));
con.close();
return 0;
}
public static String execute(Connection connection, String query) throws SQLException {
// Code to execute
}
}
Oozie工作流程stdout:
>>> Invoking Main class now >>>
Fetching child yarn jobs
tag id : oozie-TagID
Child yarn jobs are found -
Main class : GetData
Arguments :
jaas.conf
URL
getting connection
<<< Invocation of Main class completed <<<
我没有得到任何结果因为我的Jaas.conf应该在FileSystem中不在HDFS上。当Jass.conf在FileSystem上时,我的程序运行得非常好。有没有办法从HDFS访问jaas.conf而不是将其复制到我的文件系统?