zookeeper service registry configuration

       I have been using zookeeper for a while, so I will briefly summarize the configuration. The first is the stand-alone mode:

wrote
1 Download the zookeeper installation package
2 Enter the conf subdirectory under the zookeeper directory, create zoo.cfg
3 Edit zoo.cfg
tickTime=2000
dataDir=D:\\zookeeper\\zookeeper-3.4.9-1\\data\\
dataLogDir =D:\\zookeeper\\zookeeper-3.4.9-1\\datalog\\
clientPort=4180

   Parameter Description

   

wrote
Parameter description:

tickTime: basic event unit, in milliseconds, used to control heartbeat and timeout, the default timeout time is twice the tickTime

dataDir: data directory. Can be any directory.

dataLogDir: log directory, also can be any Directory. If this parameter is not set, the same settings as dataDir will be used.

clientPort: The port number that listens for client connections

   The server configuration is complete, start the server:

     bin/zkServer.cmd 

   Client connection:

   bin/zkCli.cmd -server localhost:4180 

 

  2Single-machine simulation cluster mode

   Copy three installation packages

  1. |--zookeeper1  

  2. |--zookeeper2 

  3. |--zookeeper3  

 

Change the zookeeper0/conf/zoo.cfg file

zookeeper1 wrote
tickTime=2000
initLimit=5
syncLimit=2
dataDir=D:\\zookeeper\\zookeeper-3.4.9-1\\data\\
dataLogDir=D:\\zookeeper\\zookeeper-3.4.9-1\\datalog\\
clientPort=4180
server.1=127.0.0.1:8880:7770
server.2=127.0.0.1:8881:7771
server.3=127.0.0.1:8882:7772

 

zookeeper2 wrote
tickTime=2000

initLimit=5

syncLimit=2

dataDir=D:\\zookeeper\\zookeeper-3.4.9-2\\data

dataLogDir=D:\\zookeeper\\zookeeper-3.4.9-2\\datalog

clientPort=4181

server.1=127.0.0.1:8880:7770
server.2=127.0.0.1:8881:7771
server.3=127.0.0.1:8882:7772

 

zookeeper3 wrote

 

tickTime=2000

initLimit=5

syncLimit=2

dataDir=D:\\zookeeper\\zookeeper-3.4.9-3\\data

dataLogDir=D:\\zookeeper\\zookeeper-3.4.9-3\\datalog

clientPort=4182

server.1=127.0.0.1:8880:7770
server.2=127.0.0.1:8881:7771
server.3=127.0.0.1:8882:7772

 Add parameters

  

wrote

 

initLimit: The zookeeper cluster contains multiple servers, one of which is the leader, and the rest of the servers in the cluster are followers. The initLimit parameter configures the longest heartbeat time between the follower and the leader when the connection is initialized. At this time, the parameter is set to 5 , indicating that the time limit is 5 times tickTime, that is, 5*2000=10000ms=10s.

syncLimit: This parameter configures the maximum length of time for sending messages, requests and responses between the leader and the follower. At this time, the parameter is set to 2, indicating the time limit It is 2 times tickTime, that is, 4000ms.

server.X=A:B:C where X is a number, indicating the number of the server. A is the IP address where the server is located. B configures the server to exchange with the leader in the cluster The port used by the message. C configures the port used when electing the leader. Since the configuration is pseudo-cluster mode, the B and C parameters of each server must be different

 Need to change dataDir, dataLogDir, clientPort parameters

Create a new myid text file in the dataDir directory, and write 1, 2, and 3 respectively. The numbers here correspond to the server numbers in the zookeeper configuration file, which cannot be wrong.

 

   After the configuration is complete, start three servers respectively

  

cluster mode

The configuration of cluster mode is basically the same as that of pseudo-cluster.
Since each server is deployed on different machines in cluster mode, the conf/zoo.cfg file of each server can be exactly the same.

 

 

   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326404281&siteId=291194637