• Hadoop HA 集群搭建


    集群部署节点角色的规划(3节点)

    ----------------------------------------------------------------------------------------------------------------

    Server01 192.168.2.11:hadoop01:node01 namenode resourcemanager zkfc nodemanager datanode zookeeper journalnode

    Server02 192.168.2.12:hadoop02:node02 namenode resourcemanager zkfc nodemanager datanode zookeeper journalnode

    Server03 192.168.2.13:hadoop03:node03 datanode nodemanager zookeeper journalnode

    ----------------------------------------------------------------------------------------------------------------

    环境准备

    1. 修改Linux主机名
    2. 修改主机名
    3. 关闭防火墙
    4. ssh免登录
    5. 安装JDK
    6. 配置时间同步
    7. 安装zookeeper

    安装配置Hadoop集群

    将Hadoop解压到指定目录,并添加配置指定jdk目录

    [root@node01 hadoop-2.7.7]# tar zxvf /root/soft/hadoop-2.7.7.tar.gz -C /apps/

    [root@node01 hadoop-2.7.7]# cd /apps/hadoop-2.7.7/etc/hadoop/

    [root@node01 hadoop]# vim hadoop-env.sh

    export JAVA_HOME=/apps/jdk1.8.0_151

       

    配置core-site.xml文件

    [root@node01 hadoop]# vim core-site.xml

        <!-- 集群名称在这里指定!该值来自于hdfs-site.xml中的配置 -->

        <property>

            <name>fs.defaultFS</name>

            <value>hdfs://cluster1</value>

        </property>

        <!-- 这里的路径默认是NameNodeDataNodeJournalNode等存放数据的公共目录 -->

        <property>

            <name>hadoop.tmp.dir</name>

            <value>/data/hadoop/tmp</value>

        </property>

       

        <!-- ZooKeeper集群的地址和端口。注意,数量一定是奇数,且不少于三个节点-->

        <property>

            <name>ha.zookeeper.quorum</name>

            <value>node01:2181,node02:2181,node03:2181</value>

        </property>

       

    配置hdfs-site.xml文件

    [root@node01 hadoop]# vim hdfs-site.xml

        <!--指定hdfsnameservicecluster1,需要和core-site.xml中的保持一致 -->

        <property>

            <name>dfs.nameservices</name>

            <value>cluster1</value>

        </property>

        <!-- cluster1下面有两个NameNode,分别是nn1nn2 -->

        <property>

            <name>dfs.ha.namenodes.cluster1</name>

            <value>nn1,nn2</value>

        </property>

        <!-- nn1RPC通信地址 -->

        <property>

            <name>dfs.namenode.rpc-address.cluster1.nn1</name>

            <value>node01:9000</value>

        </property>

        <!-- nn1http通信地址 -->

        <property>

            <name>dfs.namenode.http-address.cluster1.nn1</name>

            <value>node01:50070</value>

        </property>

        <!-- nn2RPC通信地址 -->

        <property>

            <name>dfs.namenode.rpc-address.cluster1.nn2</name>

            <value>node02:9000</value>

        </property>

        <!-- nn2http通信地址 -->

        <property>

            <name>dfs.namenode.http-address.cluster1.nn2</name>

            <value>node02:50070</value>

        </property>

        <!-- 指定NameNodeedits元数据在JournalNode上的存放位置 -->

        <property>

            <name>dfs.namenode.shared.edits.dir</name>

            <value>qjournal://node01:8485;node02:8485;node03:8485/cluster1</value>

        </property>

        <!-- 指定JournalNode在本地磁盘存放数据的位置 -->

        <property>

            <name>dfs.journalnode.edits.dir</name>

            <value>/data/hadoop/journaldata</value>

        </property>

        <!-- 开启NameNode失败自动切换 -->

        <property>

            <name>dfs.ha.automatic-failover.enabled</name>

            <value>true</value>

        </property>

        <!-- 指定该集群出故障时,哪个实现类负责执行故障切换 -->

        <property>

            <name>dfs.client.failover.proxy.provider.cluster1</name>

            <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>

        </property>

        <!-- 配置隔离机制方法,多个机制用换行分割,即每个机制暂用一行-->

        <property>

            <name>dfs.ha.fencing.methods</name>

            <value>sshfence</value>

        </property>

        <!-- 使sshfence隔离机制时需要ssh免登陆 -->

        <property>

            <name>dfs.ha.fencing.ssh.private-key-files</name>

            <value>/root/.ssh/id_rsa</value>

        </property>

        <!-- 配置sshfence隔离机制超时时间 -->

        <property>

            <name>dfs.ha.fencing.ssh.connect-timeout</name>

            <value>30000</value>

        </property>

       

    配置mapred-site.xml文件

    [root@node01 hadoop]# cp mapred-site.xml.template mapred-site.xml

    [root@node01 hadoop]# vim mapred-site.xml

        <!-- 指定mr框架为yarn方式 -->

        <property>

            <name>mapreduce.framework.name</name>

            <value>yarn</value>

        </property>

       

    配置yarn-site.xml文件

    [root@node01 hadoop]# vim yarn-site.xml

        <!-- 开启RM高可用 -->

        <property>

            <name>yarn.resourcemanager.ha.enabled</name>

            <value>true</value>

        </property>

        <!-- 指定RMcluster id -->

        <property>

            <name>yarn.resourcemanager.cluster-id</name>

            <value>yrc</value>

        </property>

        <!-- 指定RM的名字 -->

        <property>

            <name>yarn.resourcemanager.ha.rm-ids</name>

            <value>rm1,rm2</value>

        </property>

        <!-- 分别指定RM的地址 -->

        <property>

            <name>yarn.resourcemanager.hostname.rm1</name>

            <value>node01</value>

        </property>

        <property>

            <name>yarn.resourcemanager.hostname.rm2</name>

            <value>node02</value>

        </property>

        <!-- 指定zk集群地址 -->

        <property>

            <name>yarn.resourcemanager.zk-address</name>

            <value>node01:2181,node02:2181,node03:2181</value>

        </property>

        <property>

            <name>yarn.nodemanager.aux-services</name>

            <value>mapreduce_shuffle</value>

        </property>

       

    在文件slaves中配置集群节点

    [root@node01 hadoop]# vim slaves

    node01

    node02

    node03

    [root@node01 apps]# scp -r hadoop-2.7.7 node02:$PWD

    [root@node01 apps]# scp -r hadoop-2.7.7 node03:$PWD

       

    配置Hadoop环境变量

    [root@node02 sbin]# vim /etc/profile

    export HADOOP_HOME=/apps/hadoop-2.7.7

    export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

    手动启动node01、node01、node03三个节点上的journalnode

    [root@node01 sbin]# ./hadoop-daemon.sh start journalnode

    格式化namenode

    [root@node01 bin]# hdfs namenode -format

    [root@node01 data]# scp -r hadoop node02:$PWD

    [root@node01 data]# scp -r hadoop node03:$PWD

       

    格式化ZKFC(在active上执行)

    [root@node01 apps]# hdfs zkfc -formatZK

       

    启动HDFS

    [root@node01 apps]# start-dfs.sh

       

    启动Yarn,并且手动启动standby节点

    [root@node01 apps]# start-yarn.sh

    [root@node02 sbin]# yarn-daemon.sh start resourcemanager

      

  • 相关阅读:
    Spring----BeanPostProcessor
    spring lifeCycle
    lambda表达式
    mybatis ----SqlSessionManager
    带权随机
    Protocol Buffers学习笔记
    Java的Lambda表达式
    mysql之group_concat函数
    Java排序之归并排序
    Java排序之计数排序
  • 原文地址:https://www.cnblogs.com/starzy/p/14275066.html
Copyright © 2020-2023  润新知