首页 > 其他分享 >kafka集群部署教程

kafka集群部署教程

时间:2023-04-14 16:44:26浏览次数:36  
标签:bin 10 教程 zookeeper kafka 集群 usr local

#### 部署zookeeper集群

1、先部署zookeeper集群一般是3个节点,安装zookeeper 依赖java 环境先安装 jdk

      yum install java-1.8.0-openjdk-devel -y

      java -version #查看jdk版本

2、创建工作目录(3个节点都需要执行)

    mkdir -p /usr/local/zookeeper

    日志存储目录(3个节点都需要执行)

   mkdir -p /usr/local/zookeeper/dataDir

3、下载安装包并解压(3个节点都需要执行)

     cd /usr/local/zookeeper

     wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz

     tar -xvf  apache-zookeeper-3.8.0-bin.tar.gz  

4、新增实例文件(3个节点都需要执行)myid文件后续zoo.cfg中使用

echo "1" > /usr/local/zookeeper/dataDir/myid

echo "2" > /usr/local/zookeeper/dataDir/myid

echo "3" > /usr/local/zookeeper/dataDir/myid

5、配置修改,并scp 到另外2台机器上面

cd /usr/local/zookeeper/apache-zookeeper-3.8.0-bin/conf

mv zoo_sample.cfg zoo.cfg

vim  zoo.cfg

egrep -v "^#|^$" zoo.cfg

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/dataDir
server.1=10.x.x.2:2888:3888
server.2=10.x.x.3:2888:3888
server.3=10.x.x.4:2888:3888
clientPort=2181
maxClientCnxns=60

6、关闭防火墙

systemctl stop firewalld && systemctl disable firewalld

7、配置systemd 服务

cd /usr/lib/systemd/system/

 

创建zookeeper 服务文件

cat zookeeper.service

[Unit]
Description=zookeeper.service
After=network.target

[Service]
Type=forking
Environment="PATH=/usr/local/jdk1.8.0_311/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
User=root
Group=root
ExecStart=/usr/local/zookeeper/apache-zookeeper-3.8.0-bin/bin/zkServer.sh start
ExecStop=/usr/local/zookeeper/apache-zookeeper-3.8.0-bin/bin/zkServer.sh stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

刷新 systemctl 

systemctl daemon-reload

 systemctl enable  --now zookeeper

8、 查看集群状态

/usr/local/zookeeper/apache-zookeeper-3.8.0-bin/bin/zkServer.sh status

#######部署kafka集群###########

1、创建工作目录(3个节点都需要执行)

mkdir -p /usr/local/kafka

2、下载安装包解压(3个节点都需要执行)

cd /usr/local/kafka

wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/3.4.0/kafka_2.13-3.4.0.tgz

tar zxf  kafka_2.13-3.4.0.tgz

3、cd /usr/local/kafka/kafka_2.13-3.4.0/config (3个节点都需要只需要关注修改项broker.id、listeners、zookeeper.connect、log.dirs)

#节点1#

vim server.properties

broker.id=0
listeners=PLAINTEXT://10.x.x.2:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/var/log/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.x.x.2:2181,10.x.x.3:2181,10.x.x.4:2181
zookeeper.connection.timeout.ms=18000
group.initial.rebalance.delay.ms=0

#节点2#

broker.id=1
listeners=PLAINTEXT://10.x.x.3:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/var/log/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.x.x.2:2181,10.x.x.3:2181,10.x.x.4:2181
zookeeper.connection.timeout.ms=18000
group.initial.rebalance.delay.ms=0

#节点3#

 

 broker.id=3
listeners=PLAINTEXT://10.x.x.4:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/var/log/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.x.x.2:2181,10.x.x.3:2181,10.x.x.4:2181
zookeeper.connection.timeout.ms=18000
group.initial.rebalance.delay.ms=0

4、 配置 systemd kafka服务,创建kafka服务文件(3台节点都需要执行)

cd /lib/systemd/system/

vim kafka.service

[Unit]
Description=broker(Apache Kafka server)
After=network.target zookeeper.service

[Service]
Type=simple
Environment="PATH=/usr/local/jdk1.8.0_311/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
User=root
Group=root
ExecStart=/usr/local/kafka/kafka_2.13-3.4.0/bin/kafka-server-start.sh /usr/local/kafka/kafka_2.13-3.4.0/config/server.properties
ExecStop=/usr/local/kafka/kafka_2.13-3.4.0/bin/kafka-server-stop.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

 5、 刷新systemctl 

