ZooKeeper3.4.5 - start zookeeper at the same time

We know that zookeeper requires each node to start up, and then vote for the master and slave. In practice, this is achieved using automated scripts.

#!/bin/sh
echo "start zkService ..."
for i in 1 2 3
do
ssh mini$i "source /etc/profile;/root/apps/zookeeper-3.4.5/bin/zkServer.sh start"
done

sourceThe command is used in the above code , because sshwhen the connection is made, the variables in the load are not loaded profile. Make it JAVA_HOMEnot found in the current script process, which will cause the failure of startup.

Similarly, we can also view the status of each server in this way:

#!/bin/sh
echo "show zkService status..."
for i in 1 2 3
do
echo "mini$i :"
ssh mini$i "source /etc/profile;/root/apps/zookeeper-3.4.5/bin/zkServer.sh status"
done

Guess you like

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