Ant Bites the elephant's zookeeper learning process

Source: Internet
Author: User
Tags zookeeper

Ant 01 Eats Elephant:


# Author of this article-Liu Xiaotao

# creation Time: 2016-1-26:22:30

# Time to complete: 2016-1-27-23:11

I am not smarter than others, learning things are slow, memory also seems to be lowered (Ben three), but I can not give up learning stalled!

# write this article, a supervision of their own tasks have not been completed two: Record the learning process, convenient for later search, deepen the memory of the three common exchange discussion


Elephant to chew on:

(article: "Deploying a Mesos cluster with docker,7 commands.") Article from the Linux Commune website (www.linuxidc.com) Link: http://www.linuxidc.com/Linux/2015-06/118589.htm)


Ant 01: Below-all


The purpose of this article:

1 review docker through Zookeeper's Dockerfile review

2 through Zookeeper's Dockerfile learning zookeeper

The address of the zookeeper image information is:

https://registry.hub.docker.com/u/garland/zookeeper/

Https://github.com/sekka1/mesosphere-docker/tree/master/zookeeper

Dockerfile

======================================# docker-version 1.0.1# version         0.5# source         https:// Github.com/jplock/docker-zookeeperfrom debian:jessiemaintainer justin plock <[email  protected]>RUN apt-get update && apt-get install -y  openjdk-7-jre-headless wgetrun wget -q -o - http://apache.mirrors.pair.com/ zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz | tar -xzf - -c /opt      && mv /opt/zookeeper-3.4.6 /opt/zookeeper      && cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg      && mkdir -p /tmp/zookeeperenv java_home /usr/lib/jvm/ java-7-openjdk-amd64add ./run.sh /opt/run.shrun chmod 777 /opt/run.shexpose 2181 2888 3888workdir /opt/ zookeepervolume ["/opt/zookeeper/conf",  "/tmp/zookeeper"]cmd ["/opt/run.sh"]=================== ====================

See this dockerfile first eye: I wipe, stool system, did not play Ah, second eye: No matter, Unix-like system, the principle of universal.


A look at the broad:

Two run command to know zookeeper installation environment requires Java and how to install zookeeper

Expose command, provide three ports externally (before looking at the zookeeper, probably know zookeeper to three ports)

Add Command: Erase, add run script go in, what script ah this is, after I have a good docker environment into the container copy out of the study

VOLUME: The command I only remember is mounted, forgot to mount a-B or two are on the plug-in, and so will create a container to look after


Through the above to see, you can know how zookeeper installation run, configuration file path, provide the external port service (the principle of the software is similar: installation, configuration files, port)


Start biting elephants:

Specify target:

1 Build a Centos7 zookeeper image (basically copy it)

2 Making the installation deployment document based on the CENTOS7 system (non-mirrored) zookeeper

3 in-depth understanding of Zookeeper's principles (what is zookeeper?) What can I do for you? How did you do that? )

How to do it:

1 Prepare a clean CENTOS7 environment and run the zookeeper installation, please.

2 in Centos7 installation run no problem, you can consider the construction of Dockerfile

3 Refer to Baidu Google Official document understanding zookeeper principle. (before 2 steps if you have a problem, I have to search to ask to solve, I am not a great God)

(just suddenly came up with an idea: use Saltstack to install zookeeper, give yourself a scare, first forget it, later)


Target 1-1 Download the image and run (install Docker slightly)

Systemctl Start Docker

Import CentOS image (pre-download good, otherwise the network download is too slow, suggest to turn over the wall or pull down with foreign host to save yourself)

[[email protected] opt]# Docker load < centos.tar.gz

Download the zookeeper image of the above article

Docker Pull Garland/zookeeper


To view the image:

[[email protected] local]# docker imagesrepository                     TAG                  IMAGE ID             CREATED              VIRTUAL SIZEdocker.io/centos               latest               60e65a8e4030        4 weeks  ago         196.6 mbdocker.io/garland/zookeeper    latest              0e07387e8ab2      &nbSp;  12 months ago       378.5 mb 

