zookeeper build record

zookeeper-3.4.9.tar.gz stand-


alone mode
Click here to download the zookeeper installation package, and extract it to a suitable directory. Enter the conf subdirectory under the zookeeper directory, and create zoo.cfg:
  1. tickTime=2000   
  2. dataDir=/Users /apple/zookeeper/data   
  3. dataLogDir=/Users/apple/zookeeper/logs   
  4. clientPort=4180  
Parameter description:
  ● tickTime: basic time unit used in zookeeper, millisecond value.
  ● dataDir: data directory. Can be any directory .
  ● dataLogDir: log directory, which can also 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. So
far, the stand-alone mode of zookeeper has been configured. Start the server Just run the script:
Bash code 
  1. bin/zkServer.sh start 
After the server starts, you can start the client to connect to the server, execute the script:
Bash code 
  1. bin/zkCli.sh -server localhost:4180 

pseudo-cluster mode
The so-called pseudo-cluster refers to starting multiple zookeeper processes on a single machine and forming a cluster. Take starting three zookeeper processes as an example.
Copy the zookeeper directory twice:
Bash code 
  1. |--zookeeper0 
  2. | --zookeeper1 
  3. |--zookeeper2 
Change the zookeeper0/conf/zoo.cfg file to:
Bash code 
  1. tickTime=2000   
  2. initLimit=5   
  3. syncLimit=2   
  4. dataDir=/Users/apple/zookeeper0/data   
  5 .dataLogDir=/Users/apple/zookeeper0/logs   
  6. clientPort=4180 
  7. server.0=127.0.0.1:8880:7770   
  8. server.1=127.0.0.1:8881:7771   
  9. server.2=127.0. 0.1:8882:7772 
Added several new parameters with the following meanings:
  ● 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, Indicates 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 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 of the server. B configure the server and the cluster The port used by the leader to exchange messages. C configures the port used to elect the leader. Since the configuration is in pseudo-cluster mode, the B and C parameters of each server must be different.
Refer to zookeeper0/conf/zoo.cfg to configure zookeeper1/ conf/zoo.cfg, and zookeeper2/conf/zoo.cfg files. Just change the dataDir, dataLogDir, clientPort parameters.
Create a new myid file in the previously set dataDir, and write a number, which indicates the number No. server. This number must correspond to X in server.X in
zoo.cfg file. Write 0 in /Users/apple/zookeeper0/data/myid file, /Users/apple/zookeeper1/data/myid file Write 1 in the /Users/apple/zookeeper2/data/myid file and write 2 in the file.
Enter the three directories /Users/apple/zookeeper0/bin, /Users/apple/zookeeper1/bin, /Users/apple/zookeeper2/bin, respectively, and start the server.
Choose any server directory, and start the client:
Bash code 
  1. bin /zkCli.sh -server localhost:4180  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. The following Here is an example: Bash code    1. tickTime=2000      2. initLimit=5      3. syncLimit=2      4. dataDir=/home/zookeeper/data      5. dataLogDir=/home/zookeeper/logs      6. clientPort=4180    7. server. 43=10.1.39.43:2888:3888    8. server.47=10.1.39.47:2888:3888      9. server.48=10.1.39.48:2888:3888 














In the example, three zookeeper servers are deployed, which are respectively deployed on 10.1.39.43, 10.1.39.47, and 10.1.39.48. It should be noted that the numbers in the myid files in the dataDir directory of each server must be different.
10.1.39.43 server myid is 43, the myid of the 10.1.39.47 server is 47, and the myid of the 10.1.39.48 server is 48.

Guess you like

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