From 143ec4588fd36d1c42e58711731a2d0e4ba4c1c3 Mon Sep 17 00:00:00 2001 From: Bazilio <4119114+xBazilio@users.noreply.github.com> Date: Thu, 27 May 2021 23:14:02 +0300 Subject: [PATCH] kafka_cluster --- README.MD | 1 + docker-compose.yml | 6 ++++++ kafka-server-start.sh | 46 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100755 kafka-server-start.sh diff --git a/README.MD b/README.MD index d834c63..78224de 100644 --- a/README.MD +++ b/README.MD @@ -12,6 +12,7 @@ I did my best to include helpfull examples for most common use cases 1. Download and unpack [kafka](https://kafka.apache.org/downloads) into `kafka_distr` folder 1. Copy and overwrite *.properties files from `kafka_custom_config` to `kafka_distr/config` +1. Copy and overwrite `kafka-server-start.sh` fo `kafka_distr/bin` 1. Run `docker-compose up` ### Usage diff --git a/docker-compose.yml b/docker-compose.yml index 9dcfa7d..c85a0b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,7 @@ services: volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/zookeeper/data/zoo1:/opt/zookeeper" + hostname: zoo1 networks: - kafka-lab zoo2: @@ -16,6 +17,7 @@ services: volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/zookeeper/data/zoo2:/opt/zookeeper" + hostname: zoo2 networks: - kafka-lab zoo3: @@ -25,6 +27,7 @@ services: volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/zookeeper/data/zoo3:/opt/zookeeper" + hostname: zoo3 networks: - kafka-lab @@ -37,6 +40,7 @@ services: - zoo1 - zoo2 - zoo3 + hostname: kafka1 networks: - kafka-lab environment: @@ -51,6 +55,7 @@ services: - zoo1 - zoo2 - zoo3 + hostname: kafka2 networks: - kafka-lab environment: @@ -65,6 +70,7 @@ services: - zoo1 - zoo2 - zoo3 + hostname: kafka3 networks: - kafka-lab environment: diff --git a/kafka-server-start.sh b/kafka-server-start.sh new file mode 100755 index 0000000..86d2771 --- /dev/null +++ b/kafka-server-start.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# 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. + +sleep 20 + +if [ $# -lt 1 ]; +then + echo "USAGE: $0 [-daemon] server.properties [--override property=value]*" + exit 1 +fi +base_dir=$(dirname $0) + +if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then + export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties" +fi + +if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then + export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G" +fi + +EXTRA_ARGS=${EXTRA_ARGS-'-name kafkaServer -loggc'} + +COMMAND=$1 +case $COMMAND in + -daemon) + EXTRA_ARGS="-daemon "$EXTRA_ARGS + shift + ;; + *) + ;; +esac + +exec $base_dir/kafka-run-class.sh $EXTRA_ARGS kafka.Kafka "$@"