Downgrade ZooKeeper
ZooKeeper is the final component in the downgrade process.
In this step you will downgrade and validate each ZooKeeper process, node by node.
Sign on as the zookeeper_admin user (default =
zookeeper) and run the followingstatcommand for each node in the ZooKeeper quorum until you find the leader:su - zookeeperecho stat | nc <servername> <port> | grep ModeexitFor example, to check nodes
hdp1andhdp2, assuming they use default ZooKeeper server port 2181:[zookeeper@hdp1 ~] echo stat | nc hdp1 2181 | grep Mode Mode: follower [zookeeper@hdp1 ~] echo stat | nc hdp2 2181 | grep Mode Mode: leader [zookeeper@hdp1 ~] exit
As with the related upgrade step, this is an optimization step. If the leader changes later, it won’t impact the outcome of the downgrade process.
Downgrade and restart each node, as follows. Downgrade the leader last.
Stop the ZooKeeper server, switch to the previous version, and start the server:
su - zookeeper -c "source /usr/hdp/current/zookeeper-server/conf/zookeeper-env.sh ; env ZOOCFGDIR=/usr/hdp/current/zookeeper-server/conf ZOOCFG=zoo.cfg /usr/hdp/current/zookeeper-server/bin/zkServer.sh stop"hdp-select set zookeeper-server 2.2.0.0-2041su - zookeeper -c "source /usr/hdp/current/zookeeper-server/conf/zookeeper-env.sh ; env ZOOCFGDIR=/usr/hdp/current/zookeeper-server/conf ZOOCFG=zoo.cfg /usr/hdp/current/zookeeper-server/bin/zkServer.sh start"Make sure that the ZooKeeper quorum has been reestablished before downgrading the next node. To check this, create a new znode on the node just downgraded, and then list the created znode.
For example, start a
zkcliprocess (ZooKeeper shell) that points to the local host (zkcliis in /usr/hdp/current/zookeeper-server/bin):./zkCli.sh localhostCreate a znode called
znode-1. Associate the stringmy_datawith the node:[zk: node-1:2181(CONNECTED) 20] create /znode-1 my_data Created /znode-1
List the node-1 test directory:
[zk: node-1:2181(CONNECTED) 21] ls /znode-1 []
Remove the test node and exit
zkcli:[zk: node-1:2181(CONNECTED) 22] delete /znode-1 [zk: node-1:2181(CONNECTED) 21] quit [hdp@node-1 bin]#
Repeat the validation step until successful or until you have completed ten attempts. If the test does not succeed after ten tries, see if the ZooKeeper process is running. If not, check ZooKeeper logs for an indication of the problem.
After downgrading ZooKeeper successfully on each node, restart the leader node.

