Coder Social home page Coder Social logo

kafka-cluster's Introduction

Configuration

The configuration can modify by update conf/* file and env vars.

docker-compose build

Usage

update file in each machine

file docker-compose.yml
ZOO_MY_ID
ZOO_SERVERS

file config/server.properties 
advertised.listeners
zookeeper.connect
listener.name.sasl_plaintext.plain.sasl.jaas.config

file config/consumer.properties
sasl.jaas.config

file config/producer.properties
sasl.jaas.config 

Start a cluster:

  • docker-compose up -d

Destroy a cluster:

  • docker-compose stop

create topic

#KAFKA
# 创建topic, 授权生产,消费
topic_list=(topic1 topic2 topic3)
for topic in "${topic_list[@]}"; do
  kafka-topics.sh --bootstrap-server localhost:9092 --create --topic "${topic}" --partitions 24 --replication-factor 2  --command-config config/producer.properties
done

authorize producer

# producer
user_list=(test)
topic_list=(topic1 topic2 topic3)
for topic in "${topic_list[@]}"; do
  for user in "${user_list[@]}"; do
    kafka-acls.sh --bootstrap-server localhost:9092  --add --allow-principal User:"${user}" --producer --topic "${topic}" --command-config config/producer.properties
  done
done

authorize consumer

user_list=(test)
group_list=(test)
topic_list=(topic1 topic2 topic3)
for topic in "${topic_list[@]}"; do
    for user in "${user_list[@]}"; do
      group=${user}
      kafka-acls.sh --bootstrap-server localhost:9092 --add --allow-principal User:"${user}" --consumer --topic "${topic}" --group "${group}" --command-config config/producer.properties
    done
done

revoke authorize

# 删除
topic_list=(Hello-Kafka)
user_list=(test)
for topic in "${topic_list[@]}"; do
  kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic "${topic}" --command-config config/producer.properties
  for user in "${user_list[@]}"; do
    kafka-acls.sh --bootstrap-server localhost:9092  --remove --allow-principal User:"${user}" --producer --topic "${topic}" --command-config config/producer.properties
    # for group in "${group_list[@]}"; do
    kafka-acls.sh --bootstrap-server localhost:9092 --remove --allow-principal User:"${user}" --consumer --topic "${topic}" --group "${group}" --command-config config/producer.properties
    # done
  done
done

query & reset

kafka-topics.sh --bootstrap-server localhost:9092 --list --command-config config/producer.properties
kafka-acls.sh --bootstrap-server localhost:9092 --list --command-config config/producer.properties
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group test --reset-offsets --to-earliest --command-config config/consumer.properties --all-topics --execute

kafka-cluster's People

Contributors

williamguozi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.