91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

docker怎么部署kafka

發布時間:2021-10-21 13:34:39 來源:億速云 閱讀:205 作者:小新 欄目:開發技術

小編給大家分享一下docker怎么部署kafka,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

1. 搭建docker

這里我直接用的是docker-compose部署,所以需要提前安裝好compose。
既然要用compose那么yml文件自然是少不了的。

首先要新建一個目錄,并在目錄中新建一個yml文件

docker怎么部署kafka

文件的內容如下:

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    volumes:
      - ./data:/data
    ports:
      - "2181:2181"
       
  kafka:
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME:127.0.0.1
      KAFKA_MESSAGE_MAX_BYTES: 2000000
      KAFKA_CREATE_TOPICS: "Topic1:1:3,Topic2:1:1:compact"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    volumes:
      - ./kafka-logs:/kafka
      - /var/run/docker.sock:/var/run/docker.sock
 
  kafka-manager:
    image: sheepkiller/kafka-manager
    ports:
      - 9020:9000
    environment:
      ZK_HOSTS: zookeeper:2181

接著利用這個yml文件啟動我們的項目

$ docker-compose up -d

可以看到新建了三個容器

docker怎么部署kafka

2.進入容器

我們通過以下命令進入到kafka容器的交互模式

$ docker exec -it kafkademo01_kafka_1 /bin/bash

因為高版本的kafka內置了zookeeper,所以我們無需進入zookeeper容器。所以yml文件中關于zookeeper的部署是可以省略的。

然后進入kafka的根目錄

$ cd /opt/kafka

3.修改配置文件

$ cd /config

docker怎么部署kafka

首先要修改的是zookeeper的配置文件:zookeeper.properties
(注釋已刪除)

dataDir=/opt/kafka/zooLogs
clientPort=2182
maxClientCnxns=0
admin.enableServer=false

然后修改kafka的配置文件:server.porperties
(注釋已刪除)

############################# Server Basics #############################                                                                                                                                                                                                                                                                                                             
broker.id=0                                                                                                                                        
############################# Socket Server Settings #############################                                                                                                                                                                                                                                                                                              
listeners=PLAINTEXT://127.0.0.1:9093

############################# Socket Server Settings #############################                                                                      
listeners=PLAINTEXT://127.0.0.1:9093                                                                                                                    
num.network.threads=3                                                                                                                                   
num.io.threads=8                                                                                                                                        
socket.send.buffer.bytes=102400                                                                                                                         
socket.receive.buffer.bytes=102400
                                                          
socket.request.max.bytes=104857600                                                                                                                      
############################# Log Basics #############################                                                                                  
log.dirs=/opt/kafka/kafkaLogs                                                                                                                           
num.partitions=1                                                                                                                                        
num.recovery.threads.per.data.dir=1                                                                                                                     
############################# Internal Topic Settings  #############################                                                                                                   
offsets.topic.replication.factor=1                                                                                                                       
transaction.state.log.replication.factor=1                                                                                                               
transaction.state.log.min.isr=1                                                                                                                         
############################# Log Retention Policy #############################                                                                        
log.retention.hours=168                                                                                                                                                                                                                                               
log.segment.bytes=1073741824                                                                                                                            
log.retention.check.interval.ms=300000                                                                                                                  
############################# Zookeeper #############################                                                                                   
zookeeper.connect=127.0.0.1:2182                                                                                                       
zookeeper.connection.timeout.ms=18000                                                                                                                   
############################# Group Coordinator Settings #############################                                                                  
group.initial.rebalance.delay.ms=0                                                                                                                      
port=9093                                                                                                                                                
advertised.host.name=127.0.0.1                                                                                                                           
message.max.bytes=2000000                                                                                                                                
advertised.port=9093

4.測試kafka

以下是一些基本的命令

啟動zookeeper

zookeeper-server-start.sh ../config/zookeeper.properties

啟動kafka

kafka-server-start.sh ../config/server.properties

創建一個主題

kafka-topics.sh --create --zookeeper 127.0.0.1:2182 --replication-factor 1 --partitions 1 --topic test

查看創建的主題

kafka-topics.sh --list --zookeeper 127.0.0.1:2182

生產者

kafka-console-producer.sh --broker-list 127.0.0.1:9093 --topic test

消費者

kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9093 --topic test --from-beginning

以上是“docker怎么部署kafka”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

铜山县| 洛隆县| 余庆县| 南陵县| 蓬莱市| 广昌县| 洪洞县| 秦安县| 五家渠市| 临夏县| 锡林浩特市| 大城县| 疏勒县| 甘洛县| 义乌市| 白水县| 五华县| 呼玛县| 横山县| 石台县| 宝坻区| 安丘市| 南郑县| 民县| 文水县| 临江市| 泽普县| 咸宁市| 左贡县| 五华县| 华安县| 湘西| 手游| 万州区| 铅山县| 临夏市| 绍兴市| 土默特左旗| 藁城市| 房产| 新建县|