• 大数据软件安装之ZooKeeper监控


    一、ZooKeeper安装

    官方文档:

    https://zookeeper.apache.org/doc/r3.5.5/zookeeperStarted.html

    1、解压分发

    [test@hadoop102 opt]$ tar -zxvf  zookeeper-3.4.10.tar.gz -C /opt/module/

    [test@hadoop102 module]$ xsync zookeeper-3.4.10/

    2、配置服务号

    [test@hadoop102 zookeeper-3.4.10]$ mkdir zkData

    [test@hadoop102 zkData]$ touch myid

    [test@hadoop102 zkData]$ vim myid

    修改 myid=2

    同样修改 hadoop103 myid=3 ;hadoop104 myid=4

    3、配置zoo.cfg(conf)

    [test@hadoop102 conf]$ mv zoo_sample.cfg zoo.cfg

    [test@hadoop102 conf]$ vim zoo.cfg

    修改:

    dataDir=/opt/module/zookeeper-3.4.10/zkData

    #######################cluster##########################

    server.2=hadoop102:2888:3888

    server.3=hadoop103:2888:3888

    server.4=hadoop104:2888:3888

    [test@hadoop102 conf]$ xsync zoo.cfg

    server.A=B:C:D

      A是一个数字,表示这个是第几号服务器;

      集群模式下配置一个文件myid,这个文件在dataDir目录下,这个文件里面有一个数据就是A的值,Zookeeper启动时读取此文件,拿到里面的数据与zoo.cfg里面的配置信息比较从而判断到底是哪个server。

      B是这个服务器的地址;

      C是这个服务器Follower与集群中的Leader服务器交换信息的端口;

      D是万一集群中的Leader服务器挂了,需要一个端口来重新进行选举,选出一个新的Leader,而这个端口就是用来执行选举时服务器相互通信的端口。

    4、启动zookeeper

    启动zookeeper服务端

    [test@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh start

    查看状态

    [test@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh status

    启动zookeeper客户端

    [test@hadoop102 zookeeper-3.4.10]$ bin/zkCli.sh start

    二、HDFS HA(Hadoop高可用)

    官方文档:

    http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HDFSHighAvailabilityWithQJM.html

    1、创建并复制hadoop

    mkdir /opt/ha

    cp -r hadoop-2.7.2/ /opt/ha/

    2、配置hadoop

    1)配置jdk环境

    cd /opt/module/hadoop-2.7.2/etc/hadoop

    [test@hadoop102 hadoop]$ vim hadoop-env.sh

    export JAVA_HOME=/opt/module/jdk1.8.0_144

    2)配置hadoop文件

    配置core-site.xml

    cd /opt/module/hadoop-2.7.2/etc/hadoop

    [test@hadoop102 hadoop]$ vim core-site.xml

    <configuration>

    <!-- 把两个NameNode)的地址组装成一个集群mycluster -->
    <property>
    <name>fs.defaultFS</name>

    <value>hdfs://mycluster</value>
    </property>

    <!-- 指定hadoop运行时产生文件的存储目录 -->

    <property>
    <name>hadoop.tmp.dir</name>
    <value>/opt/ha/hadoop-2.7.2/data/tmp</value>

    </property>

    <!-- 自动故障转移 -->

    <property>
    <name>ha.zookeeper.quorum</name>
    <value>hadoop102:2181,hadoop103:2181,hadoop104:2181</value>

    </property>

    </configuration>

    配置hdfs-site.xml

    cd /opt/module/hadoop-2.7.2/etc/hadoop

    [test@hadoop102 hadoop]$ vim hdfs-site.xml

    <configuration>
    <!-- 完全分布式集群名称 -->
    <property>
    <name>dfs.nameservices</name>
    <value>mycluster</value>
    </property>

    <!-- 集群中NameNode节点都有哪些 -->

    <property>
    <name>dfs.ha.namenodes.mycluster</name>
    <value>nn1,nn2</value>

    </property>

    <!-- nn1的RPC通信地址 -->

    <property>
    <name>dfs.namenode.rpc-address.mycluster.nn1</name>
    <value>hadoop102:9000</value>

    </property>

    <!-- nn2的RPC通信地址 -->

    <property>
    <name>dfs.namenode.rpc-address.mycluster.nn2</name>
    <value>hadoop103:9000</value>

    </property>

    <!-- nn1的http通信地址 -->

    <property>
    <name>dfs.namenode.http-address.mycluster.nn1</name>
    <value>hadoop102:50070</value>

    </property>

    <!-- nn2的http通信地址 -->

    <property>
    <name>dfs.namenode.http-address.mycluster.nn2</name>
    <value>hadoop103:50070</value>

    </property>

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

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

    <value>qjournal://hadoop102:8485;hadoop103:8485;hadoop104:8485/mycluster</value>

    </property>

    <!-- 配置隔离机制,即同一时刻只能有一台服务器对外响应 -->

    <property>
    <name>dfs.ha.fencing.methods</name>
    <value>sshfence</value>

    </property>

    <!-- 使用隔离机制时需要ssh无秘钥登录-->

    <property>
    <name>dfs.ha.fencing.ssh.private-key-files</name>
    <value>/home/atguigu/.ssh/id_rsa</value>

    </property>

    <!-- 关闭权限检查-->

    <property>
    <name>dfs.permissions.enable</name>
    <value>false</value>

    </property>

    <!-- 访问代理类:client,mycluster,active配置失败自动切换实现方式-->

    <property>

    <name>dfs.client.failover.proxy.provider.mycluster</name>
    <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
    </property>

    <!--自动故障转移-->

    <property> <name>dfs.ha.automatic-failover.enabled</name>
    <value>true</value>

    </property>

    </configuration>

    3、分发到其他机器

    xsync /opt/module/ha

    4、启动

    [test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start journalnode

    NN1格式化并启动

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs namenode -format

    [test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start namenode

    NN2设置同步并启动

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs namenode -bootstrapStandby

    [test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start namenode

    启动NN1并切换为Active

    [test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemons.sh start datanode

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs haadmin -transitionToActive nn1

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs haadmin -getServiceState nn1

    5、配置完自动故障转移后再启动

    [test@hadoop102 hadoop-2.7.2]$ sbin/stop-dfs.sh

    [test@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh start

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs zkfc -formatZK

    [test@hadoop102 hadoop-2.7.2]$ sbin/start-dfs.sh

    三、Yarn HA

    官方文档:

    http://hadoop.apache.org/docs/r2.7.2/hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html

    1、配置yarn-site.xml

    cd /opt/module/hadoop-2.7.2/etc/hadoop

    [test@hadoop102 hadoop]$ vim yarn-site.xml

    <configuration>

        <property>

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

            <value>mapreduce_shuffle</value>

        </property>

        <!--启用resourcemanager ha-->

        <property>

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

            <value>true</value>

        </property>

        <!--声明两台resourcemanager的地址-->

        <property>

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

            <value>cluster-yarn1</value>

        </property>

        <property>

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

            <value>rm1,rm2</value>

        </property>

        <property>

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

            <value>hadoop102</value>

        </property>

        <property>

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

            <value>hadoop103</value>

        </property>

        <!--指定zookeeper集群的地址--> 

        <property>

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

            <value>hadoop102:2181,hadoop103:2181,hadoop104:2181</value>

        </property>

        <!--启用自动恢复--> 

        <property>

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

            <value>true</value>

        </property>

        <!--指定resourcemanager的状态信息存储在zookeeper集群--> 

        <property>

            <name>yarn.resourcemanager.store.class</name>     <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>

    </property>

    </configuration>

    2、启动hdfs

    1)[test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start journalnode

    2)初始化NN1并启动

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs namenode -format

    [test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start namenode

    3)NN2同步并启动

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs namenode -bootstrapStandby

    [test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start namenode

    4)启动所有DN

    [test@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemons.sh start datanode

    [test@hadoop102 hadoop-2.7.2]$ bin/hdfs haadmin -transitionToActive nn1

    3、启动yarn

    [test@hadoop102 hadoop-2.7.2]$ sbin/start-yarn.sh

    [test@hadoop102 hadoop-2.7.2]$ sbin/yarn-daemon.sh start resourcemanager

    [test@hadoop102 hadoop-2.7.2]$ bin/yarn rmadmin -getServiceState rm1

    完成

  • 相关阅读:
    ActiveSync合作关系对话框的配置
    WINCE对象存储区(object store)
    Wince 隐藏TASKBAR的方法
    Wince输入法换肤换语言机制
    poj 3080 Blue Jeans 解题报告
    codeforces A. Vasily the Bear and Triangle 解题报告
    hdu 1050 Moving Tables 解题报告
    hdu 1113 Word Amalgamation 解题报告
    codeforces A. IQ Test 解题报告
    poj 1007 DNA Sorting 解题报告
  • 原文地址:https://www.cnblogs.com/solomongold/p/12524499.html
Copyright © 2020-2023  润新知