日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

kafka集群安装

發布時間:2025/4/5 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 kafka集群安装 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 在根目錄創建kafka文件夾(service1、service2、service3都創建)

[root@localhost /]# mkdir kafka

2.通過Xshell上傳文件到service1服務器:上傳kafka_2.9.2-0.8.1.1.tgz到/software文件夾

3.遠程copy將service1下的/software/kafka_2.9.2-0.8.1.1.tgz到service2、service3

[root@localhost software]# scp -r /software/kafka_2.9.2-0.8.1.1.tgz root@192.168.2.212:/software/

[root@localhost software]# scp -r /software/kafka_2.9.2-0.8.1.1.tgz root@192.168.2.213:/software/

3.copy /software/kafka_2.9.2-0.8.1.1.tgz到/kafka/目錄(service1、service2、service3都執行)

[root@localhost software]# cp /software/kafka_2.9.2-0.8.1.1.tgz /kafka/

4.安裝解壓kafka_2.9.2-0.8.1.1.tgz(service1、service2、service3都執行)

[root@localhost /]# cd /kafka/

[root@localhost kafka]# tar -zxvf kafka_2.9.2-0.8.1.1.tgz

5.創建kafka消息目錄(service1,service2,service3都要創建)

[root@localhost kafka]# mkdir kafkaLogs

6. 修改kafka的配置文件(service1,service2,service3都要配置)

[root@localhost /]# cd /kafka/kafka_2.9.2-0.8.1.1/

[root@localhost kafka_2.9.2-0.8.1.1]# cd config/

[root@localhost config]# ls

consumer.properties log4j.properties producer.properties server.properties test-log4j.properties tools-log4j.properties zookeeper.properties

[root@localhost config]# vi 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

#

#www.apache.org/licenses/LI…

#

# 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 port the socket server listens on

port=19092 --當前broker對外提供的TCP端口,默認9092

# Hostname the broker will bind to. If not set, the server will bind to all interfaces

host.name=192.168.2.213 --一般是關閉狀態,我們要將它打開,如果dns解析失敗,會出現文件句柄泄露,不要小看dns解析失敗率,如果dns解析失敗率為萬分之一,由于kafka的性能非常高,每個topic的每個分區,每秒可以處理十萬多條的數據,即使萬分之一的失敗率,每秒也要泄露10個文件句柄,很快句柄數就會泄露完畢,就會超過linux打開文件的數,就會出現異常,所以我們配置ip,就不會進行dns解析

# Hostname the broker will advertise to producers and consumers. If not set, it uses the

# value for "host.name" if configured. Otherwise, it will use the value returned from

# java.net.InetAddress.getCanonicalHostName().

#advertised.host.name=

# The port to publish to ZooKeeper for clients to use. If this is not set,

# it will publish the same port that the broker binds to.

#advertised.port=

# The number of threads handling network requests

num.network.threads=2 --broker網絡處理的線程數,一般不做處理

# The number of threads doing disk I/O

num.io.threads=8 --broker io處理的線程數,這個數量一定要比log.dirs的目錄數要大

# The send buffer (SO_SNDBUF) used by the socket server

socket.send.buffer.bytes=1048576 --將發送的消息先放到緩沖區,當到達一定量的時候再一次性發出

# The receive buffer (SO_RCVBUF) used by the socket server

socket.receive.buffer.bytes=1048576 --kafka接受消息的緩沖區,當接受的數量達到一定量的時候再寫入磁盤

# The maximum size of a request that the socket server will accept (protection against OOM)

socket.request.max.bytes=104857600 --像kafka發送或者請求消息的最大數,此設置不能超過java堆棧大小

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

# A comma seperated list of directories under which to store log files

log.dirs=/kafka/kafkaLogs --多個目錄可以用,隔開

# 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=2 --一個topic默認分區數

############################# 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 exceessive 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

log.retention.hours=168

message.max.byte=5048576 --kafka每條消息容納的最大大小

default.replication.factor=2 --默認的復制因子,默認消息只有一個副本,不太安全,所以設置為2,如果某個分區的消息失敗了,我們可以使用另一個分區的消息服務

replica.fetch.max.byte=5048576 --kafka每條消息容納的最大大小

# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining

# segments don't drop below log.retention.bytes.

#log.retention.bytes=1073741824

# The maximum size of a log segment file. When this size is reached a new log segment will be created.

log.segment.bytes=536870912 --消息持久化的最大大小

# 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=60000

# By default the log cleaner is disabled and the log retention policy will default to just delete segments after their retention expires.

# If log.cleaner.enable=true is set the cleaner will be enabled and individual logs can then be marked for log compaction.