When the download is complete, use the image to run the container

Docker run-d-P 2181:2181-p 2888:2888-p 3888:3888 garland/zookeeper


To view a running container

[[email protected] ~]# docker pscontainer id         IMAGE                command             created              STATUS               PORTS                                                                        namesf09f7d3f100b        garland/zookeeper     "/opt/run.sh" &NBsp;      22 minutes ago      up 22  minutes       0.0.0.0:2181->2181/tcp, 0.0.0.0:2888->2888/ Tcp, 0.0.0.0:3888->3888/tcp   lonely_tesla

After entering the container, exit, the container continues to run the script (this script comes from the old boy education-instructor to find squad Leader)

[[email protected] ~]# vim enter_doker.sh#!/bin/bashpid= ' docker inspect--format ' {{. State.pid}} "$ ' nsenter-t $PID-u-i-n-P

Enter the container:

[Email protected] ~]#/enter_doker.sh f09f7d3f100b[[email protected] ~]#

Content of run.sh:

=============================================================#!/bin/shzoo_cfg= "/opt/zookeeper/conf/zoo.cfg" #  Output server IDecho  "server id  (myID):  ${server_id}" echo  "${server_ ID} " > /tmp/zookeeper/myid# Add additional ZooKeeper servers into  the zoo.cfg fileecho  "${additional_zookeeper_1}"  >> ${ZOO_CFG}echo  "${ additional_zookeeper_2} " >> ${ZOO_CFG}echo " ${additional_zookeeper_3} " >>  ${ZOO_CFG}echo  "${additional_zookeeper_4}"  >> ${ZOO_CFG}echo  "${additional_ Zookeeper_5} " >> ${ZOO_CFG}echo " ${additional_zookeeper_6} " >> ${zoo_cfg} echo  "${additional_zookeeper_7}"  >> ${ZOO_CFG}echo  "${additional_zookeeper_8}"   >> ${ZOO_CFG}echo  "${additional_zookeeper_9}"  >> ${ZOO_CFG}echo  "${ ADDITIONAL_ZOOKEEPER_10} " >> ${zoo_cfg}# start zookeeper/opt/zookeeper/bin/zkserver.sh start-foreground======== ====================================================

See this a little confused, echo a lot of things, do not know what the meaning ah.

The only thing to see is to want to do zookeeper image, then let zookeeper run in the foreground, parameter is Start-foreground


Build yourself on the CENTOS7 first.

Cd/optwget http://apache.mirrors.pair.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz Tar-xzf ZOOKEEPER-3.4.6.TAR.GZMV zookeeper-3.4.6 zookeeper CP zookeeper/conf/zoo_sample.cfg ZOOKEEPER/CONF/ZOO.CFGMKDIR-P/ Tmp/zookeeper


Detailed configuration file:

Zookeeper/conf/zoo_sample.cfg

The time interval (in milliseconds) between the Ticktime=2000# zookeeper service side or between the server and the client (follower) initlimit=10#  This configuration item is used to configure   zookeeper  accepts the client (the client here is not a client of the user connection  Zookeeper  server, but is connected to the  leader in the  Zookeeper  server cluster)    Follower  server) The maximum number of heartbeat intervals that can be tolerated when initializing a connection. After the length of the  10  heartbeat (that is,  ticktime) has been exceeded  Zookeeper  the server has not received a return message from the client, the client connection failed. The total length of time is  5*2000=10  seconds synclimit=5#  This configuration item identifies  Leader  and  Follower  sends a message, The maximum length of the request and response time cannot exceed the length of  tickTime , the total length of time is  2*2000=4  seconds datadir=/tmp/zookeeper#  zookeeper  the directory where data is saved, by default,zookeeper  log files that write data are also stored in this directory clientport=2181# this port is the client connection  Zookeeper  The port,zookeeper  of the server listens to this port, accepting requests for client access. # the maximum number of client connections. increase this if  you need to handle more clients#maxclientcnxns=60# the number of  snapshots to retain in datadir#autopurge.snapretaincount=3# purge task interval in hours set to  "0"  to  disable auto purge feature#autopurge.purgeinterval=1# Configuring the cluster server.1=192.168.56.21:2888:3888  server.2=192.168.56.22:2888:3888
# server. A=b:c:d where A is a number, which indicates this is the first server, B is the IP address of this server, and C is the port that this server exchanges information with the Leader server in the cluster, and D indicates that in case the Leader server in the cluster Hang up and need a port to re-elect a new Leader, which is the port that the server communicates with each other when the election is performed.


