【Linux】:Centos7安装Kafka

目录

一.先安装zookeeper并启动

二.安装kafka


一.先安装zookeeper并启动

1.下载

https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.8.2/apache-zookeeper-3.8.2-bin.tar.gz

2.上传到Linux任意目录下

3.解压到/user/local/文件夹下

bash 复制代码
[root@localhost app]# tar -zxvf ./apache-zookeeper-3.8.2-bin.tar.gz -C /usr/local/

4.切换到/usr/local/下

bash 复制代码
[root@localhost app]# cd /usr/local/

5.修改文件改名

bash 复制代码
 [root@localhost local]# mv ./apache-zookeeper-3.8.2-bin/ ./apache-zookeeper-3.8.2/

6.在安装目录下创建文件夹

bash 复制代码
  [root@localhost local]# cd ./apache-zookeeper-3.8.2/
  [root@localhost apache-zookeeper-3.8.2]# mkdir data
  [root@localhost apache-zookeeper-3.8.2]# mkdir logs
  [root@localhost apache-zookeeper-3.8.2]# ls
     bin  conf  data  docs  lib  LICENSE.txt  logs  NOTICE.txt  README.md  README_packaging.md

7.修改配置文件

bash 复制代码
[root@localhost conf]# vim ./zoo_sample.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=/usr/local/apache-zookeeper-3.8.2/data     # 修改,按照刚新建文件夹的目录
    dataLogDir=/usr/local/apache-zookeeper-3.8.2/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.
    #
    # https://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

    ## Metrics Providers
    #
    # https://prometheus.io Metrics Exporter
    #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
    #metricsProvider.httpHost=0.0.0.0
    #metricsProvider.httpPort=7000
    #metricsProvider.exportJvmInfo=true

8.修改配置文件名称

bash 复制代码
 [root@localhost conf]# mv ./zoo_sample.cfg ./zoo.cfg

7.启动zookeeper

bash 复制代码
 [root@localhost conf]# /usr/local/apache-zookeeper-3.8.2/bin/zkServer.sh start
    /usr/bin/java
    ZooKeeper JMX enabled by default
    Using config: /usr/local/apache-zookeeper-3.8.2/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED

9.查看zookeeper状态

bash 复制代码
 [root@localhost conf]# /usr/local/apache-zookeeper-3.8.2/bin/zkServer.sh status
    /usr/bin/java
    ZooKeeper JMX enabled by default
    Using config: /usr/local/apache-zookeeper-3.8.2/bin/../conf/zoo.cfg
    Client port found: 2181. Client address: localhost. Client SSL: false.
    Mode: standalone

10.连接服务

bash 复制代码
 [root@localhost conf]# /usr/local/apache-zookeeper-3.8.2/bin/zkCli.sh

服务停止命令:扩展命令

bash 复制代码
 [root@localhost conf]# /usr/local/apache-zookeeper-3.8.2/bin/zkServer.sh stop
    /usr/bin/java
    ZooKeeper JMX enabled by default
    Using config: /usr/local/apache-zookeeper-3.8.2/bin/../conf/zoo.cfg
    Stopping zookeeper ... STOPPED

二.安装kafka

1.下载kafka

https://kafka.apache.org/downloads,下载的是3.5.0:Scala 2.12 - kafka_2.12-3.5.1.tgz (asc, sha512)

2.解压到/usr/local文件夹下,并改文件夹的名称

bash 复制代码
 [root@localhost app]# tar -zxvf ./kafka_2.12-3.5.1.tgz -C /usr/local/

3.进入Kafka,新建日志文件夹

bash 复制代码
 [root@localhost local]# cd /usr/local/kafka_2.12-3.5.1
 [root@localhost kafka_2.12-3.5.1]# mkdir ./log/

4.修改配置文件

bash 复制代码
 [root@localhost kafka_2.12-3.5.1]# vim ./config/server.properties
 需要改一下信息:
    # broker的编号,如果集群中有多个broker,则每个broker的编号需要设置的不同,同zookeeper一致就可以
    broker.id=0
    # 存放消息日志文件地址
    log.dirs=/usr/local/kafka_2.12-3.5.1/log/
    # broker对外提供服务的入口地址
    advertised.listeners=PLAINTEXT://192.168.154.128:9092  (192.168.154.128是我虚拟机的IP地址)

5.单机形式启动kafka

bash 复制代码
   [root@localhost kafka_2.12-3.5.1]# bin/kafka-server-start.sh -daemon config/server.properties

6.停止kafka

bash 复制代码
 [root@localhost kafka_2.12-3.5.1]bin/kafka-server-stop.sh
相关推荐
watermelonoops1 小时前
Deepin和Windows传文件(Xftp,WinSCP)
linux·ssh·deepin·winscp·xftp
疯狂飙车的蜗牛2 小时前
从零玩转CanMV-K230(4)-小核Linux驱动开发参考
linux·运维·驱动开发
远游客07134 小时前
centos stream 8下载安装遇到的坑
linux·服务器·centos
马甲是掉不了一点的<.<4 小时前
本地电脑使用命令行上传文件至远程服务器
linux·scp·cmd·远程文件上传
jingyu飞鸟4 小时前
centos-stream9系统安装docker
linux·docker·centos
超爱吃士力架5 小时前
邀请逻辑
java·linux·后端
cominglately7 小时前
centos单机部署seata
linux·运维·centos
魏 无羡7 小时前
linux CentOS系统上卸载docker
linux·kubernetes·centos
CircleMouse8 小时前
Centos7, 使用yum工具,出现 Could not resolve host: mirrorlist.centos.org
linux·运维·服务器·centos
木子Linux8 小时前
【Linux打怪升级记 | 问题01】安装Linux系统忘记设置时区怎么办?3个方法教你回到东八区
linux·运维·服务器·centos·云计算