• zookeeper(目前只有安装)


    安装

    流程

    kafka的时候安装

    Apache ZooKeeper

    安装地址:https://archive.apache.org/dist/zookeeper/zookeeper-3.5.7/apache-zookeeper-3.5.7-bin.tar.gz

    解压

    tar -zxvf kafka_2.12-3.0.0.tgz -C /export/server/

    改配置

    1. cd config
    2. cp zoo_sample.cfg zoo.cfg
    3. vim zoo.cfg
    4. # the directory where the snapshot is stored.
    5. # do not use /tmp for storage, /tmp here is just
    6. # example sakes.
    7. dataDir=/export/server/zookeeper-3.5.7/zkdata
    8. # 这里和server.几 和下面的myid匹配上
    9. # 2888是正常leader端口,3888是备用端口
    10. server.1=hadoop1:2888:3888
    11. server.2=hadoop2:2888:3888
    12. server.3=hadoop3:2888:3888
    13. :wq

    在设置的dataDir目录下创建一个名字叫myid的文件(必须叫myid!!!)

    写入一个数(几都行,只要三个集群别一样)

    [root@hadoop1 zkdata]# echo 1 > myid

    [root@hadoop2 zkdata]# echo 2 > myid

    [root@hadoop3 zkdata]# echo 3 > myid

    fenfa

    zoo.cfg配置解毒

    1. # The number of milliseconds of each tick
    2. # 每个滴答的毫秒数 心跳
    3. tickTime=2000
    4. # The number of ticks that the initial
    5. # synchronization phase can take
    6. # 初始同步阶段可以占用的心跳数 到了没连上就失败
    7. initLimit=10
    8. # The number of ticks that can pass between
    9. # sending a request and getting an acknowledgement
    10. # 在发送请求和获得确认之间可以传递的心跳数
    11. syncLimit=5
    12. # the directory where the snapshot is stored.
    13. # do not use /tmp for storage, /tmp here is just
    14. # example sakes.
    15. # 快照所在的目录。不使用/ tmp为存储、/ tmp这里只是例子的缘故。
    16. dataDir=/export/server/zookeeper-3.5.7/zkdata
    17. # the port at which the clients will connect
    18. clientPort=2181
    19. # the maximum number of client connections.
    20. # increase this if you need to handle more clients
    21. # 客户端连接的最大数量。如果需要处理更多客户端,请增加此值
    22. #maxClientCnxns=60
    23. #
    24. # Be sure to read the maintenance section of the
    25. # administrator guide before turning on autopurge.
    26. # 在开启自动督促之前,请务必阅读管理员指南的维护部分。
    27. #
    28. # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
    29. #
    30. # The number of snapshots to retain in dataDir
    31. # dataDir中要保留的快照数量
    32. #autopurge.snapRetainCount=3
    33. # Purge task interval in hours
    34. # Set to "0" to disable auto purge feature
    35. # 清除任务间隔(小时) 设置为“0”表示禁用自动清除功能
    36. #autopurge.purgeInterval=1

    原神启动

    hadoop1启动

    [root@hadoop1 zookeeper-3.5.7]# bin/zkServer.sh start
    ZooKeeper JMX enabled by default
    Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED

    [root@hadoop1 zookeeper-3.5.7]# bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg
    Client port found: 2181. Client address: localhost.
    Error contacting service. It is probably not running.
    一看状态居然失败了?因为另外两个没启动,不过半没法选出来leader

    hadoop2/3也启动

    bin/zkServer.sh start

    现在hadoop1状态

    [root@hadoop1 zookeeper-3.5.7]# bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg
    Client port found: 2181. Client address: localhost.
    Mode: follower


    [root@hadoop2 zookeeper-3.5.7]# bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg
    Client port found: 2181. Client address: localhost.
    Mode: leader(hadoop2成leader了)


    [root@hadoop3 zookeeper-3.5.7]# bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg
    Client port found: 2181. Client address: localhost.
    Mode: follower

    批量启动脚本

    1. #!/bin/bash
    2. case $1 in
    3. start)
    4. for i in hadoop1 hadoop2 hadoop3
    5. do
    6. echo ---------------- zookeeper $i start ----------------
    7. ssh $i "/export/server/zookeeper-3.5.7/bin/zkServer.sh start"
    8. done
    9. ;;
    10. stop)
    11. for i in hadoop1 hadoop2 hadoop3
    12. do
    13. echo ---------------- zookeeper $i stop ----------------
    14. ssh $i "/export/server/zookeeper-3.5.7/bin/zkServer.sh stop"
    15. done
    16. ;;
    17. status)
    18. for i in hadoop1 hadoop2 hadoop3
    19. do
    20. echo ---------------- zookeeper $i status ----------------
    21. ssh $i "/export/server/zookeeper-3.5.7/bin/zkServer.sh status"
    22. done
    23. ;;
    24. *)
    25. echo "Usage: $0 {start|stop|status}"
    26. ;;
    27. esac

    chmod 777 zk

  • 相关阅读:
    多旋翼无人机仿真 rotors_simulator 是如何悬停的(二)
    【.Net Core】程序相关各种全局文件
    我要给你讲的简单明了,Java就是值传递,不服来辩
    二分查找:34. 在排序数组中查找元素的第一个和最后一个位置
    【SSM框架】Mybatis详解08(源码自取)之优化注册,#{}与¥{}区别,返回主键,UUID
    【数据结构】B树(B-树)和B+树
    SQL server 一次把一列的所有值都取出来保存到一个变量里
    python 执行cmd命令,输出日志的几种写法
    c语言入门---调试技巧
    tup()是什么意思
  • 原文地址:https://blog.csdn.net/qq_58551342/article/details/133924576