If it is a pseudo-cluster configuration, because B is the same, so different Zookeeper instance communication port numbers can not be the same, so they should be assigned a different port number.


In addition to modifying the Zoo.cfg configuration file, in the cluster mode to configure a file myID, the file in the DataDir directory, the file contains a data is a value, Zookeeper startup will read this file, get the data inside and zoo.cfg The configuration information is compared to determine the server.


Complete configuration file:

[Email protected] conf]# cd/opt/zookeeper/conf/[[email protected] conf]# vim zoo.cfg ticktime=2000initlimit= 10synclimit=5datadir=/opt/zookeeper/dataclientport=2181server.1=192.168.56.21:2888:3888server.2= 192.168.56.22:2888:3888


To run the service:

[Email protected] ~]#/opt/zookeeper/bin/zkserver.sh startjmx enabled by defaultusing Config:/opt/zookeeper/bin/. /conf/zoo.cfgstarting Zookeeper ... STARTED

View Status:

[Email protected] ~]#/opt/zookeeper/bin/zkserver.sh statusjmx enabled by defaultusing Config:/opt/zookeeper/bin/. /conf/zoo.cfgmode:follower
[Email protected] ~]#/usr/local/zookeeper-3.4.6/bin/zkserver.sh statusjmx enabled by defaultusing Config:/usr/local/ zookeeper-3.4.6/bin/. /conf/zoo.cfgmode:leader


Zookeeper build complete, configuration file detailed complete, the principle can see http://blog.csdn.net/qinglu000/article/details/23844359, very detailed


Dockerfile construction of zookeeper images based on CentOS:

# auther:liuxiaotao# date:2016-1-27# version:1.0from centosmaintainer liuxiaotao [email protected]run yum update-y && Yum install-y java-1.7.0-openjdk java-1.7.0-openjdk-devel java-1.7.0-openjdk-headlessadd zookeeper-3.4.6.tar.gz/usr/local/src/# Docker can zuto Untar zhe *.tar.gz files RUN mv/usr/local/src/zookeeper-3.4.6/us R/local/zookeeperadd zoo.cfg/usr/local/zookeeper/conf/expose 2181 2888 3888VOLUME ["/usr/local/zookeeper/conf", "/ Usr/local/zookeeper/data "]cmd ["/usr/local/zookeeper/bin/zkserver.sh Start-foreground "]

Build

Docker build-t Lezyo/zookepeer:v2.


View Image:

[[email protected] docker]# docker imagesrepository                     TAG                  IMAGE ID             CREATED              VIRTUAL SIZElezyo/zookepeer                v2                   cb3c2eb639ec        10  minutes ago      561.8 MBlezyo/zookeeper                v1                   b83857ea996f        41  minutes ago      561.8 MB<none>                          <none>               2d8697315524        44 minutes ago       523 MB<none>                         <none>               898c41613f2f         45 minutes ago      523 MB<none>        &Nbsp;                <none >              e6ef1aaeb302         48 minutes ago      523  MBdocker.io/centos               latest              60e65a8e4030         4 weeks ago          196.6 MBdocker.io/garland/zookeeper   latest               0e07387e8ab2         12 months ago       378.5 mb

Run:

Docker run-d-P lezyo/zookepeer:v2/usr/local/zookeeper/bin/zkserver.sh start-foreground


The operation was successful, but it was a little rough, so zookeeper first. Chew on the next.

This article is from the "Linux Dragon in the Sky" blog, please be sure to keep this source http://xiaotaoge.blog.51cto.com/1462401/1739399

Ant Bites the elephant's zookeeper learning process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.