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 [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 \
 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

A brief discussion on several ways to implement front-end JS sandbox

Table of contents Preface iframe implements sandb...

Detailed explanation of the use of Linux lseek function

Note: If there are any errors in the article, ple...

How to change the MySQL database file directory in Ubuntu

Preface The company's Ubuntu server places th...

Summary of knowledge points about null in MySQL database

In the MySQL database, null is a common situation...

Write a simple calculator using JavaScript

The effect is as follows:Reference Program: <!...

mysql 5.7.17 winx64.zip installation and configuration method graphic tutorial

Preface: I reinstalled win10 and organized the fi...

This article will help you understand the life cycle in Vue

Table of contents 1. beforeCreate & created 2...

Detailed description of the function of new in JS

Table of contents 1. Example 2. Create 100 soldie...

How to simply encapsulate axios in vue

Inject axios into Vue import axios from 'axio...

Programs to query port usage and clear port usage in Windows operating system

In Windows operating system, the program to query...

Web Design Tutorial (8): Web Page Hierarchy and Space Design

<br />Previous article: Web Design Tutorial ...

MySQL 8.0.15 installation and configuration graphic tutorial under Win10

This article records the installation and configu...

SQL implementation of LeetCode (196. Delete duplicate mailboxes)

[LeetCode] 196.Delete Duplicate Emails Write a SQ...

Vue parent-child component mutual value transfer and call

Table of contents 1. Parent passes value to child...

MySQL 5.7.18 installation tutorial under Windows

This article explains how to install MySQL from a...