This topic provides answers to some frequently asked questions about ZooKeeper.
- What do I do if the ZooKeeper service is unstable and unexpectedly restarts?
- What do I do if an error message that contains "Too many connections" is reported?
- How do I smoothly migrate data from the data directory of ZooKeeper to a new data directory?
What do I do if the ZooKeeper service is unstable and unexpectedly restarts?
- View the number of znodes on the Status tab of the ZooKeeper service page.
- View the size of snapshots.
- On the Configure tab of the ZooKeeper service page, search for the zk_data_dirs parameter and obtain its value. The value indicates the data directory of ZooKeeper.
- View the size of snapshots in the data directory.
- On the Configure tab of the ZooKeeper service page, search for the zk_data_dirs parameter and obtain its value. The value indicates the data directory of ZooKeeper.
If the number of znodes or the size of a snapshot is excessively large, check the distribution of znodes. Then, stop upper-layer applications from excessively using ZooKeeper based on the distribution of znodes.
What do I do if an error message that contains "Too many connections" is reported?
A possible cause is that the number of connections between each znode and a client IP address exceeds the upper limit.

If the issue persists after you modify the maxClientCnxns parameter, view the connection metric on the Status tab. If the number of connections continues to increase, check the processes of the ZooKeeper client. For example, check whether all unnecessary connections are closed. After you resolve the issues, the ZooKeeper client can run as expected.
How do I smoothly migrate data from the data directory of ZooKeeper to a new data directory?
- Change the data directory and save the configurations.
- On the Configure tab of the ZooKeeper service page, search for the zk_data_dirs parameter and change the value of this parameter to /mnt/disk2/zookeeper.
- In the upper-right corner of the Configure tab, click Save.
- In the Confirm Changes dialog box, configure Description and click OK.
- On the Configure tab of the ZooKeeper service page, search for the zk_data_dirs parameter and change the value of this parameter to /mnt/disk2/zookeeper.
- Deploy client configurations.
- In the upper-right corner of the Configure tab of the ZooKeeper service page, click Deploy Client Configuration.
- In the Cluster Activities dialog box, configure Description and click OK.
- In the Confirm message, click OK.
- Optional:Check the new data directory.
- Log on to the master node of the EMR cluster in SSH mode. For more information, see Log on to a cluster.
- Run the following command to view the value of the dataDir parameter in the zoo.cfg configuration file:
cat /etc/ecm/zookeeper-conf/zoo.cfg
If the command output shown in the following figure is returned, the data directory of ZooKeeper is changed.
- Stop the emr-header-1 node.
- On the Component Deployment tab of the ZooKeeper service page, find the emr-header-1 node and click Stop in the Actions column.
- In the Cluster Activities dialog box, configure Description and click OK.
- In the Confirm message, click OK.
- In the upper-right corner of the Component Deployment tab of the ZooKeeper service page, click History to view the stop progress. The emr-header-1 node is stopped if the value of the Status parameter is Successful.
- Change the data directory.
- Log on to the master node of the EMR cluster in SSH mode. For more information, see Log on to a cluster.
- Run the following command to change the data directory and configure related permissions
for the emr-header-1 node:
sudo rm -rf /mnt/disk2/zookeeper && sudo cp -rf /mnt/disk1/zookeeper /mnt/disk2/zookeeper && sudo chown hadoop:hadoop -R /mnt/disk2/zookeeper
- Start the emr-header-1 node.
- On the Component Deployment tab of the ZooKeeper service page, find the emr-header-1 node and click Start in the Actions column.
- In the Cluster Activities dialog box, configure Description and click OK.
- In the Confirm message, click OK.
Refresh the page until the value of the Status parameter for the emr-header-1 node is Good.
- Find the emr-worker-1 node and repeat Step 4 to Step 6.
- Find the emr-worker-2 node and repeat Step 4 to Step 6.
Data is migrated to the new data directory after the value of the Status parameter for all nodes is Good.Note The emr-worker-2 node was originally the leader. After you click Stop for the node in the Actions column, the node becomes a follower. The emr-worker-1 or emr-header-1 node becomes the leader.