Deploy ZooKeeper distributed node

Use 2 servers, low resources, and deploy 3 zookeeper distributed nodes:

1. Prepare the environment
The system has been configured with the JAVA environment;
download one Version of the zookeeper compressed package,
download link: http://apache.claz.org/zookeeper/zookeeper-3.5.3-beta/zookeeper-3.5.3-beta.tar.gz

2. Planning
Server A, deploying 1 instance
Server B, deploying 2 instances

3. We configure 3 services. A distributed cluster requires at least three instance services, configuration information As follows:

For each service log, create a new data directory
Server A:
/opt/local/zookeeper/zk, create new data, logs, create a new myid in data, inside Write 3;
Server B:
/opt/local/zookeeper/zk1, create new data, logs, create a new myid in data, and write 2 in it;
/opt/local/zookeeper/zk2, Create new data and logs, create a new myid in data, and write 1 in it;

4, the configuration file directory /opt/local/zookeeper-3.4.10/conf,

New 3 Two configuration files,
Server A: zoo.cfg
Server B: zoo1.cfg, zoo2.cfg

The ports are 2181 2182 2183 respectively

tickTime=2000 

initLimit=10

syncLimit=5

dataDir=/opt/local/zookeeper/zk/data

clientPort=2181
dataLogDir=/opt/local/zookeeper/zk/logs

server.1=IP1:2287:3387
server.2=IP2:2288:3388< br />server.3=IP2:2289:3389

First explain the meaning of server.x=A:B:C:

x: represents the use of each service instance The content of myid under the dataDir
A: The IP address of the machine where the service is used
br>B: Leader election port (all ports in a pseudo-distributed environment should not be the same)
C: Port for communication between zk servers, and synchronization of information between servers

5、
Start three services:

bin/zkServer.sh start conf/zoo.cfg 
bin/zkServer.sh start conf/zoo1.cfg
bin/zkServer.sh start conf/ zoo2.cfg

Check service status:

#Mode: follower
bin/zkServer.sh status conf/zoo.cfg
#Mode: leader
bin/zkServer.sh status conf/zoo1.cfg
#Mode: follower
bin/zkServer.sh status conf/zoo2.cfg

Leave a Comment

Your email address will not be published.