首页 > 系统相关 >Centos7的kafka集群搭建

Centos7的kafka集群搭建

时间:2023-03-15 20:48:19浏览次数:60  
标签:service zookeeper 192.168 kafka Centos7 集群 usr var

CentOS 7搭建kafka集群

原创 莫问 记录栈 2022-11-16 19:49 发表于陕西 收录于合集 #centos6个 #kafka1个 #linux9个 #kafka集群1个

/**

*@系统:CentOS Linux release 7.9.2009 (Core)

*@说明:jdk-11.0.12 | apache-zookeeper-3.7.1 | kafka_2.12-3.3.1

* 注意:因为有大部分操作是相同的,所以使用的是工具的批操作

*/

 

一、准备工作

1. 下载 jdk11

https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html#license-lightbox

2. 下载 zookeeper

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

3. 下载 kafka

https://downloads.apache.org/kafka/3.3.1/kafka_2.12-3.3.1.tgz

4. 修改主机名

# hostnamectl set-hostname kafka01# hostnamectl set-hostname kafka02# hostnamectl set-hostname kafka03

5. 修改 hosts

# vim /etc/hosts==== content ====192.168.137.129    kafka01192.168.137.130    kafka02192.168.137.131    kafka03==== / ====

6. 开放防火墙端口

# 生产环境注意修改zookeeper和kafka的端口# firewall-cmd --zone=public --add-port=2881/tcp --permanent# firewall-cmd --zone=public --add-port=3881/tcp --permanent# firewall-cmd --zone=public --add-port=9092/tcp --permanent# firewall-cmd --reload

二、安装 jdk11

1. 安装

# rpm -ivh jdk-11.0.12_linux-x64_bin.rpm

2. 添加环境变量

# ls /usr/java# vim /etc/profile==== content ====export JAVA_HOME=/usr/java/jdk-11.0.12export PATH=$PATH:$JAVA_HOME/bin==== / ====# . /etc/profile ##source /etc/profile

3. 验证

# java -versionjava version "11.0.12" 2021-07-20 LTSJava(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)# cd $JAVA_HOME# pwd/usr/java/jdk-11.0.12

三、安装 zookeeper

1. 安装

# tar -zxf apache-zookeeper-3.7.1-bin.tar.gz -C /usr/local# cd /usr/local/# mv apache-zookeeper-3.7.1-bin zookeeper

2. 修改配置文件

# cd /usr/local/zookeeper/conf/# cp zoo_sample.cfg zoo.cfg# mkdir -p /var/zookeeper/data# 在对应的三台机子上分别执行# kafka01# vim zoo.cfg==== content ====dataDir=/var/zookeeper/dataserver.1=0.0.0.0:2881:3881server.2=192.168.137.130:2881:3881server.3=192.168.137.131:2881:3881==== / ====# echo 1 > /var/zookeeper/data/myid# cat /var/zookeeper/data/myid1# kafka02# vim zoo.cfg==== content ====dataDir=/var/zookeeper/dataserver.1=192.168.137.129:2881:3881server.2=0.0.0.0:2881:3881server.3=192.168.137.131:2881:3881==== / ====# echo 2 > /var/zookeeper/data/myid# cat /var/zookeeper/data/myid2# kafka03# vim zoo.cfg==== content ====dataDir=/var/zookeeper/dataserver.1=192.168.137.129:2881:3881server.2=192.168.137.130:2881:3881server.3=0.0.0.0:2881:3881==== / ====# echo 3 > /var/zookeeper/data/myid# cat /var/zookeeper/data/myid3

3. 添加系统服务

# cd /etc/systemd/system# vim zookeeper.service==== content ====[Unit]Description=Zookeeper Service
[Service]Type=simpleWorkingDirectory=/usr/local/zookeeper/PIDFile=/var/zookeeper/data/zookeeper_server.pidSyslogIdentifier=zookeeperExecStart=/usr/local/zookeeper/bin/zkServer.sh startExecStop=/usr/local/zookeeper/bin/zkServer.sh stopRestart=alwaysTimeoutSec=20SuccessExitStatus=130 143
[Install]WantedBy=multi-user.target==== / ====# systemctl daemon-reload# systemctl enable zookeeper.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/zookeeper.service to /etc/systemd/system/zookeeper.service.

四、安装 kafka

1. 安装

# tar -zxf kafka_2.13-3.3.1.tgz -C /usr/local/# mv kafka_2.13-3.3.1 kafka

2. 修改配置文件

