This article describes how to use docker to deploy the kafka project on centos6. Share with you for your reference, the details are as follows: Directory structure:
Dockfile FROM centos MAINTAINER qiongtao.li [email protected] ADD ./kafka_2.11-0.10.2.1.tgz /opt ADD ./start.sh /start.sh ENV KAFKA_PORT=9092\ KAFKA_DIR=/opt/kafka \ KAFKA_DATA_DIR=/data/kafka RUN echo "Asia/shanghai" > /etc/timezone \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && yum -y install java \ && mkdir -p $KAFKA_DATA_DIR \ && mv /opt/kafka_2.11-0.10.2.1 $KAFKA_DIR EXPOSE $KAFKA_PORT ENV PATH=$PATH:$KAFKA_DIR/bin ENTRYPOINT ["sh", "/start.sh"] start.sh conf=$KAFKA_DIR/config/server.properties sed -i "s|broker.id=0|broker.id=${BROKER_ID:-1}|g" $conf sed -i "s|#delete.topic.enble=true|delete.topic.enble=true|g" $conf sed -i "s|log.dirs=/tmp/kafka-logs|log.dirs=${KAFKA_DATA_DIR}|g" $conf sed -i "s|#advertised.listeners=PLAINTEXT://your.host.name:9092|advertised.listeners=PLAINTEXT://${KAFKA_HOST}:${KAFKA_PORT:-9092}|g" $conf sed -i "s|zookeeper.connect=localhost:2181|zookeeper.connect=${ZOOKEEPER_HOST}:${ZOOKEEPER_PORT:-2181}|g" $conf sh kafka-server-start.sh $conf Readme docker rm -f kafka docker rmi -f kafka docker build -t kafka . docker run -d \ -p 9092:9092 \ --name kafka \ -e KAFKA_HOST=101.201.111.163 \ -e ZOOKEEPER_HOST=10.171.8.236 \ -e BROKER_ID=1 \ -v /data:/data \ Kafka docker ps -a docker logs -f kafka Note: KAFKA_HOST = host IP , which corresponds to advertised.listeners in the configuration file Test the installation and deployment cat Readme|while read line; do $line; done Kafka download address: http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.10.2.1/kafka_2.11-0.10.2.1.tgz I hope this article will help you use Docker containers. You may also be interested in:
|
<<: Detailed explanation of the difference between Vue life cycle
>>: MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit
Table of contents JSON.parse JSON.parse Syntax re...
Before introducing the GROUP BY and HAVING clause...
If you upgrade in a formal environment, please ba...
I saw a good idea and recorded it. I have used jQ...
Table of contents React Fiber Creation 1. Before ...
Table of contents Method 1 1. Configuration and i...
This article describes various ways to implement ...
There are two ways to create a primary key: creat...
This article example shares the specific code of ...
First of all, for security reasons, JavaScript ca...
Tomcat accesses the project, usually ip + port + ...
We often see a cool effect where the mouse hovers...
It was found in the test that when the page defini...
When nginx configures proxy_pass, the difference ...
1. Build a Docker environment 1. Create a Dockerf...