CentOS 6 uses Docker to deploy Zookeeper operation example

CentOS 6 uses Docker to deploy Zookeeper operation example

This article describes how to use docker to deploy zookeeper on centos6. Share with you for your reference, the details are as follows:

Directory structure:

/zookeeper
/Dockerfile
./start.sh
/Readme
/zookeeper-3.4.10.tar.gz

Dockerfile

FROM centos
MAINTAINER qiongtao.li hnatao@126.com
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 \
 z
docker ps -a
docker logs -f zk

Test the installation and deployment

cat Readme|while read line; do $line; done

Zookeeper download address:

https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz

I hope this article will help you use Docker containers.

You may also be interested in:
  • Install Zookeeper under Docker (standalone and cluster)
  • Implementation of Docker to build Zookeeper&Kafka cluster
  • Detailed tutorial on how to quickly install Zookeeper in Docker

<<:  How to add fields and comments to a table in sql

>>:  Two practical ways to enable proxy in React

Recommend

Web development tutorial cross-domain solution detailed explanation

Preface This article mainly introduces the cross-...

VUE+Express+MongoDB front-end and back-end separation to realize a note wall

I plan to realize a series of sticky note walls. ...

WeChat applet implements search box function

This article example shares the specific code for...

Docker container from entry to obsession (recommended)

1. What is Docker? Everyone knows about virtual m...

What to do if the container started by docker run hangs and loses data

Scenario Description In a certain system, the fun...

Example of using docker compose to build a consul cluster environment

Basic concepts of consul Server mode and client m...

Common HTML tag writing errors

We better start paying attention, because HTML Po...

MySQL Database Indexes and Transactions

Table of contents 1. Index 1.1 Concept 1.2 Functi...

How to modify the length limit of group_concat in Mysql

In MySQL, there is a function called "group_...

js implements a simple countdown

This article example shares the specific code of ...

Uniapp implements DingTalk scan code login sample code

Since Uniapp does not have DingTalk authorization...

Tutorial on installing MySQL 5.7.28 on CentOS 6.2 (mysql notes)

1. Environmental Preparation 1.MySQL installation...

Docker mounts local directories and data volume container operations

1. Docker mounts the local directory Docker can s...

Install mysql5.7.17 using RPM under Linux

The installation method of MySQL5.7 rpm under Lin...