在JAVA应用中远程提交MapReduce程序至Hadoop集群运行

    由于在单独的JAVA应用中,程序没有指明集群的一些配置信息,导致程序不知道集群的位置以及其他的一些信息,故首先在配置类中,即Configuration,需要指明集群的位置,配置代码如下:

    Configuration conf = new Configuration(true);
    conf.set("fs.default.name", "hdfs://master:9000");
    conf.set("hadoop.job.user", "hadoop");
    conf.set("mapreduce.framework.name", "yarn");
    conf.set("mapreduce.jobtracker.address", "master:9001");
    conf.set("yarn.resourcemanager.hostname", "master");
    conf.set("mapreduce.jobhistory.address", "master:10020");
    ToolRunner.run(conf, new MatrixMP(), null);

    上述内容主要是配置Hadoop时的部分配置内容,它指明了集群、HDFS、JOBTRACKER等的位置,最后通过ToolRunner.run()启动运行,其中MatrixMP为我们运行的MapReduce类。下述为其他可能会用到的:

    conf.set("yarn.resourcemanager.admin.address", "master:8033");
    conf.set("yarn.resourcemanager.address", "master:8032");
    conf.set("yarn.resourcemanager.resource-tracker.address", "master:8036");
    conf.set("yarn.resourcemanager.scheduler.address", "master:8030");
    conf.set("mapreduce.jobhistory.webapp.address", "master:19888");
    conf.set("yarn.application.classpath", "/home/hadoop/hadoop/etc/hadoop,"
        +"/home/hadoop/hadoop/share/ha
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值