linux(centos5.8)环境下Hadoop 2.0.2单机部署以及Eclipse环境搭建

Hadoop 2.0.2-alpha单机部署

(1)新建hadoop用户以及hadoop用户组

首先取得root权限

        $ su -

建用户hadoop组

       # groupadd hadoop

新建用户hadoop,放入hadoop组中,并设置主目录为/home/hadoop

       # useradd -g hadoop -d /home/hadoop hadoop

修改密码

      # passwd hadoop

其中删除用户命令为userdel,删除用户组命令为groupdel,查看用户和分组信息可以cat /etc/groups 或cat /etc/passwd

回到新建用户目录

     # su hadoop

     $ cd

(2)下载和配置hadoop

下载hadoop文件

      $ wget http://mirror.bjtu.edu.cn/apache/hadoop/common/hadoop-2.0.2-alpha/hadoop-2.0.2-alpha.tar.gz

下载完成后解压

     $ tar xzvf hadoop-2.0.2-alpha.tar.gz

新建一个叫hadoop的文件夹,建立软链接,以便以后使用其他版本

     $ ln -sf hadoop-2.0.2-alpha hadoop

配置系统环境变量

    $ su - 

    # vim /etc/profile

在最后加上以下几行

[plain] view plain copy
  1. export HADOOP_PREFIX="/home/hadoop/hadoop"     
  2. PATH="$PATH:$HADOOP_PREFIX/bin:$HADOOP_PREFIX/sbin"     
  3. export HADOOP_MAPRED_HOME=${HADOOP_PREFIX}     
  4. export HADOOP_COMMON_HOME=${HADOOP_PREFIX}     
  5. export HADOOP_HDFS_HOME=${HADOOP_PREFIX}     
  6. export YARN_HOME=${HADOOP_PREFIX}  
  7. export HADOOP_CONF_DIR="${HADOOP_PREFIX}/etc/hadoop"  
重新启动系统

       # reboot

重启后使用hadoop用户登录,进入/home/hadoop/hadoop/etc/hadoop中进行配置

      $ cd /home/hadoop/hadoop/etc/hadoop/

修改hadoop-env.sh
修改JAVA_HOME,这里JAVA_HOME的路径必须指定为真实的路径,不能引用${JAVA_HOME},否则运行的时候会有错误JAVA_HOME is not set

[plain] view plain copy
  1. export JAVA_HOME=/user/java/jdk1.6.0_35  
修改core-site.xml
[plain] view plain copy
  1. <configuration>  
  2.   <property>  
  3.     <name>fs.default.name</name>  
  4.     <value>hdfs://localhost:9000</value>  
  5.   </property>  
  6.   <property>  
  7.     <name>hadoop.tmp.dir</name>  
  8.     <value>/tmp/hadoop/hadoop-${user.name}</value>  
  9.   </property>  
  10. </configuration>  
修改hdfs-site.xml

其中,/home/hadoop/dfs/name,/home/hadoop/dfs/data都是文件系统中的目录,需要先新建

[plain] view plain copy
  1. <configuration>  
  2.   <property>    
  3.     <name>dfs.namenode.name.dir</name>    
  4.     <value>file:/home/hadoop/dfs/name</value>    
  5.     <description>Determines where on the local filesystem the DFS name node    
  6.       should store the name table.  If this is a comma-delimited list    
  7.       of directories then the name table is replicated in all of the    
  8.       directories, for redundancy. </description>    
  9.     <final>true</final>    
  10.   </property>    
  11.     
  12.   <property>    
  13.     <name>dfs.datanode.data.dir</name>    
  14.     <value>file:/home/hadoop/dfs/data</value>    
  15.     <description>Determines where on the local filesystem an DFS data node    
  16.        should store its blocks.  If this is a comma-delimited    
  17.        list of directories, then data will be stored in all named    
  18.        directories, typically on different devices.    
  19.        Directories that do not exist are ignored.    
  20.     </description>    
  21.     <final>true</final>    
  22.   </property>    
  23.     
  24.   <property>    
  25.     <name>dfs.replication</name>    
  26.     <value>1</value>    
  27.   </property>    
  28.     
  29.   <property>    
  30.     <name>dfs.permissions</name>    
  31.     <value>false</value>    
  32.   </property>    
  33. </configuration>  
修改mapred-site.xml

[plain] view plain copy
  1. <configuration>  
  2.   <property>    
  3.     <name>mapreduce.framework.name</name>    
  4.     <value>yarn</value>    
  5.   </property>   
  6.     
  7.   <property>    
  8.     <name>mapred.system.dir</name>    
  9.     <value>file:/home/hadoop/mapred/system</value>    
  10.     <final>true</final>    
  11.   </property>    
  12.     
  13.   <property>    
  14.     <name>mapred.local.dir</name>    
  15.     <value>file:/home/hadoop/mapred/local</value>    
  16.     <final>true</final>    
  17.   </property>  
  18. </configuration>  
