当前位置:首页 > 服务端 > kafka安装(一)

kafka安装(一)

2022年11月07日 22:46:24服务端18

一、下载地址:

链接: https://pan.baidu.com/s/18vp_qCGZgZNjtaewOCc3Uw  

密码:54jh

二、启动zookeeper:

[root@javaxiaobang kafka]# bin/zookeeper-server-start.sh config/zookeeper.properties > zookeeper.log &
[1] 4232 
[root@javaxiaobang kafka]#

三、配置kafka(server.properties)

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# see kafka.server.KafkaConfig for additional details and defaults

############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.
#节点的唯一编号(整数)
broker.id=0

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
#服务端口默认9092
listeners=PLAINTEXT://:9092

# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092

# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL

# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3

# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8

# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400

# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400

# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600


############################# Log Basics #############################

# A comma separated list of directories under which to store log files
#kafka数据的存储目录,一般都改为逗号隔开的多个目录(方便磁盘扩充)
log.dirs=/tmp/kafka/db0

# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
#默认主题分片数量
num.partitions=1

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1

############################# Internal Topic Settings  #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1

############################# Log Flush Policy #############################

# Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
#    1. Durability: Unflushed data may be lost if you are not using replication.
#    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.

# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000

# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000

############################# Log Retention Policy #############################

# The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.

# The minimum age of a log file to be eligible for deletion due to age
# 日志保留策略1-副本保留多长时间
log.retention.hours=168

# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
# 日志保留策略2-副本超过多少字节
log.segment.bytes=1073741824

# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=300000

############################# Zookeeper #############################

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
# 元数据存放的地址
zookeeper.connect=localhost:2181

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000


############################# Group Coordinator Settings #############################

# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=0

四、启动kafka:

[root@javaxiaobang kafka]# bin/kafka-server-start.sh config/server-0.properties > kafka-0.log &
[2] 7761
[root@javaxiaobang kafka]# bin/kafka-server-start.sh config/server-1.properties > kafka-1.log &
[3] 8126
[root@javaxiaobang kafka]# bin/kafka-server-start.sh config/server-2.properties > kafka-2.log &
[4] 8493
[root@javaxiaobang kafka]#

五、创建主题:

[root@javaxiaobang kafka]# bin/kafka-topics.sh --create --bootstrap-server 123.56.224.5:9092 --replication-factor 3 --partitions 3 --topic test-topic
[root@javaxiaobang kafka]# bin/kafka-topics.sh --describe --bootstrap-server 123.56.224.5:9092 --topic test-topic
Topic:test-topic	PartitionCount:3	ReplicationFactor:3	Configs:segment.bytes=1073741824
	Topic: test-topic	Partition: 0	Leader: 2	Replicas: 2,1,0	Isr: 2,1,0
	Topic: test-topic	Partition: 1	Leader: 1	Replicas: 1,0,2	Isr: 1,0,2
	Topic: test-topic	Partition: 2	Leader: 0	Replicas: 0,2,1	Isr: 0,2,1

六、发送消息:

[root@javaxiaobang kafka]# bin/kafka-console-producer.sh --broker-list 123.56.224.5:9092 --topic test-topic
>第一条消息
>第二条消息
>第三条消息
>

七、消费消息:

[root@javaxiaobang kafka]# bin/kafka-console-consumer.sh --bootstrap-server 123.56.224.5:9092 --from-beginning --topic test-topic
第一条消息
第二条消息
第三条消息

八、删除topic

[root@javaxiaobang kafka]# bin/kafka-topics.sh --delete --bootstrap-server 123.56.224.5:9093 --topic javaxiaobangtopic
[root@javaxiaobang kafka]#

九、停止broker:

[root@javaxiaobang kafka]# bin/kafka-server-stop.sh

十、监控管理

https://github.com/quantifind/KafkaOffsetMonitor

java -cp KafkaOffsetMonitor-assembly-0.2.0.jar com.quantifind.kafka.offsetapp.OffsetGetterWeb --zk 127.0.0.1:2181 --port 9090 --refresh 10.seconds --retain 2.days &

kafka安装(一) _ JavaClub全栈架构师技术笔记

十一、zookeeper监控工具:

java -jar zookeeper-dev-ZooInspector.jar

kafka安装(一) _ JavaClub全栈架构师技术笔记

 

作者:架构师肖邦
来源链接:https://blog.csdn.net/sunrisetg/article/details/104999731

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。


本文链接:https://www.javaclub.cn/server/68389.html

分享给朋友:

“kafka安装(一)” 的相关文章

Kafka 安装和测试

Kafka 安装和测试

1. 简介 kafka (官网地址: http://kafka.apache.org)是一款分布式消息发布和订阅的系统,具有高性能和高吞吐率。 i. 消息的发布(publish)称作produ...

Kafka安装之二 在CentOS 7上安装Kafka

Kafka安装之一  Zookeeper Kafka安装之二 在CentOS 7上安装Kafka 一、简介         Kafka是由Apache软件基金会开发的一个开...

kafka Java客户端之 consumer API 多线程消费消息

kafka Java客户端之 consumer API 多线程消费消息

kafka consumer 线程设计 Kafka Java Consumer采用的是单线程的设计。其入口类KafkaConsumer是一个双线程的设计,即用户主线程和心跳线程。 用户主线程,指的是启动Consumer应用程序main方法的线程,心...

Kafka中错误:Unrecognized VM option ‘UseCompressedOops’ Error: Clould not create the Java Vritual Machine. Error: A fatal exception has occurres . Program will exit.

Kafka中错误:Unrecognized VM option ‘UseCompressedOops’ Error: Clould not create the Java Vritual Machine. Error: A fatal exception has occurres . Program will exit.

     错误的描述:   在kafka安装目录下,执行 $ bin/zookeeper-server-start.sh config/zookeeper.properties &    Unrecognized VM op...

Ubuntu20.04安装kafka

Ubuntu20.04安装kafka

文章目录 简介 为什么需要消息中间件 Kafka一代 - 消息队列 Kafka二代 - Partition Kafka三代 - Broker集群...

kafka-eagle安装

kafka-eagle安装

1、首先去官网下载eagle http://download.kafka-eagle.org/ 2、上传至服务器,解压到安装目录,我使用的是1.4.4版本 tar -xzf kafka-eagle-bin-1.4.4.tar.gz -C /apps/ cd /a...

mac/linux 下kafka安装

Kafka安装和配置,依赖zookeeper  安装和启动zookeeper (1)下载 http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar...

查询linux kafka安装目录,Kafka 1.0.0安装和配置--Linux篇

阅读目录: 1. 关闭防火墙和Selinux 2. 安装所需环境JDK,Zookeeper 3. 下载Kafka 1.0.0版本 4. 配置Kafka 5. 启动Kafka并验证 6. 报错及解决 7. 说明...

kafka在windows下的安装与配置

kafka在windows下的安装与配置

kafka在windows下的安装与配置 1.配置JDK (1)配置环境变量 (2)打开Dos界面,检查 2.配置Zookeeper (1)下载稳定版。 下载地址:http://mirrors.hust.e...

Kafka 环境安装与使用

Kafka 环境安装与使用

Kafka 环境安装 1.上传及解压 tar zxvf /opt/software/kafka_2.11-0.11.0.2.gz -C /opt/install/ 2.创建软连接和环境变量[可选] cd /opt/install...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。