u011856283
你好杰米
采纳率95%
2018-06-13 07:35

sqoop1使用java报Can't get Kerberos principal renewer

10
已采纳

全部代码如下

**sqoop1使用java api过Kerberos出现Can't get Master Kerberos principal for use as renewer
**

 public class SqoopTest {

    public static void main(String[] args) throws Exception {
        // =================================================================
        Configuration conf = new Configuration();
        conf.set("fs.default.name", "hdfs://101.30.188.246:9000/");//设置HDFS服务地址
        String keytabFile = "/home/hcj/tab/hdfs.keytab";
        String principle = "hdfs@MSO.COM";
        String krbConf = "/home/hcj/krb5.conf";
        System.setProperty("java.security.krb5.conf", krbConf);
        conf.set("hadoop.security.authentication", "Kerberos");
        //conf.setBoolean("fs.hdfs.imHADOpl.disable.cache", true);
        conf.set("keytab.file", keytabFile);
        UserGroupInformation.setConfiguration(conf);
        UserGroupInformation.loginUserFromKeytab(principle, keytabFile);
        // =================================================================
        String[] arg = new String[] {
                // Oracle数据库信息

                /*
                 * sqoop export --connect  jdbc:mysql://127.0.0.1:3306/test  --username jamie  --table  
                 * persons --export-dir /user/hive/warehouse/dw_api_server.db/persons2/ 
                 * --input-fields-terminated-by '\t' --input-lines-terminated-by '\n'
                 */
                "--connect","jdbc:mysql://114.115.156.37:3306/test",
                "--username","root",
                "--password","root",
                "--table","persons",
                "--m","1",
                "--export-dir","hdfs://101.30.188.246:9000/user/hive/warehouse/dw_api_server.db/persons/",
                "--input-fields-terminated-by","\t"
                //"-columns","id,city"
        };



        String[] expandArguments = OptionsFileUtil.expandArguments(arg);
        SqoopTool tool = SqoopTool.getTool("export");

        Configuration loadPlugins = SqoopTool.loadPlugins(conf);




        Sqoop sqoop = new Sqoop((com.cloudera.sqoop.tool.SqoopTool) tool, loadPlugins);
        int res = Sqoop.runSqoop(sqoop, expandArguments);
        if (res == 0)
            System.out.println ("成功");

    }

}

报错

 java.io.IOException: Can't get Master Kerberos principal for use as renewer
    at org.apache.hadoop.mapreduce.security.TokenCache.obtainTokensForNamenodesInternal(TokenCache.java:133)
    at org.apache.hadoop.mapreduce.security.TokenCache.obtainTokensForNamenodesInternal(TokenCache.java:100)
    at org.apache.hadoop.mapreduce.security.TokenCache.obtainTokensForNamenodes(TokenCache.java:80)
    at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:166)
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1290)
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1287)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1866)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:1287)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1308)
    at org.apache.sqoop.mapreduce.ExportJobBase.doSubmitJob(ExportJobBase.java:322)
    at org.apache.sqoop.mapreduce.ExportJobBase.runJob(ExportJobBase.java:299)
    at org.apache.sqoop.mapreduce.ExportJobBase.runExport(ExportJobBase.java:440)
    at org.apache.sqoop.manager.SqlManager.exportTable(SqlManager.java:931)
    at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:80)
    at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:99)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
    at com.mshuoke.datagw.impl.sqoop.SqoopTest.main(SqoopTest.java:58)

求解

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