我已经设置了 Hadoop 2.2.0 单节点并启动了它。我可以浏览 FShttp://localhost:50070/
然后我尝试使用以下代码编写一个虚拟文件。
public class Test {
public void write(File file) throws IOException{
FileSystem fs = FileSystem.get(new Configuration());
Path outFile = new Path("test.jpg");
FSDataOutputStream out = fs.create(outFile);
}
我得到以下异常
INFO: DEBUG - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginSuccess with annotation @org.apache.hadoop.metrics2.annotation.Metric(valueName=Time, value=[Rate of successful kerberos logins and latency (milliseconds)], about=, type=DEFAULT, always=false, sampleName=Ops)
INFO: DEBUG - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginFailure with annotation @org.apache.hadoop.metrics2.annotation.Metric(valueName=Time, value=[Rate of failed kerberos logins and latency (milliseconds)], about=, type=DEFAULT, always=false, sampleName=Ops)
INFO: DEBUG - UgiMetrics, User and group related metrics
INFO: DEBUG - Creating new Groups object
INFO: DEBUG - Trying to load the custom-built native-hadoop library...
INFO: DEBUG - Failed to load native-hadoop with error: java.lang.UnsatisfiedLinkError: no hadoop in java.library.path
INFO: DEBUG - java.library.path=/usr/lib/jvm/jdk1.7.0/jre/lib/amd64:/usr/lib/jvm/jdk1.7.0/jre/lib/i386::/usr/java/packages/lib/i386:/lib:/usr/lib
INFO: WARN - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
INFO: DEBUG - Falling back to shell based
INFO: DEBUG - Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping
INFO: DEBUG - Group mapping impl=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback; cacheTimeout=300000
INFO: DEBUG - hadoop login
INFO: DEBUG - hadoop login commit
INFO: DEBUG - using local user:UnixPrincipal: qualebs
INFO: DEBUG - UGI loginUser:qualebs (auth:SIMPLE)
INFO: DEBUG - Failed to detect a valid hadoop home directory
java.io.IOException: HADOOP_HOME or hadoop.home.dir are not set.
at org.apache.hadoop.util.Shell.checkHadoopHome(Shell.java:225)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:250)
at
org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:639)
at org.apache.hadoop.fs.FilterFileSystem.setPermission(FilterFileSystem.java:468)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:456)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:424)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:905)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:886)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:783)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:772)
at com.qualebs.managers.HadoopDFS.writer(HadoopDFS.java:41)
我在哪里设置 HADOOP_HOME 或 hadoop.home.dir?操作系统是 Ubuntu 11.10
我配置的唯一配置文件如下,添加了属性
- 核心站点.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
- hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
- mapred-site.xml.template
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
热切期待您的回复。