Java代码
1. <?xml version="1.0"?> 2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> 3. 4. <!-- Put site-specific property overrides in this file. --> 5. 6. <configuration> 7. <property> 8. <name>hadoop.tmp.dir</name> 9. <value>/home/hadoop/hadoop-datastore/hadoop-${user.name}</value> 10. </property> 11. <property> 12. <name>fs.default.name</name> 13. <value>hdfs://localhost:9000</value> 14. </property> 15. </configuration> <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>hadoop.tmp.dir</name> <value>/home/hadoop/hadoop-datastore/hadoop-${user.name}</value> </property> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> </configuration> |
hadoop.tmp.dir配置为你想要的路径,${user.name}会自动扩展为运行hadoop的代码
1. <configuration>
2. <property>
3. <name>dfs.replication</name>
4. <value>1</value>
5. </property>
6. </configuration>
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
dfs.replication为默认block复制数量
conf/mapred-site.xml
Xml代码
1. <configuration>
2. <property>
3. <name>mapred.job.tracker</name>
4. <value>localhost:9001</value>
5. </property>
6. </configuration>
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
执行
格式化分布式文件系统:
$ bin/hadoop namenode -format
启动hadoop:
Java代码
1. $ bin/start-all.sh
$ bin/start-all.sh
可以从
NameNode - http://localhost:50070/
JobTracker - http://localhost:50030/
查看NameNode和JobTracker
运行例子:
$ bin/hadoop fs -put conf input
$ bin/hadoop jar hadoop-*-examples.jar grep input output 'dfs[a-z.]+'
look at the run result:
$ bin/hadoop fs -get output output
$ cat output/*