修改yarn-site.xml
[plain] view plain copy
  1. <configuration>  
  2.   
  3. <!-- Site specific YARN configuration properties -->  
  4.   <property>  
  5.     <name>yarn.resourcemanager.resource-tracker.address</name>  
  6.     <value>localhost:8081</value>  
  7.     <description>host is the hostname of the resource manager and   
  8.     port is the port on which the NodeManagers contact the Resource Manager.  
  9.     </description>  
  10.   </property>  
  11.   
  12.   <property>  
  13.     <name>yarn.resourcemanager.scheduler.address</name>  
  14.     <value>localhost:8082</value>  
  15.     <description>host is the hostname of the resourcemanager and port is the port  
  16.     on which the Applications in the cluster talk to the Resource Manager.  
  17.     </description>  
  18.   </property>  
  19.   
  20.   <property>  
  21.     <name>yarn.resourcemanager.scheduler.class</name>  
  22.     <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>  
  23.     <description>In case you do not want to use the default scheduler</description>  
  24.   </property>  
  25.   
  26.   <property>  
  27.     <name>yarn.resourcemanager.address</name>  
  28.     <value>localhost:8083</value>  
  29.     <description>the host is the hostname of the ResourceManager and the port is the port on  
  30.     which the clients can talk to the Resource Manager. </description>  
  31.   </property>  
  32.   
  33.   <property>  
  34.     <name>yarn.nodemanager.local-dirs</name>  
  35.     <value></value>  
  36.     <description>the local directories used by the nodemanager</description>  
  37.   </property>  
  38.   
  39.   <property>  
  40.     <name>yarn.nodemanager.address</name>  
  41.     <value>0.0.0.0:port</value>  
  42.     <description>the nodemanagers bind to this port</description>  
  43.   </property>    
  44.   
  45.   <property>  
  46.     <name>yarn.nodemanager.resource.memory-mb</name>  
  47.     <value>10240</value>  
  48.     <description>the amount of memory on the NodeManager in GB</description>  
  49.   </property>  
  50.    
  51.   <property>  
  52.     <name>yarn.nodemanager.remote-app-log-dir</name>  
  53.     <value>/app-logs</value>  
  54.     <description>directory on hdfs where the application logs are moved to </description>  
  55.   </property>  
  56.   
  57.    <property>  
  58.     <name>yarn.nodemanager.log-dirs</name>  
  59.     <value></value>  
  60.     <description>the directories used by Nodemanagers as log directories</description>  
  61.   </property>  
  62.   
  63.   <property>  
  64.     <name>yarn.nodemanager.aux-services</name>  
  65.     <value>mapreduce.shuffle</value>  
  66.     <description>shuffle service that needs to be set for Map Reduce to run </description>  
  67.   </property>  
  68. </configuration>  

(3)启动hdfs以及yarn

完成以上配置后可以检测是否配置成

首先格式化namenode

         $ hdfs namenode -format

然后启动hdfs

        $ start-dfs.sh

或者

       $ hadoop-daemon.sh start namenode 

       $ hadoop-daemon.sh start datanode

接着启动yarn daemons

       $ start-yarn.sh

或者

      $ yarn-daemon.sh start resourcemanager 

      $ yarn-daemon.sh start nodemanager

启动完成后可以进入http://localhost:50070/dfshealth.jsp 查看dfs状态,如下图所示

转载请注明:http://blog.csdn.net/lawrencesgj/article/details/8240571


Eclipse环境配置

(1)下载eclipse插件并导入到eclipse中

         到http://wiki.apache.org/hadoop/EclipsePlugIn上下载对应的eclipse插件,然后eclipse的plugin目录中,我的环境是/usr/share/eclipse/plugins

(2)使用hadoop用户启动eclipse

       $ su hadoop

       $ eclipse&

(3)配置eclipse

       启动后在视图中调出mapreduce视图,并点击右下角new hadoop的大象图标,如下图


       填写安装目录以及用户明后Vaildate Location 就可以看到发现hadoop2.02了!这里我自己花了一点时间摸索,要完成关键是用hadoop用户启动eclipse,之前用系统的用户一直验证不成功。。

(3)新建mapreduce project

       如无意外,在File>>New>>Project下面就会看到有Mapreduce Project,点击后需要配置hadoop install directory,如果用mapreduce框架配置为/home/hadoop/hadoop/share/hadoop/mapreduce,如果用yarn框架配置为/home/hadoop/hadoop/share/hadoop/yarn即可。

      转载请注明:http://blog.csdn.net/lawrencesgj/article/details/8240571


       一开始因为没有用hadoop用户打开eclipse所以这里费了不少时间,后来才醒悟过来。这样我们就新建了一个mapreduce项目了!



参考:

  • http://ipjmc.iteye.com/blog/1703112
  • http://slaytanic.blog.51cto.com/2057708/885198
  • http://hadoop.apache.org/docs/r2.0.2-alpha/hadoop-yarn/hadoop-yarn-site/SingleCluster.html
  • http://wiki.apache.org/hadoop/EclipseEnvironment


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值