systemctl daemon-reload

设置kafka开机自启动

systemctl enable kafka

 

标签:bin,10,教程,zookeeper,kafka,集群,usr,local
From: https://www.cnblogs.com/zbhlinux/p/17318413.html

相关文章

  • Prometheus监控zookeeper集群(1)
    因为zookeeper版本较低为3.4.x版本,所有采用zookeeper_exporter方式采集数据1.下载(zookeeper_exporter采集器)https://github.com/carlpett/zookeeper_exporter/releases/download/v1.1.0/zookeeper_exporter2.传到liunx上/opt目录下,没有目录可以自行创建3.授予权限chmod755......
  • zookeeper集群安装
    解压zookeeper[root@masterpack]#tar-zxvfzookeeper-3.4.10.tar.gz-C/usr/local/src/配置环境变量#ZOOKEEPER_HOMEexportZOOKEEPER_HOME=/usr/local/src/zookeeperexportPATH=$PATH:$ZOOKEEPER_HOME/bin创建data文件用于存放数据信息创建logs文件用于存放日志......
  • hadoop伪分布式集群的安装(不是单机版)
    准备工作三台虚拟机,关闭防火墙,关闭selinux查看防火状态systemctlstatusfirewalld暂时关闭防火墙systemctlstopfirewalld永久关闭防火墙systemctldisablefirewalld查看selinux状态getenforce暂时关闭selinuxsetenforce0永久关闭selinux在/etc/selinux/confi......
  • 发卡网平台搭建架设教程
    发卡网平台搭建架设教程我是艾西,今天跟大家聊聊什么是发卡网以及发卡平台的搭建架设发卡网平台:主要是寄售一些虚拟产品和服务。发卡网具体能售卖些什么呢?例如:电商优惠券/折扣卷、论坛邀请码、注册码以及积分充值卡,软件认证码、注册码还有各大视频平台的CDK激活码等!当然还可以提供......
  • Xshell 免费下载使用教程
    小白教程新电脑要安装xshell,不想付费不想破解嫌麻烦怎么办,官方提供了免费版(家庭个人免费许可证),只要提供一个邮箱即可! 一 首先打开官方网站(https://www.xshell.com/zh/),切记其他网站下载的有广告或者病毒  二选择你自己适用的软件,看个人情况我这里就用xshell三选择......
  • charles下载与安装教程
    一安装目的由于公司大多数项目都迁移到https,之前的fiddler由于没有安装证书,抓取不到https的接口,决定重新安装charles抓包工具,排查线上问题; 二官网下载https://www.charlesproxy.com/latest-release/download.do选择合适的版本进行安装; 三激活打开:https://www.zzzmode......
  • Three.js教程:鼠标操作三维场景
    推荐:将NSDT场景编辑器加入你3D工具链其他工具系列:NSDT简石数字孪生为了使用鼠标操作三维场景,可以借助three.js众多控件之一OrbitControls.js,可以在下载的three.js-master文件中找到(three.js-master\examples\js\controls)。然后和引入three.js文件一样在html文件中引入控件Orb......
  • 使用阿里云下载海外Docker镜像教程
    1、准备Github帐号自行注册:https://github.com/2、打开阿里云-容器镜像服务https://cr.console.aliyun.com/cn-hangzhou/instances3、绑定Github帐号4、GitHub仓库准备4.1.、创建一个项目 4.2、项目创建一个Dockerfile 4.3、往Dockerfile写入指令FROMregis......
  • Groovy教程
    基础语法1.输出字符串println(“HelloWorld”);2.定义变量defstudent='aaa'3.关键字关键字含义as强制类型转换assert断言break跳出循环caseswitch语句中的分支catch捕获异常class定义类const常量continue继续循环def......
  • SolidWorks【SW 】2023 SP1.0 中文版安装包下载及【SW 】2023 图文安装教程​(亲测)
    SolidWorks是一款非常实用高效的机械CAM和CAE分析辅助工具,具有非常直观的3D开发环境,可以帮助用户轻松设计和制造各种复杂产品,SolidWorks软件还具有工程分析和准备系统,使您的设计和制造资源的生产效率得到充分发挥。更好的产品可以更快更便宜地创造出来。%64%6f%63%73%2e%71%71%2e%......