1. 程式人生 > >Hadoop 單機部署與eclipse開發

Hadoop 單機部署與eclipse開發

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)環境

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上並執行