# cd /usr/local/kafka/config# vim server.properties==== content ====# kafka01broker.id=0# listeners=PLAINTEXT://:9092listeners=PLAINTEXT://192.168.137.129:9092# advertised.listeners=PLAINTEXT://your.host.name:9092advertised.listeners=PLAINTEXT://192.168.137.129:9092# log.dirs=/tmp/kafka-logslog.dirs=/var/kafka/logs# zookeeper.connect=localhost:2181zookeeper.connect=192.168.137.129:2181,192.168.137.130:2181,192.168.137.131:2181/mykafka----------# kafka02broker.id=1# listeners=PLAINTEXT://:9092listeners=PLAINTEXT://192.168.137.130:9092# advertised.listeners=PLAINTEXT://your.host.name:9092advertised.listeners=PLAINTEXT://192.168.137.130:9092# log.dirs=/tmp/kafka-logslog.dirs=/var/kafka/logs# zookeeper.connect=localhost:2181zookeeper.connect=192.168.137.129:2181,192.168.137.130:2181,192.168.137.131:2181/mykafka----------# kafka03broker.id=2# listeners=PLAINTEXT://:9092listeners=PLAINTEXT://192.168.137.131:9092# advertised.listeners=PLAINTEXT://your.host.name:9092advertised.listeners=PLAINTEXT://192.168.137.131:9092# log.dirs=/tmp/kafka-logslog.dirs=/var/kafka/logs# zookeeper.connect=localhost:2181zookeeper.connect=192.168.137.129:2181,192.168.137.130:2181,192.168.137.131:2181/mykafka==== / ====

3. 添加系统服务

# cd /etc/systemd/system# vim kafka.service==== content ====[Unit]Requires=zookeeper.serviceAfter=zookeeper.service
[Service]Type=simpleExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.propertiesExecStop=/usr/local/kafka/bin/kafka-server-stop.shRestart=AlwaysTimeoutSec=20
[Install]WantedBy=multi-user.target==== / ====
# systemctl daemon-reload# systemctl enable kafka.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/kafka.service to /etc/systemd/system/kafka.service.# init 6

4. 验证

# kafka01# jps8977 Jps716 QuorumPeerMain8623 Kafka
# kafka02# jps8251 Kafka718 QuorumPeerMain8607 Jps

# kafka03# jps8994 Kafka9315 Jps712 QuorumPeerMain
# systemctl status zookeeper.service● zookeeper.service - Zookeeper Service Loaded: loaded (/etc/systemd/system/zookeeper.service; enabled; vendor preset: disabled) Active: active (running) # systemctl status kafka.service● kafka.service - Kafka service Loaded: loaded (/etc/systemd/system/kafka.service; enabled; vendor preset: disabled) Active: active (running)

 

-未完待续-

=推荐阅读=

=================================

Git基本操作(一)

=================================

记录栈 记录Linux技术、PHP技术、数据库技术、前端技术、PS技巧、IT技巧等...... 37篇原创内容 公众号

 

收录于合集 #centos  6个 上一篇华为云HECS基于Nginx部署zabbix5.0监控下一篇CentOS 7安装部署vsftpd服务 阅读 46   记录栈 37篇原创内容  

标签:service,zookeeper,192.168,kafka,Centos7,集群,usr,var
From: https://www.cnblogs.com/cherishthepresent/p/17219900.html

相关文章

  • kafka消费者不能消费信息
     1、在kafka查看主题__consumer_offsets的情况 $kafka_home/bin/kafka-topics.sh--describe--zookeeperhostname:2181 --topic__consumer_offsets 显示图片的......
  • nginx+lua+openresty+kafka相关问题汇总
    这里使用的是kafka插件是doujiang大佬的https://github.com/doujiang24/lua-resty-kafka,版本为v0.2.0。应用场景在nginx转发中,记录非200请求的信息,遂打算在log_by_lua*中......
  • kafka容器内的server.properties在哪里
    刚刚需要修改kafka的配置文件server.properties,网上都说在config目录下,可我进去kafka容器找了一圈都没有看到该目录; 最后运气好,终于发现了 ......
  • 【大数据】Centos7、Hadoop3.3.1、分布式搭建
    主要遵照 https://www.cnblogs.com/lehoso/p/15550119.html进行搭建,文章里写的很清楚了,我就不多说了。在搭建过程中,用思维导图绘制了一个大纲。可点击下载安装过程中的......
  • 故障etcd 节点 加入现有集群
    故障etcd节点加入现有集群恢复步骤:1、查看故障节点的etcd状态并关闭服务    systemctlstatusetcd &&  systemctlstopetcd 2、列出现有的集群节点IDE......
  • Kafka Rebalance-重平衡
    消费者组ConsumerGroupKafka提供的可扩展且具有容错性的消费者机制共享一个公共的ID,这个ID被称为GroupID。组内的所有消费者协调在一起来消费订阅主题(Subscribe......
  • 【Azure 微服务 Service Fabric 】新创建的Service Fabric集群,如何从本地机器上连接到
    问题描述当在Azure中成功创建一个ServiceFabricCluster服务后,我们能够在它的Overview页面中发现ServiceFabricExplorer的终结点,但是打开后,因为不知道如何获取证书,所以......
  • Docker搭建Mysql集群
    Docker搭建Mysql集群前言:使用PXC集群方案搭建集群安装PXC镜像dockerpullpercona/percona-xtradb-cluster:5.7.21改名dockertagpercona/percona-xtradb-clus......
  • Kafka为什么性能这么快
    1、页缓存技术pagecacheKafka是基于操作系统的页缓存(pagecache)来实现文件写入的,我们也可以称之为oscache,意思就是操作系统自己管理的缓存。Kafka在写入磁盘文件......
  • 高可用的kubernetes集群安装
    一、架构设计二、集群规划 IP集群角色描述110.10.0.115keepalived虚拟IP虚拟IP,对10.10.0.15、10.10.0.29做keepalived110.10.0.15master、......