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

    Kafka(三) CenterOs安装jdk,zookeeper,kafka以及相关配置_第1张图片注意:默认的/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

     

 

你可能感兴趣的:(#,Kafka)