您好,登錄后才能下訂單哦!
本文實例講述了centos6使用docker部署kafka項目的方法。分享給大家供大家參考,具體如下:
目錄結構:
/kafka
/Dockerfile
/start.sh
/Readme
/kafka_2.11-0.10.2.1.tgz
Dockfile
FROM centos MAINTAINER qiongtao.li hnatao@126.com 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
說明:KAFKA_HOST=宿主機IP,其對應配置文件的advertised.listeners
測試安裝部署
cat Readme|while read line; do $line; done
kafka下載地址:
http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.10.2.1/kafka_2.11-0.10.2.1.tgz
希望本文所述對大家Docker容器使用有所幫助。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。