在win7上使用eclipse上传文件到rhel的HDFS上

本文详细介绍了如何解决在配置Hadoop时遇到的`IllegalArgumentException:WrongFS`错误,以及通过指定HDFS URI和配置文件来正确访问HDFS路径的问题。包括创建配置器、加载配置文件和创建文件系统的方法,适用于Ubuntu和Win7系统。
Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS: hdfs://192.168.1.251:9000/home/hep/hadoop-hep/mapred/system/jobtracker.info, expected: file:///
最后找到错误代码行:
 

方式一-指定HDFSURI

              // 1.创建配置器
14        Configuration conf = new Configuration();
15        // 2.创建文件系统(手动指定HDFS的URI)
16        hdfs = FileSystem.get(URI.create("hdfs://192.168.1.251:9000/"), conf);

方式二-指定HDFS的配置文件

Win7系统中创建一个core-site.xml文件: 

01<?xml version="1.0"?>
02<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
03 
04<!-- Put site-specific property overrides in this file. -->
05<configuration>
06    <property>
07        <name>fs.default.name</name>
08        <!-- 指定Ubuntu的IP -->
09        <value>hdfs://192.168.1.251:9000</value>
10    </property>
11    <property>
12        <name>hadoop.tmp.dir</name>
13        <value>/home/hm/hadoop-${user.name}</value>
14    </property>
15</configuration>
// 1.创建配置器
13        Configuration conf = new Configuration();
14        // 2.加载指定的配置文件
15        conf.addResource(new Path("c:/core-site.xml"));
16        // 3.创建文件系统
17        hdfs = FileSystem.get(conf);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值