Bash-based kafka shell requiring only linux, core-utils, bash & original kafka scripts
- Docker
- Well, that's it
- Bash
- Local installation of kafka (kafka's shell scripts required)
- GNU getopt
If you searched through internet looking for some simple out-of-the-box kafka, I must congrat you! You've found it! All you need to do is clone this repo:
git clone https://github.com/saksmt/kafka-shell.git
Navigate to docker
directory:
cd kafka-shell/docker
Type:
docker-compose up -d
And finally get your kafka shell:
./connect-to-shell
As a bonus you'll get wonderful zookeeper client on 8888 port
There are 3 contexts:
topics
publish
consume
Topics context allows you to list
existing topics, create <TOPIC> [OPTIONS]
complex new ones, create <TOPIC>
simple (single partition, replication factor = 1) and describe <TOPIC>
existing
Publish context, suprisingly, allows to publish messages to topics:
echo "my message" | raw topic_name
echo "my message under key" | with-key key_name topic_name
Consume context can consume messages, either all-from <topic>
or only latest-from <topic>
You'll need to have original kafka for example in /opt/kafka
, then you need to tell the shell where kafka is:
KAFKA_BINDIR=/opt/kafka/bin
Place this file in /usr/local/etc/kafka-shell/config
If you want your shell to be placed somewhere outside of repository, don't forget to move .kafka-shell-rcscript
somewhere too, for example in /usr/local/lib
and modify config (/usr/local/etc/kafka-shell/config
)
like following:
LIB_FILE=/usr/local/lib/.kafka-shell-rcscript
Default installation assumes you have kafka under /usr/local/opt/kafka
and want to place shell under
/usr/local/bin
To quickly use such installation just run ./install
To connect to some kafka you'll need addresses of:
- Zookeeper
- Bootstrap kafka server
- Broker (optional, defaults to bootstrap server)
ZK='zookeeperHost:2181' BOOTSTRAP_SERVER='kafkaBootstrapServer:9091' BROKER='brokerHost:9091' kafka-shell connect
You can also store your servers under /usr/local/etc/kafka-shell/servers
directory in following format:
# filename: localhost
ZK='localhost:2181'
BOOTSTRAP_SERVER='localhost:9091'
And then you can quickly connect to your saved kafka:
kafka-shell connect localhost
If you have lots of servers you may find these commands useful:
kafka-shell list
- list all available serverskafka-shell show <server>
- show server's connect options
All sources are licensed under MIT license.