I. Preparatory work before deployment
1. Each host can guarantee normal communication, preferably in the same network segment.
2. Modify the host file, and add the mapping IP host name. Methods to modify the / etc / hosts and etc / hostname file, different Linux distributions approach is not necessarily the same.
3. Turn off the firewall or open ports to use
II. Deployment Zookeeper cluster
1. Zookeeper visit the official website to download the installation package, and extract.
tar -xvzf zookeeper-3.4.6.tar.gz
2. Create a data directory
Execute the following command to create the data directory:
mkdir / usr / zookeeper / data p>
Execute the following command to create the log directory:
mkdir / usr / zookeeper / data / log
execute the following command to create myid file and write ID:
echo 1 > / usr / zookeeper / data / myid
3. Modify the configuration
Run the following command to edit zoo.cfg file:
cd zookeeper-3.4.6 / conf / & & mv zoo_sample.cfg zoo.cfg & & vi zoo.cfg
Modify configuration is as follows:
dataDir = / usr / zookeeper / data p>
dataLogDir = / usr / zookeeper / data / log
autopurge.snapRetainCount = 3
autopurge.purgeInterval = 1
In the last added Zookeeper cluster nodes address:
server.1 = node1: 2888: 3888
server.2 = node2: 2888: 3888
server.3 = node3: 2888: 3888
4. Copy configuration files to other nodes
scp -r zookeeper-3.4.6 / node2: / usr /
It should be noted that each node myid is not the same.
III. Start Zookeeper cluster
execute the following command to start Zookeeper Zookeeper service nodes in the cluster:
zookeeper-3.4.6 / bin / zkServer.sh start
Zookeeper execute the following command to view the status of each node in the cluster:
zookeeper-3.4.6 / bin / zkServer.sh status
You can see the node1 node follewer node
IV. HA validation failure is automatically transferred if it works
Zookeeper process using jps command
Use the command kill -9 2432 kill leader process, and then view the status of each node Zookeeper, if there is a leader of the verification handy |