美文网首页
大数据环境搭建--02 Centos7安装Zookeeper3.

大数据环境搭建--02 Centos7安装Zookeeper3.

作者: M醉逍遥 | 来源:发表于2017-06-06 12:18 被阅读0次

    注意:我们将大数据相关组件全部安装在/opt/bigdata目录

    1.下载zookeeper安装包

    [root@cluster201 bigdata]# pwd
    /opt/bigdata
    [hadoop@cluster201 bigdata]$ wget http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz
    

    2.解压

    [root@cluster201 bigdata]# pwd
    /opt/bigdata
    [hadoop@cluster201 bigdata]$ tar -zvxf zookeeper-3.4.10.tar.gz
    

    3. 修改环境变量,在/etc/profile文件中增加如下内容

    #zookeeper
    export ZOOKEEPER_HOME=/opt/bigdata/zookeeper-3.4.10
    export PATH=$PATH:$ZOOKEEPER_HOME/bin
    

    用source命令让配置文件生效

    [root@cluster201 bigdata]# source /etc/profile
    

    4.在/opt/bigdata/zookeeper-3.4.10下创建存放数据与日志的目录

    [root@cluster201 bigdata]# pwd
    /opt/bigdata/zookeeper-3.4.10
    [root@cluster201 zookeeper-3.4.10]# mkdir data
    [root@cluster201 zookeeper-3.4.10]# mkdir log
    

    5.修改配置文件(cluster201/cluster202/cluster203执行同样的操作)

    先拷贝样本配置文件

    [root@cluster201 conf]# pwd
    /opt/bigdata/zookeeper-3.4.10/conf
    [root@cluster201 conf]# cp zoo_sample.cfg zoo.cfg
    

    将zoo.cfg的内容修改如下

    # The number of milliseconds of each tick
    tickTime=2000
    # The number of ticks that the initial 
    # synchronization phase can take
    initLimit=10
    # The number of ticks that can pass between 
    # sending a request and getting an acknowledgement
    syncLimit=5
    # the directory where the snapshot is stored.
    # do not use /tmp for storage, /tmp here is just 
    # example sakes.
    #配置数据存放目录
    dataDir=/opt/bigdata/zookeeper-3.4.10/data
    #配置日志存放目录
    dataLogDir=/opt/bigdata/zookeeper-3.4.10/log
    # the port at which the clients will connect
    clientPort=2181
    # the maximum number of client connections.
    # increase this if you need to handle more clients
    #maxClientCnxns=60
    #
    # Be sure to read the maintenance section of the 
    # administrator guide before turning on autopurge.
    #
    # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
    #
    # The number of snapshots to retain in dataDir
    #autopurge.snapRetainCount=3
    # Purge task interval in hours
    # Set to "0" to disable auto purge feature
    #autopurge.purgeInterval=1
    #配置集群地址
    server.1=cluster201:2888:3888
    server.2=cluster202:2888:3888
    server.3=cluster203:2888:3888
    

    6.在data目录中创建myid文件

    cluster201(192.168.88.201)

    [root@cluster201 zookeeper-3.4.10]# pwd
    /opt/bigdata/zookeeper-3.4.10
    [root@cluster201 zookeeper-3.4.10]# echo 1 > data/myid
    

    cluster202(192.168.88.202)

    [root@cluster202 zookeeper-3.4.10]# pwd
    /opt/bigdata/zookeeper-3.4.10
    [root@cluster202 zookeeper-3.4.10]# echo 2 > data/myid
    

    cluster203(192.168.88.203)

    [root@cluster203 zookeeper-3.4.10]# pwd
    /opt/bigdata/zookeeper-3.4.10
    [root@cluster203 zookeeper-3.4.10]# echo 3 > data/myid
    

    7.zookeeper的启动、停止、状态查看,三台执行相同操作

    #启动zookeeper
    [hadoop@cluster201 zookeeper-3.4.10]$ zkServer.sh start
    ZooKeeper JMX enabled by default
    Using config: /opt/bigdata/zookeeper-3.4.10/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED
    #查看Java进程
    [hadoop@cluster201 zookeeper-3.4.10]$ jps
    2814 QuorumPeerMain
    2846 Jps
    #查看zookeeper状态
    [hadoop@cluster201 zookeeper-3.4.10]$ zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /opt/bigdata/zookeeper-3.4.10/bin/../conf/zoo.cfg
    Mode: follower
    #停止zookeeper
    [hadoop@cluster201 zookeeper-3.4.10]$ zkServer.sh stop
    ZooKeeper JMX enabled by default
    Using config: /opt/bigdata/zookeeper-3.4.10/bin/../conf/zoo.cfg
    Stopping zookeeper ... STOPPED
    #重启zookeeper
    [hadoop@cluster201 zookeeper-3.4.10]$ zkServer.sh restart
    
    Paste_Image.png

    8.zookeeper基本命令

    #链接到集群
    [hadoop@cluster201 zookeeper-3.4.10]$ zkCli.sh -server cluster201:2181
    #查看帮助
    [zk: cluster201:2181(CONNECTED) 0] help
    ZooKeeper -server host:port cmd args
        stat path [watch]
        set path data [version]
        ls path [watch]
        delquota [-n|-b] path
        ls2 path [watch]
        setAcl path acl
        setquota -n|-b val path
        history 
        redo cmdno
        printwatches on|off
        delete path [version]
        sync path
        listquota path
        rmr path
        get path [watch]
        create [-s] [-e] path data acl
        addauth scheme auth
        quit 
        getAcl path
        close 
        connect host:port
    

    相关文章

      网友评论

          本文标题:大数据环境搭建--02 Centos7安装Zookeeper3.

          本文链接:https://www.haomeiwen.com/subject/jcugfxtx.html