Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zookeeper not starting

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]
like image 390
Krishna Gangaraju Avatar asked Aug 01 '12 18:08

Krishna Gangaraju


People also ask

How do I start the ZooKeeper command?

To start the ZooKeeper server on a Linux system, use the Zookeeper/zookeeper/bin/zkServer.sh restart command from your Watson Explorer installation directory. On Microsoft Windows systems, use the Zookeeper\zookeeper\bin\zkServer.

What happens if ZooKeeper fails?

If one the ZooKeeper nodes fails, the following occurs: Other ZooKeeper nodes detect the failure to respond. A new ZooKeeper leader is elected if the failed node is the current leader. If multiple nodes fail and ZooKeeper loses its quorum, it will drop into read-only mode and reject requests for changes.


4 Answers

just omit the "start" parameter and call "bin\zkServer" instead.

like image 136
Andi Avatar answered Sep 28 '22 05:09

Andi


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.

like image 32
chandan singh Avatar answered Sep 28 '22 05:09

chandan singh


java.lang.NumberFormatException: For input string: "C:\Development\apps\zookeeper\zookeeper3.4.1\bin..\conf\zoo.cfg"

It seems you run the zkServer with the "start" and the location of the zoo.cfg file, namely, "C:\Development\apps\zookeeper\zookeeper3.4.1\bin..\conf\zoo.cfg", and another parameter, which adds up to 3 parameters:

./zkServer start C:\Development\apps\zookeeper\zookeeper3.4.1\bin..\conf\zoo.cfg xxx

So, the problem can be solved by simply remove the second and third parameter, which makes the command to:

./zkServer start

The reason behind this is because the classes(QuorumPeerMain, ZooKeeperServerMain) zkServer uses to initialize the zookeeper system accept various number of parameters and behave accordingly. When you feed two parameters to zkServer, the meaning behind the two parameters supposed to be port and datadir. Yeah, port should be a number, and here comes your bomb.

BTW, the bootstrap scripts are coming with help instructions when you execute them without any para.

like image 44
DarKeViLzAc Avatar answered Sep 28 '22 05:09

DarKeViLzAc


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 %*

like image 40
Chao Avatar answered Sep 28 '22 05:09

Chao