当前位置:   article > 正文

【Linux】Kafka+ZooKeeper的安装_linux 安装1个zk 3个kafka

linux 安装1个zk 3个kafka

前言

之所以写这篇文章,是因为要集成ELK,如果只是安装Kafka,这篇也是ok的,如果是为了了解ELK如果集成Kafka的,首先得先会安装ELK,可以参考这篇文章

【ELK】ElasticSearch+Logstash+Kibana搭建并集成SpringBoot_阿小冰的博客-CSDN博客【ELK】ElasticSearch+Logstash+Kibana搭建并集成SpringBoothttps://blog.csdn.net/qq_38377525/article/details/124449938

安装

ZooKeeper的安装

1、下载安装包

Index of /dist/zookeeper/zookeeper-3.4.9icon-default.png?t=M3K6http://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/可以在上面的这个链接下载,我这里直接用的3.4.9版本的zk

2、放到服务器上,解压到指定目录

[root@localhost home]# tar -zxvf zookeeper-3.4.9.tar.gz -C /usr/local

3、切换到安装目录

[root@localhost home]# cd /usr/local/zookeeper-3.4.9/

4、复制一份出来配置文件

[root@localhost zookeeper-3.4.9]# cp conf/zoo_sample.cfg conf/zoo.cfg

5、启动zk

  1. [root@localhost zookeeper-3.4.9]# bin/zkServer.sh start
  2. ZooKeeper JMX enabled by default
  3. Using config: /usr/local/zookeeper-3.4.9/bin/../conf/zoo.cfg
  4. Starting zookeeper ... STARTED

6、查看进程

  1. [root@localhost zookeeper-3.4.9]# ps -ef|grep zoo
  2. root 29957 1 5 19:40 pts/3 00:00:00 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper-3.4.9/bin/../build/classes:/usr/local/zookeeper-3.4.9/bin/../build/lib/*.jar:/usr/local/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/usr/local/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/usr/local/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/usr/local/zookeeper-3.4.9/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/zookeeper-3.4.9/bin/../conf/zoo.cfg
  3. root 29985 11939 0 19:40 pts/3 00:00:00 grep --color=auto zoo

单机版zk安装成功

Kafka的安装 

 1、下载安装包

[root@localhost home]# wget http://archive.apache.org/dist/kafka/3.0.1/kafka_2.13-3.0.1.tgz

这个过程,时间有点长,因为直接从国外网站上直接下载的,

2、解压到指定目录

[root@localhost home]# tar -zxvf kafka_2.13-3.0.1.tgz -C /usr/local/

3、进入安装目录并创建软连接

  1. [root@localhost home]# cd /usr/local/
  2. [root@localhost local]# ln -s kafka_2.13-3.0.1 kafka

4、编辑配置文件,修改一下配置

  1. [root@localhost kafka]# vim config/server.properties
  2. broker.id=1 #对应zookeeper的id
  3. listeners=PLAINTEXT://1127.0.0.1:9092 #配置自己的ip地址
  4. log.retention.hours=24 #改成24小时
  5. zookeeper.connect=127.0.0.12181#配置集群

5、后台启动

[root@localhost kafka]# bin/kafka-server-start.sh -daemon config/server.properties

6、查看日志是否启动成功

  1. [root@localhost kafka]# tail -f logs/server.log
  2. [2022-04-27 21:49:38,049] INFO [GroupMetadataManager brokerId=1] Removed 0 expired offsets in 9 milliseconds. (kafka.coordinator.group.GroupMetadataManager)
  3. [2022-04-27 21:49:38,070] INFO [ProducerId Manager 1]: Acquired new producerId block (brokerId:1,blockStartProducerId:0,blockEndProducerId:999) by writing to Zk with path version 1 (kafka.coordinator.transaction.ProducerIdManager)
  4. [2022-04-27 21:49:38,091] INFO [TransactionCoordinator id=1] Starting up. (kafka.coordinator.transaction.TransactionCoordinator)
  5. [2022-04-27 21:49:38,093] INFO [TransactionCoordinator id=1] Startup complete. (kafka.coordinator.transaction.TransactionCoordinator)
  6. [2022-04-27 21:49:38,113] INFO [Transaction Marker Channel Manager 1]: Starting (kafka.coordinator.transaction.TransactionMarkerChannelManager)
  7. [2022-04-27 21:49:38,156] INFO [/config/changes-event-process-thread]: Starting (kafka.common.ZkNodeChangeNotificationListener$ChangeEventProcessThread)
  8. [2022-04-27 21:49:38,182] INFO [SocketServer brokerId=1] Started processors for 1 acceptors (kafka.network.SocketServer)
  9. [2022-04-27 21:49:38,223] INFO Kafka version : 2.1.1 (org.apache.kafka.common.utils.AppInfoParser)
  10. [2022-04-27 21:49:38,223] INFO Kafka commitId : 21234bee31165527 (org.apache.kafka.common.utils.AppInfoParser)
  11. [2022-04-27 21:49:38,225] INFO [KafkaServer id=1] started (kafka.server.KafkaServer)

或者查看进程

[root@localhost kafka]# ps -ef|grep kafka

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/580163
推荐阅读
相关标签
  

闽ICP备14008679号