log.cleaner.enable=false --不使用log壓縮

############################# 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=192.168.2.211:2181,192.168.2.212:2181,192.168.2.213:2181 --zk地址

# Timeout in ms for connecting to zookeeper

zookeeper.connection.timeout.ms=1000000

7.啟動kafka服務

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

[root@localhost bin]# jps

27413 Kafka

27450 Jps

17884 QuorumPeerMain

8.驗證kafka集群

[root@localhost bin]# ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 1 --topic test

Created topic "test".

9.在service1上開啟producer程序

./kafka-console-producer.sh --broker-list 192.168.2.211:9092 --topic test

[root@localhost bin]# ./kafka-console-producer.sh --broker-list 192.168.2.211:9092 --topic test

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: Seewww.slf4j.org/codes.html#…for further details.

10. 在service2上開啟consumer程序

[root@localhost bin]# ./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: Seewww.slf4j.org/codes.html#…for further details.

11.在producer中發送消息:hello jeesz

[root@localhost bin]# ./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: Seewww.slf4j.org/codes.html#…for further details.

hello jeesz

12. 在consumer中接受到消息

[root@localhost bin]# ./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: Seewww.slf4j.org/codes.html#…for further details.

hello jeesz

愿意了解框架技術或者源碼的朋友直接求求:2042849237


轉載于:https://juejin.im/post/5a4dce8d5188257d38445f26

總結

以上是生活随笔為你收集整理的kafka集群安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: youjizz国产精品| 黑人巨大国产9丨视频 | 性视频欧美 | 中文久草 | 91亚洲精品一区二区乱码 | 欧美激情视频网 | 人妖干美女 | 人人插人人射 | 疯狂做爰的爽文多肉小说王爷 | 一区二区三区日韩精品 | 色碰视频 | 欧美黑人精品一区二区 | 中文在线а√天堂 | 欧美精品一区二区三区三州 | 久久精品视频在线 | 四虎影院一区二区 | 76少妇精品导航 | 亚洲欧美综合自拍 | 日本做爰全过程免费看 | 熟妇人妻中文av无码 | 丰满熟妇肥白一区二区在线 | 久久人人艹 | 久久国产视频一区 | 99免费在线视频 | 在线精品福利 | 成人福利网站在线观看 | 超污视频软件 | 亚洲一区二区视频在线观看 | 国产精品成人免费一区二区视频 | 日韩人妻无码精品久久免费 | 一本大道综合伊人精品热热 | www.狠狠艹 | 波多野结衣二区 | 四虎在线免费视频 | 国产精品伦子伦 | 亚洲精品一二三区 | 国产欧美一区二区三区在线看蜜臀 | 国产精华一区二区三区 | 国产精品外围 | 久久无码人妻丰满熟妇区毛片 | 亚洲精品国产精品国 | 亚洲欧美天堂网 | 国产欧美在线观看视频 | 欧美大片黄 | 69色| 男女黄网站 | 国产乱子伦精品无码专区 | 在线免费视频 | 久久久免费高清视频 | 强开乳罩摸双乳吃奶羞羞www | 国产一国产二国产三 | av一区在线播放 | 男女超碰| 黄色大视频 | 国产在线视频网站 | 久草视频观看 | 伊人ab | 国产精品二区三区 | 国产午夜视频在线观看 | 三级黄色短视频 | 日本激情在线 | 无码人妻精品一区二区蜜桃色欲 | 亚洲色偷偷色噜噜狠狠99网 | 公车激情云雨小说 | 最黄一级片 | 天堂va蜜桃 | 天天插伊人| 国产13页| 在线看片福利 | 欧美高清大白屁股ass18 | 亚洲国产高清视频 | 69视频免费在线观看 | 91国在线视频 | 野花国产精品入口 | 欧美一区二区三区爱爱 | 又黄又爽的视频在线观看 | h色视频在线观看 | 亚洲免费成人 | 亚洲高清久久 | 亚洲一区二区福利视频 | 日韩理论在线 | 亚洲AV无码精品黑人黑人 | 最近中文字幕av | 美女黄色一级 | 北条麻妃一区二区三区免费 | 五个女闺蜜把我玩到尿失禁 | 91看视频 | 精品欧美一区二区精品久久 | 国产aa视频 | 狠狠撸在线 | 成人三级视频 | 欧美亚洲精品在线观看 | 人人玩人人干 | 麻豆视频入口 | 国产清纯白嫩初高中在线观看性色 | av第一页| 韩国美女黄色片 | 国产探花视频在线观看 | 国产精品一区二区三区久久 |