zookeeper (four) zookeeper deployment

There are three ways to deploy zookeeper, stand-alone mode, the cluster model, using a pseudo-cluster mode about Docker way to deploy
NOTE: The cluster is three or more odd number, such as 3,5,7, not too much, more than a cluster machine and election data synchronization time-consuming and unstable.

Stand-alone mode

# Download
into the download version of the directory, select the .tar.gz file downloads, download links:
http://archive.apache.org/dist/zookeeper/

# Installation
Note: You need to install Java

Use tar to extract the directory you want to install to 3.4.13 version, for example, to extract /usr/local/zookeeper-3.4.13

tar -zxvf zookeeper-3.4.13.tar.gz -C /usr/local

# Configure
create data logs and two directories under the root directory for storing data and a log

cd /usr/local/zookeeper-3.4.13
mkdir data
mkdir logs

New zoo.cfg file in the conf directory, writes the following save

tickTime=2000
dataDir=/usr/local/zookeeper-3.4.13/data
dataLogDir=/usr/local/zookeeper-3.4.13/logs
clientPort=2181

# Start and stop
into the bin directory, start, stop, restart, and view the current node status

./zkServer.sh start
./zkServer.sh stop
./zkServer.sh restart
./zkServer.sh status

Pseudo-cluster model

Pseudo-cluster model is launched in the same host multiple zookeeper and the formation of clusters below to create three groups zookeeper cluster on the host 192.168.10.134 example.

The stand-alone mode by zookeeper installed into a copying zookeeper1 / zookeeper2 / zookeeper3 three

# zookeeper1
modify the configuration file

tickTime=2000
dataDir=/usr/local/zookeeper1/data
dataLogDir=/usr/local/zookeeper1/logs
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.10.134:2888:3888
server.2=192.168.10.134:4888:5888
server.3=192.168.10.134:6888:7888

Setting the server ID

echo '1' > data/myid

# zookeeper2
modify the configuration file

tickTime=2000
dataDir=/usr/local/zookeeper2/data
dataLogDir=/usr/local/zookeeper2/logs
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.10.134:2888:3888
server.2=192.168.10.134:4888:5888
server.3=192.168.10.134:6888:7888

Setting the server ID

echo '2' > data/myid

# zookeeper3
modify the configuration file

tickTime=2000
dataDir=/usr/local/zookeeper3/data
dataLogDir=/usr/local/zookeeper3/logs
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.10.134:2888:3888
server.2=192.168.10.134:4888:5888
server.3=192.168.10.134:6888:7888

Setting the server ID

echo '3' > data/myid

# Start and stop
, respectively, start the server, the order does not matter

./zkServer.sh start
./zkServer.sh stop
./zkServer.sh restart
./zkServer.sh status

# Cluster model
Cluster model is installed on a different host zookeeper mode and then make up the cluster, the steps above will not be repeated here.

Published 45 original articles · won praise 7 · views 915

Guess you like

Origin blog.csdn.net/qq_42222342/article/details/103883959