Issue
On a Fusion 4.x node, ./fusion start (or starting ZooKeeper on its own) fails with a message like this:
Starting zookeeper.
Error starting zookeeper: zookeeper service (pid NNNNN) failed
ZooKeeper does not stay up. Because most Fusion services depend on ZooKeeper, the other services on that node may not start either.
Environment
- Fusion 4.x (self-hosted), using the start/stop scripts in
$FUSION_HOME/bin - ZooKeeper running as an ensemble across several servers (for example, three nodes)
Diagnosis
The zookeeper service (pid NNNNN) failed line is a generic wrapper message. It only tells you that the ZooKeeper process exited during startup. To find the actual cause, check the ZooKeeper log on the failing server:
$FUSION_HOME/var/log/zookeeper/zookeeper.log
Also check for leftover Java processes on the server:
ps -ef | grep java
This issue applies if the log shows the same pattern on every start attempt, like this:
INFO [main:server.persistence.FileSnap@86] - Reading snapshot data/zookeeper/version-2/snapshot.<id>
ERROR [main:server.persistence.Util@214] - Last transaction was partial.
ERROR [main:server.persistence.Util@214] - Last transaction was partial.
ERROR [main:server.quorum.QuorumPeer@692] - Unable to load database on disk
java.io.IOException: Unreasonable length = -1426063360
...
ERROR [main:server.quorum.QuorumPeerMain@92] - Unexpected exception, exiting abnormally
These errors mean that this node's local ZooKeeper data (a snapshot or transaction log file under data/zookeeper/version-2/) is corrupt or truncated, so ZooKeeper can't load it into memory.
Resolution
In an ensemble, every ZooKeeper node holds a full copy of the data. If the other nodes are healthy, the failing node can drop its corrupt local file and get a fresh copy from the leader.
Important: Only do this on the single failing node, and only after confirming that the rest of the ensemble is healthy. Don't delete ZooKeeper data on more than one node.
-
Confirm the other ZooKeeper nodes are up and that one of them is the leader. From a machine that can reach them, run the
statfour-letter command against each healthy node (for example, overtelnetorncon the ZooKeeper client port, which is9983by default in Fusion 4):echo stat | nc <zk-host> 9983Check the
Mode:line. One node should reportleaderand the othersfollower. -
Stop the Fusion services. Run
./fusion stopand check withps -ef | grep javathat no Fusion Java processes are left on the failing node. -
Remove the problematic file from the failing node. In the failing node's ZooKeeper data directory (
$FUSION_HOME/data/zookeeper/version-2/by default), move the snapshot file named in the log (snapshot.<id>) out of the directory. Keeping a backup copy somewhere else is a good idea. -
Restart the services. Run
./fusion start. ZooKeeper on the repaired node connects to the leader, downloads the current data, and rejoins the ensemble. -
Verify. Run
statagainst the repaired node and check that it reportsfollower(orleader). Then run./fusion statusto confirm that all Fusion services are running.
Automatically restarting Fusion services
To have Fusion 4.x services restart automatically when they stop, instead of restarting them by hand, you can run them under systemd. For setup instructions, see Using systemd to manage processes in the Fusion 4 deployment documentation.
Additional information
- If ZooKeeper is a single standalone node with no ensemble, no other node has a copy to sync from. Removing local ZooKeeper data in that setup permanently deletes Fusion's configuration. If that applies to you, contact support.
- If the ZooKeeper log shows a different error, such as a port already in use, follow the cause that the log points to.