zookeeper not starting

Viewed 34672

i'm working with zookeeper (http://zookeeper.apache.org/). downloaded 3.3.5 and create zoo.cfg and placed in $ZOOKEEPER/conf, started the zookeeper using zkServer start. but following is the error

can any please help me here ..

 nfig or no quorum defined in config, running  in standalone mode
 2012-08-01 23:20:32,175 [myid:] - ERROR [main:ZooKeeperServerMain@54] - Invalid
 arguments, exiting abnormally
 java.lang.NumberFormatException: For input string: "C:\Development\apps\zookeeper\zookeeper3.4.1\bin\..\conf\zoo.cfg"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:449)
        at java.lang.Integer.parseInt(Integer.java:499)
        at org.apache.zookeeper.server.ServerConfig.parse(ServerConfig.java:60)
        at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:83)
        at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:52)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
 2012-08-01 23:20:32,177 [myid:] - INFO  [main:ZooKeeperServerMain@55] - Usage: Z
 ooKeeperServerMain configfile | port datadir [ticktime] [maxcnxns]
 Usage: ZooKeeperServerMain configfile | port datadir [ticktime] [maxcnxns]
5 Answers

In zoo.cfg file goto dataDir=/usr/zookeeper/data

In data folder create a file with name myid and write 1. Save the file and start zkServer

If you are running multiple instances, for every instance you need to create myid file in data folder and write with 1,2,3 respectively. Actually this is used for node leader election.

Open the zkServer.cmd, find this line

call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*

and delete the %* at the end of the line. the new start cmd line should be:

call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%"

then run zkServer start or zkServer. It should work now.


Explain:

In ZkServer source code. ZooKeeperServerMain.java

protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServerException {
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}

There're different parse methods for different argument length.

In case of one arguments, it will be took as config file path.

In case of multiple arguments, there is a fixed order.

1st arg(must): server port.
2nd arg(must): dataDir
3rd arg(optional): tickTime
4th arg(optional): maxClientCnxns

So back to zkServer.cmd, there're two placeholder in the arguments position.

%ZOOMAIN% "%ZOOCFG%" %*

I believe the developer expect a space for the %*, so it'll only one argument.

However, for most zk user. they're used to use zkServer start to start the server.

and finally, cmd turn out to be:

org.apache.zookeeper.server.quorum.QuorumPeerMain "C:\Users\...\scoop\apps\zookeeper\current\bin\..\conf\zoo.cfg" "start"

Two arguments are used. the 1st argument, the config path here, is took as port number. and then we have the exception.

More, how about using zkServer directly to start zooKeeper?

In my case, I was facing the same problem. Though we dont have any arguments. the zkServer.cmd still pass an empty string to the main method. like this:

org.apache.zookeeper.server.quorum.QuorumPeerMain "C:\Users\...\scoop\apps\zookeeper\current\bin\..\conf\zoo.cfg" ""

Conclusion: Just delete the redundant placeholder %*

sudo ./zkServer.sh start
[sudo] password for administrator:
/bin/java
ZooKeeper JMX enabled by default
Using config: apache-zookeeper-3.5.5/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START

The solution is: download bin.tar file "apache-zookeeper-3.5.5-bin.tar.gz " I had downloaded just a tar file by mistake,

Related