Kafka(三) CenterOs安裝jdk,zookeeper,kafka以及相關配置

一.安裝zookeeper


  1. 在線下載zookeeper 
    wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
  2. 解壓該壓縮包
    tar -zxvf zookeeper-3.4.14.tar.gz
  3.  啓動zookeeper
    1.在zookeeper的目錄中找到bin這個目錄,zookeeper啓動腳本就在這裏。
    查看都有什麼命令
    bin/zkServer.sh
    啓動
    bin/zkServer.sh start

    注意:默認的/bin/../conf/zoo_sample.cfg,我們需要把這個文件重命名爲zoo.cfg,不然啓動不成功

    重命名
    mv zoo_sample.cfg zoo.cfg

     

  4. 查看啓動是否成功,如下圖表示已經啓動成功

  5. 需要知道的zookeeper配置信息:

  • # The number of milliseconds of each tick
    #zk服務器的心跳時間
    tickTime=2000
    # The number of ticks that the initial
    # synchronization phase can take
    #投票選舉新leader的初始化時間
    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=/tmp/zookeeper
    # the port at which the clients will connect
    #zk對外服務端口
    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

linux下載安裝zookeeper更詳細地址


二.安裝kafka


  • 下載kafka
  • wget https://mirror.bit.edu.cn/apache/kafka/2.4.1/kafka_2.13-2.4.1.tgz
  • 解壓
  • tar -zxvf kafka_2.13-2.4.1.tgz
  • 修改配置
  • #表示broker的編號,如果集羣中有多個broker,那麼broker的編號需要設置的不同。
    broker.id=0
    #對外提供的服務入口地址
    listeners=PLAINTEXT://9092 brooder,
    #設置存放消息日誌的文件地址
    log.dirs=/tmp/kafka/log
    #kafka所需要的zookeeper集羣地址:
    zookeeper.connet=ip:2181
    
  • 啓動
    bin/kafka-server-start.sh start config/server.properties 

    缺點:console關閉後,kafka也會被關閉,換爲後臺啓動就可以了

  • 後臺啓動

  •  bin/kafka-server-start.sh -daemon config/server.properties

     

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章