docker-compose创建kafka支持SASL_PLAINTEXT

# 1 mkdir conf
mkdir conf

# 2 create file zoo.cfg 
cat > conf/zoo.cfg <<-"EOF"
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/zookeeper-3.4.13/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature

autopurge.purgeInterval=1
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
requireClientAuthScheme=sasl
jaasLoginRenew=3600000
zookeeper.sasl.client=true
EOF

# 3 create file server_jaas.conf
cat > conf/server_jaas.conf <<-"EOF"
Client {
    org.apache.zookeeper.server.auth.DigestLoginModule required
    username="admin"
    password="12345678";
};
Server {
    org.apache.zookeeper.server.auth.DigestLoginModule required
    username="admin"
    password="12345678"
    user_super="12345678"
    user_admin="12345678";
};
KafkaServer {
    org.apache.kafka.common.security.plain.PlainLoginModule required
    username="admin"
    password="12345678"
    user_admin="12345678";
};
KafkaClient {
    org.apache.kafka.common.security.plain.PlainLoginModule required
    username="admin"
    password="12345678";
};
EOF

# 4 create file .env
cat > .env <<-"EOF"
HOSTIP=10.10.10.1
KAFKA_PORT=9092
EOF

# 5 create file docker-compose.yaml
cat > docker-compose.yml <<-"EOF"
name: "P1"
version: "3"
networks:
  net:
    driver: bridge  

services:
  zookeeper_sasl:
    image: wurstmeister/zookeeper
    networks:
      - net
    restart: always
    environment:
      SERVER_JVMFLAGS: '-Djava.security.auth.login.config=/opt/zookeeper-3.4.13/secrets/server_jaas.conf'
    volumes:
      - ./conf/zoo.cfg:/opt/zookeeper-3.4.13/conf/zoo.cfg
      - ./conf/server_jaas.conf:/opt/zookeeper-3.4.13/secrets/server_jaas.conf
    ports:
      - "2181:2181"
    deploy:
      resources:
        limits:
          cpus: '4'
          memory: 4G
        reservations:
          cpus: '0.5'
          memory: 200M 

  kafka_sasl:
    image: wurstmeister/kafka
    networks:
      - net
    restart: always
    environment:
      KAFKA_OPTS: '-Djava.security.auth.login.config=/opt/kafka/secrets/server_jaas.conf'
      KAFKA_BROKER_ID: 0
      KAFKA_ADVERTISED_LISTENERS: SASL_PLAINTEXT://${HOSTIP}:${KAFKA_PORT}
      KAFKA_ADVERTISED_PORT: ${KAFKA_PORT}
      KAFKA_LISTENERS: SASL_PLAINTEXT://0.0.0.0:${KAFKA_PORT}
      KAFKA_SECURITY_INTER_BROKER_PROTOCOL: SASL_PLAINTEXT
      KAFKA_PORT: ${KAFKA_PORT}
      KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN
      KAFKA_SASL_ENABLED_MECHANISMS: PLAIN
      KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.auth.SimpleAclAuthorizer
      KAFKA_SUPER_USERS: User:admin
      KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: false
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper_sasl:2181'
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
    volumes:
      - ./conf/server_jaas.conf:/opt/kafka/secrets/server_jaas.conf
    ports:
      - "${KAFKA_PORT}:${KAFKA_PORT}"
    deploy:
      resources:
        limits:
          cpus: '4'
          memory: 4G
        reservations:
          cpus: '0.5'
          memory: 200M 
    depends_on:
      - zookeeper_sasl
EOF

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Docker Compose Windows x86_64是运行在Windows操作系统上的、基于x86_64架构的Docker Compose工具。它的主要作用是简化和自动化多个Docker容器的管理和部署过程。 与Docker Compose的Linux版本相比,Docker Compose Windows x86_64提供了更好的兼容性和性能,以满足在Windows环境下使用Docker的需求。 使用Docker Compose Windows x86_64,可以使用一个YAML文件定义多个Docker容器配置和依赖关系。通过简单的命令行指令,可以执行各种操作,如构建、运行、停止和删除容器等。 Docker Compose Windows x86_64还允许在多个容器之间建立网络连接,以及通过容器之间的环境变量进行通信。这使得容器之间的协作和数据共享变得简单而高效。 Docker Compose Windows x86_64还支持通过Volumes功能将容器与宿主机的文件系统连接在一起,实现数据的持久化存储。 总结来说,Docker Compose Windows x86_64是一个强大的工具,它可以让开发人员在Windows操作系统上轻松管理和部署多个Docker容器,提供了简单、高效和可靠的容器化应用解决方案。无论是在单机环境还是生产环境中,使用Docker Compose Windows x86_64都可以显著提升开发效率和应用性能。 ### 回答2: docker-compose-windows-x86_64是Docker Compose的一个特定版本,适用于Windows操作系统的x86_64架构。Docker Compose是一个用于定义和管理多个Docker容器的工具,它允许我们使用一个简单的配置文件来定义所有容器配置和依赖关系,并通过一条命令来启动、停止和管理这些容器。 与原始的Docker Compose相比,docker-compose-windows-x86_64专门针对Windows操作系统进行了优化和适配。它提供了对Windows特定功能的支持,例如使用Windows容器、挂载Windows文件共享和运行Windows服务等。此外,它还充分利用了x86_64架构的优势,以提供更好的性能和兼容性。 使用docker-compose-windows-x86_64,我们可以轻松地在Windows操作系统上创建复杂的多容器应用程序。我们只需要在配置文件中定义每个容器的镜像、环境变量、端口映射和容器间的依赖关系,然后通过运行一个命令来启动整个应用程序。docker-compose-windows-x86_64会自动下载所需的镜像,并在我们的电脑上创建和管理对应的容器。 总之,docker-compose-windows-x86_64是一个适用于Windows操作系统的Docker Compose工具的特定版本。它提供了对Windows特定功能的支持,并通过简单的配置文件和命令来管理多个Docker容器,让我们能够轻松地构建和管理复杂的多容器应用程序。 ### 回答3: docker-compose-windows-x86_64 是针对 Windows 平台的 Docker Compose 的安装包。Docker ComposeDocker 官方提供的一个用于定义和运行多个 Docker 容器的工具。通过编写一个 YAML 文件来定义容器之间的关系和依赖性,然后使用 Docker Compose 命令来启动、停止和管理这些容器Docker Compose 使得在开发和测试环境中部署多个容器变得更加简单。它能够自动创建和管理容器网络、卷和监控服务等,提供了一个简洁的方式来管理多个容器之间的通信和数据共享。 docker-compose-windows-x86_64 是特定于 Windows 平台x86_64架构的二进制安装文件。它可以在 Windows 10 或更高版本的操作系统上运行,提供了最新版本的 Docker Compose 功能和特性。 要使用 docker-compose-windows-x86_64,你需要首先安装 Docker for Windows,然后将 docker-compose-windows-x86_64 的可执行文件下载到你的计算机上,并添加到系统的 PATH 环境变量中。然后你就可以在命令行或 PowerShell 中运行 `docker-compose` 命令来管理你的容器了。 总而言之,docker-compose-windows-x86_64 是针对 Windows 平台的 Docker Compose 安装包,它提供了方便管理和运行多个 Docker 容器的功能。通过编写简单的 YAML 文件,你可以轻松定义容器之间的关系和依赖性,并使用 Docker Compose 命令来管理这些容器的生命周期。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值