A)版本
hadoop-1.0.3
jdk1.6.0_32
eclipse hadoop開發外掛程式 hadoop-eclipse-plugin-1.0.3.jar
hadoop-1.0.3 使用單機模式安裝, 連接埠 hdfs 9000 mapred 9001
B)環境
1) hadoop-1.0.3 的安裝步驟 可以參照http://hadoop.apache.org/docs/r1.0.3/single_node_setup.html
conf/core-site.xml
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- Put site-specific property overrides in this file. --><configuration><property> <name>fs.default.name</name> <value>hdfs://xxx.xxx.xxx.xxx:9000</value> </property><property> <name>hadoop.tmp.dir</name> <value>/opt/hadoop-1.0.3/tmp</value> </property></configuration>
conf/mapred-site.xml:
<configuration> <property> <name>mapred.job.tracker</name> <value>xxx.xxx.xxx.xxx:9001</value> </property></configuration>
conf/hdfs-site.xml
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- Put site-specific property overrides in this file. --><configuration> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.permissions</name> <value>false</value> </property></configuration>
將xxx.xxx.xxx.xxx改成你的伺服器的IP
2)開發
1、用的是WINDOWS 下的 Eclipse,將外掛程式複製到plugin目錄裡就可以了
2、將hadoop-1.0.3 解壓到程式員的開發機器上
3、設定Hadoop Map/Reduce到你解壓的目錄
4、配置Map/Reduce Location
5、
建立Map/Reduce工程
examples\org\apache\hadoop\examples中的WordCount.java匯入到工程裡
問題出來了 直接啟動並執行話 會提示許可權問題。
12/09/24 13:52:27 ERROR security.UserGroupInformation: PriviledgedActionException as:zzj cause:java.io.IOException: Failed to set permissions of path: \tmp\hadoop-zzj\mapred\staging\zzj-743566479\.staging to 0700
Exception in thread "main" java.io.IOException: Failed to set permissions of path: \tmp\hadoop-zzj\mapred\staging\zzj-743566479\.staging to 0700
處理這個問題可以直接使用。
conf.set("mapred.job.tracker", "218.249.75.144:9001");
來手工指定
用RunAS 選擇 Run on Hadoop運行這個工程。eclipse 會自動將Jar包傳輸到Hadoop上並運行