zookeeper [myid:] – ERROR [main:QuorumPeerMain@85] – Invalid config, exiting abnormally


When configuring zookeeper replication the using the config file on three hosts

tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.1.12:2888:3888
server.2=192.168.1.13:2888:3888
server.3=192.168.1.14:2888:3888

and attempting to start the service we see the following error

2016-12-14 21:12:19,656 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /opt/zoo/bin/../conf/zoo.cfg
2016-12-14 21:12:19,676 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: 192.168.1.12 to address: /192.168.1.12
2016-12-14 21:12:19,676 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: 192.168.1.14 to address: /192.168.1.14
2016-12-14 21:12:19,677 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: 192.168.1.13 to address: /192.168.1.13
2016-12-14 21:12:19,677 [myid:] - INFO  [main:QuorumPeerConfig@352] - Defaulting to majority quorums
2016-12-14 21:12:19,683 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /opt/zoo/bin/../conf/zoo.cfg
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:144)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Caused by: java.lang.IllegalArgumentException: /var/zookeeper/myid file is missing
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:362)
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:140)
        ... 2 more
Invalid config, exiting abnormally

An ID needs to be assigned to each host. Run one of these per host

On host1
echo 1 > /var/zookeeper/myid

On host2
echo 2 > /var/zookeeper/myid

On host3
echo 3 > /var/zookeeper/myid

Now start zookeeper on each server using

zkServer.sh start