Hadoop 单机部署与eclipse开发

来源:互联网 发布:weedfs java 编辑:程序博客网 时间:2024/04/29 20:29

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

[html] view plaincopy
  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. <configuration>  
  6. <property>    
  7.         <name>fs.default.name</name>    
  8.         <value>hdfs://xxx.xxx.xxx.xxx:9000</value>    
  9. </property>  
  10. <property>  
  11.         <name>hadoop.tmp.dir</name>  
  12.         <value>/opt/hadoop-1.0.3/tmp</value>   
  13. </property>  
  14. </configuration>  


conf/mapred-site.xml:

[html] view plaincopy
  1. <configuration>  
  2.      <property>  
  3.          <name>mapred.job.tracker</name>  
  4.          <value><span style="font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 15px; ">xxx.xxx.xxx.xxx</span>:9001</value>  
  5.      </property>  
  6. </configuration>  

conf/hdfs-site.xml

[html] view plaincopy
  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>dfs.replication</name>    
  9.                 <value>1</value>    
  10.         </property>    
  11.         <property>   
  12.                 <name>dfs.permissions</name>   
  13.                 <value>false</value>   
  14.         </property>  
  15. </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

处理这个问题可以直接使用。

[java] view plaincopy
  1. conf.set("mapred.job.tracker""218.249.75.144:9001");  
来手工指定


用RunAS 选择 Run on Hadoop运行这个工程。eclipse 会自动将Jar包传输到Hadoop上并运行

0 0
原创粉丝点击