在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
本文实例讲述了centos6使用docker部署zookeeper操作。分享给大家供大家参考,具体如下: 目录结构:
Dockerfile FROM centos MAINTAINER qiongtao.li [email protected] ADD ./zookeeper-3.4.10.tar.gz /opt ADD ./start.sh /start.sh ENV ZOO_PORT=2181\ ZOO_DIR=/opt/zookeeper \ ZOO_DATA_DIR=/data/zookeeper/data ZOO_DATA_LOG_DIR=/data/zookeeper/logs RUN echo "Asia/shanghai" > /etc/timezone \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && yum -y install java \ && mkdir -p "$ZOO_DATA_DIR" \ && mkdir -p "$ZOO_DATA_LOG_DIR" \ && mv /opt/zookeeper-3.4.10 "$ZOO_DIR" VOLUME ["$ZOO_DATA_DIR"] EXPOSE $ZOO_PORT ENV PATH=$PATH:$ZOO_DIR/bin ENTRYPOINT ["sh", "/start.sh"] start.sh #!/bin/bash CONF=${ZOO_DIR}/conf/zoo.cfg cp -a ${ZOO_DIR}/conf/zoo_sample.cfg $CONF sed -i "s|dataDir=/tmp/zookeeper|dataDir=${ZOO_DATA_DIR}|g" $CONF sed -i "s|clientPort=2181|clientPort=${ZOO_PORT}|g" $CONF echo "dataLogDir=${ZOO_DATA_LOG_DIR}" >> $CONF for server in $ZOO_SERVERS; do echo "$server" >> $CONF done if [ ! -f "$ZOO_DATA_DIR/myid" ]; then echo "${ZOO_MY_ID:-1}" > "$ZOO_DATA_DIR/myid" fi zkServer.sh start-foreground Readme docker rm -f zk docker rmi -f zk docker build -t zk . docker run -d \ -p 2181:2181 \ --name zk \ -v /data:/data \ zk docker ps -a docker logs -f zk 测试安装部署 cat Readme|while read line; do $line; done zookeeper下载地址: https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz 希望本文所述对大家Docker容器使用有所帮助。 |
请发表评论