zookeeper not starting
Asked Answered
F

5

32

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]
Fatty answered 1/8, 2012 at 18:7 Comment(2)
try starting server with "start-foreground" to see full log of problemAurelioaurelius
I had a problem with my config, e.g. server.1=192.168.187.75:2888:3888 server.2=192.168.187.77:2888:3888 server.3=192.168.187.78:2888:3888 commenting out those resolved the issuePtyalism
I
91

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

Ingres answered 23/8, 2012 at 13:38 Comment(3)
Accepted answer? - I got the same error in zk 3.4.5 when running zkServer start, running without start fixed itPeltz
What if we want to run multiple zk nodes on one Windows. How can we start 2nd zk nodes if we can't specify CLI arguments? Will "zkServer start zoo1.cfg" fails again?Marked
This bug is related to the windows script ; see those issues : issues.apache.org/jira/browse/…Eastbourne
S
4

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.

Strikebreaker answered 17/7, 2018 at 5:38 Comment(0)
S
3

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

Selfexistent answered 20/5, 2020 at 4:16 Comment(1)
2 hours of frustration and finally found logical answer. Thanks a lot!Lowry
W
2

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.

Workhouse answered 22/3, 2013 at 9:18 Comment(1)
No! "zkServer start" will cause error, which should be this way! Most of open source stuff is ok for Unix but errornwous for Windows.Marked
D
0
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,

Dysphonia answered 12/5, 2020 at 11:27 Comment(2)
Solution is: download bin.tar file "apache-zookeeper-3.5.5-bin.tar.gz " i have downloaded just a tar file by mistakeDysphonia
Please put the proposed solution in the answer instead of this commentReticule

© 2022 - 2024 — McMap. All rights reserved.