快速部署kafka单机环境

1. 依赖准备

1.1 jdk安装

安装jdk,版本推荐8以上

1.2 zk安装

  1. 下载zk对应版本
    比如下载http://apache.communilink.net/zookeeper/stable/apache-zookeeper-3.5.5-bin.tar.gz
  2. 解压
    tar -xvf apache-zookeeper-3.5.5-bin.tar.gz
    mv apache-zookeeper-3.5.5-bin /usr/local/apache-zookeeper-3.5.5
    
  3. 创建数据目录及日志目录
    mkdir {data,logs}
    
  4. 修改配置文件
    # 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=/usr/local/apache-zookeeper-3.5.5/data
    dataLogDir=/usr/local/apache-zookeeper-3.5.5/logs
    # the port at which the clients will connect
    clientPort=2181
    admin.serverPort=8181
    # 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
    
  5. 设置环境变量
    vim /etc/profile
    export ZOOKEEPER_HOME=/usr/local/apache-zookeeper-3.5.5
    export PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin
    
    设置立即生效
    source /etc/profile
    
  6. 启动&关闭zk服务
    #启动ZooKeeper的Server
    zkServer.sh start
    #关闭ZooKeeper的Server
    zkServer.sh stop
    

2. kafka部署

  1. 下载对应集群版本https://archive.apache.org/dist/kafka/,以2.3.0为例
    wget <https://archive.apache.org/dist/kafka/2.3.0/kafka_2.12-2.3.0.tgz>
    
  2. 解压安装包
    tar zxvf kafka_2.12-2.3.0.tgz
    
  3. 修改配置文件
    • 添加 delete.topic.enable=true,主要方便删除topic
    • 去掉注释listeners=PLAINTEXT://:9092
    • 设置zookeeper连接地址,一般zk后面接上自定义kafka绑定节点,zookeeper.connect=localhost:2181/kafka
    • 配置日志目录,log.dirs=/tmp/kafka-logs
    • 设置 broke.id,需要保证同一个集群中的各个节点值唯一
    • 设置主题分区数,分区数一般为节点的整数倍,num.partitions=3
  4. 启动服务
    #常规模式启动,可以查看控制台输出
    bin/kafka-server-start.sh config/server.properties
    #后台启动
    bin/kafka-server-start.sh -daemon config/server.properties
    

kafka简单使用请参考下一篇博客kafka常用控制台命令集合

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值