Virtual machine-Linux-CentOS 7-ZooKeeper3.4.14 installation (cluster mode)

Virtual machine-Linux-CentOS 7 vomiting blood, installing Hadoop2.9.2 to build a cluster tutorial (detailed illustration)

ZooKeeper installation steps

  1. Download from official website https://zookeeper.apache.org/
    Insert picture description here
  2. Unzip to the specified directory tar -zxvf zookeeper-3.4.14.tar.gz -C /opt
  3. Enter the ZooKeeper directory, enter mkdir zkData , create a new folder, the data will be stored here in the future
  4. Enter /opt/zookeeper-3.4.14/conf and change zoo_sample.cfg to zoo.cfg : mv zoo_sample.cfg zoo.cfg
  5. Enter vim zoo.cfg , modify two places
    1. Modify dataDir to the path of the folder just created
      Insert picture description here
    2. Add the following configuration in the blank space. server.A=B: C: D: where A is the ServerID, which is used to identify the machine serial number of the machine in the cluster (any number); B is the IP address of the server; C represents the server and the leader in the cluster The port for the server to exchange information; D indicates that in case the leader server in the cluster hangs, a port is needed to re-election and select a new leader, and this port is the port used to communicate with each other during the election. If it is a pseudo-cluster configuration method, since B is the same, the communication port numbers of different Zookeeper instances cannot be the same, so C and D must be assigned different port numbers.
      Insert picture description here
      Zoo.cfg configuration instructions:
      • tickTime : This time is used as the time interval for maintaining heartbeats between Zookeeper servers or between client and server, that is, a heartbeat will be sent every tickTime.
      • initLimit : This configuration item is used to configure Zookeeper to accept clients (the client mentioned here is not the client of the user connecting to the Zookeeper server, but the follower server connected to the Leader in the Zookeeper server cluster). The number of heartbeat intervals. When the Zookeeper server has not received the return information from the client after the length of 10 heartbeats (ie tickTime) has passed, it indicates that the client connection failed. The total length of time is 10*2000=20 seconds
      • syncLimit : This configuration item identifies the length of the message sent between Leader and Follower, request and response time, the longest cannot exceed the time length of tickTime, the total time length is 5*2000=10 seconds
      • dataDir : The directory where Zookeeper saves data. By default, Zookeeper also saves the log files for writing data in this directory.
      • clientPort : This port is the port for the client to connect to the Zookeeper server. Zookeeper will listen to this port and accept the client's access request.
  6. Enter the zkData directory you just created, enter vim myid , create a myid file, and then enter a number that corresponds to the machine number behind server. in zoo.cfg.
  7. Enter scp -r /opt/zookeeper-3.4.14 root@slave1:/opt/ , scp -r /opt/zookeeper-3.4.14 root@slave2:/opt/ respectively to synchronize the zookeeper installation directory to other hosts ( Of course you can write an xsync script). In the design of ZooKeeper, zpp.cfg is on all machines in the cluster. The contents of the files should be consistent.
  8. Modify the myid files of other hosts respectively, and enter a number (different for each server), corresponding to the machine serial number after server. in zoo.cfg.

At this point, ZooKeeper is finished, enter bin/zkServer.sh start on each host to start the server.

ZooKeeper operation

project Value
zkCleanup Clean up ZooKeeper historical data, including transaction log files and snapshot data files.
zkCli A simple client of ZooKeeper
zkEnv Set ZooKeeper environment variables
zkServer ZooKeeper server start, stop and restart scripts.
  1. Start ZooKeeper server: bin/zkServer.sh start
  2. Check whether the process is started: jps
  3. View server status: bin/zkServer.sh status
  4. Start ZooKeeper client: bin/zkCli.sh
    connects locally by default. Connect to the specified server: bin/zkCli.sh -server ip:port
  5. Quit the ZooKeeper client: quit
  6. Stop ZooKeeper service: bin/zkServer.sh stop

Guess you like

Origin blog.csdn.net/H_X_P_/article/details/106236337