你好,游客 登录
背景:
阅读新闻

Hadoop-2.6.4 完全分布式搭建

[日期:2016-09-22] 来源:简书  作者:谢烟客 [字体: ]

资源准备

Hadoop

  1. 准备4台 Linux 服务器要求:glibc 版本 >= 2.14
    1. 192.168.9.1
    2. 192.168.9.2
    3. 192.168.9.3
    4. 192.168.9.4
  2. 下载: hadoop-2.6.4

服务器配置

  1. 4台服务器分别创建用户hadoop

    [email protected]# useradd hadoop

    [email protected]# echo 'hadoop' | passwd --stdin hadoop

  2. 4台服务器分别配置 hosts

    [email protected]# vi /etc/hosts

    添加内容如下:

    192.168.9.1 master

    192.168.9.2 secmaster

    192.168.9.3 slave0

    192.168.9.4 slave1

  3. master 主机免密码登陆其他主机配置
    1. 在各个主机上生成 SSH 密钥

      [email protected]$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

    2. 在 master 主机上copy公钥

      [email protected]$ ssh-copy-id -i secmaster 输入密码:hadoop即copy公钥成功

      [email protected]$ ssh-copy-id -i slave0 输入密码:hadoop即copy公钥成功

      [email protected]$ ssh-copy-id -i slave1 输入密码:hadoop即copy公钥成功

    3. 测试ssh免登陆

      在192.168.9.1主机上执行如下命令确保 master 可以实现对其他主机的免密码登陆,首次执行需要输入"yes" 确认

      [email protected]$ ssh secmaster

      [email protected]$ ssh slave0

      [email protected]$ ssh slave1

hadoop自身配置

  1. 在 master(192.168.9.1) 主机上解压 hadoop-2.6.4.tar.gz

    [email protected]$ tar xvf hadoop-2.6.4.tar.gz

  2. 配置 etc/hadoop/core-site.xml

    <configuration>
     <property>
         <name>fs.default.name</name>
         <value>hdfs://master:9000</value>
     </property>
     <property>
         <name>io.file.buffer.size</name>
         <value>131072</value>
     </property>
     <property>
         <name>hadoop.tmp.dir</name>
         <value>/home/hadoop/tmp</value>
     </property>
     <property>
         <name>hadoop.proxyuser.u0.hosts</name>
         <value>*</value>
     </property>
     <property>
         <name>hadoop.proxyuser.u0.groups</name>
         <value>*</value>
     </property>
    </configuration>
  3. 配置 etc/hadoop/hdfs-site.xml

    <configuration>
     <property>
         <name>dfs.replication</name>
         <value>2</value>
     </property>
     <property>
         <name>dfs.namenode.secondary.http-address</name>
         <value>secmaster:9001</value>
     </property>
     <property>
         <name>dfs.namenode.name.dir</name>
         <value>file:/home/hadoop/dfs/name</value>
     </property>
     <property>
         <name>dfs.datanode.data.dir</name>
         <value>file:/home/hadoop/dfs/data</value>
     </property>
     <property>
         <name>dfs.webhdfs.enabled</name>
         <value>true</value>
    </property>
    </configuration>
  4. 配置 etc/hadoop/mapred-site.xml

    <configuration>
     <property>
         <name>mapreduce.framework.name</name>
         <value>yarn</value>
     </property>
     <property>
         <name>mapreduce.jobhistory.address</name>
         <value>master:10020</value>
     </property>
     <property>
         <name>mapreduce.jobhistory.webapp.address</name>
         <value>master:19888</value>
     </property>
    </configuration>
  5. 配置etc/hadoop/yarn-site.xml

    <configuration>
    <!-- Site specific YARN configuration properties -->
     <property>
         <name>yarn.nodemanager.aux-services</name>
         <value>mapreduce_shuffle</value>
     </property>
     <property>
             <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
             <value>org.apache.hadoop.mapred.ShuffleHandler</value>
         </property>
         <property>
            <name>yarn.resourcemanager.address</name>
                <value>master:8032</value>
         </property>
         <property>
                <name>yarn.resourcemanager.scheduler.address</name>
                <value>master:8030</value>
        </property>
        <property>
             <name>yarn.resourcemanager.resource-tracker.address</name>
              <value>master:8031</value>
       </property>
       <property>
               <name>yarn.resourcemanager.admin.address</name>
                <value>master:8033</value>
        </property>
        <property>
                <name>yarn.resourcemanager.webapp.address</name>
                <value>master:8088</value>
        </property>
    </configuration>

Master向各个节点同步配置完毕后的 hadoop 工程

[email protected]$ scp -r /home/hadoop/hadoop-2.6.4 [email protected]:/home/hadoop

[email protected]$ scp -r /home/hadoop/hadoop-2.6.4 [email protected]:/home/hadoop

[email protected]$ scp -r /home/hadoop/hadoop-2.6.4 [email protected]:/home/hadoop

格式化 namenode,启动 hadoop 所有组件

[[email protected]]$ bin/hadoop namenode -format

[[email protected]]$ sbin/start-all.sh

如果不出意外完全分布式的 hadoop cluster 已经运行起来了^_^





收藏 推荐 打印 | 录入:elainebo | 阅读: