Mac OS上配置hadoop eclipse 调试环境
1. 配置Hadoop
将下载的Hadoop压缩文件解压缩,找到conf目录,打开core-site.xml,修改代码如下所示:
package cn.com.fri; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URISyntaxException; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FileContext; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.security.AccessControlException; public class Test { public static void main(String[] args) throws AccessControlException, FileNotFoundException, IOException, URISyntaxException { FileContext fc = FileContext .getFileContext();//如果运行在hadoop location中,不需要配置URI,否则需要给一个URI FSDataInputStream fsInput = fc.open(new Path( "/tmp/hadoop-alex/persons.rtf")); IOUtils.copyBytes(fsInput, System.out, 4090, false); fsInput.seek(0); IOUtils.copyBytes(fsInput, System.out, 4090, false); } }
然后右键->Run As->Run on hadoop,此时会让你选择一个location,就选中我们刚才新建的location即可。
相关推荐
minerd 2020-10-28
changjiang 2020-11-16
WeiHHH 2020-09-23
Aleks 2020-08-19
WeiHHH 2020-08-17
飞鸿踏雪0 2020-07-26
tomli 2020-07-26
deyu 2020-07-21
strongyoung 2020-07-19
eternityzzy 2020-07-19
Elmo 2020-07-19
飞鸿踏雪0 2020-07-09
飞鸿踏雪0 2020-07-04
xieting 2020-07-04
WeiHHH 2020-06-28
genshengxiao 2020-06-26
Hhanwen 2020-06-25