Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-2116

zkCli.sh doesn't honor host:port parameter

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Implemented
    • Affects Version/s: 3.4.6
    • Fix Version/s: 3.6.0
    • Component/s: java client, scripts
    • Labels:
      None
    • Environment:

      Ubuntu 12

      Description

      This doc http://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html ("Connecting to ZooKeeper" section) says:

      Once ZooKeeper is running, you have several options for connection to it:

      Java: Use
      bin/zkCli.sh 127.0.0.1:2181

      In fact, it doesn't work that way. I am running ZooKeeper with a different port to listen to client connections (2888), and this command

      bin/zkCli.sh 127.0.0.1:2888
      

      is still trying to connect to 2181.

      output
      Connecting to localhost:2181
      2015-02-11 15:38:14,415 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
      2015-02-11 15:38:14,421 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=localhost
      2015-02-11 15:38:14,421 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.7.0_17
      2015-02-11 15:38:14,424 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
      2015-02-11 15:38:14,424 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.7.0_17/jre
      2015-02-11 15:38:14,424 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/opt/zookeeper-3.4.6/bin/../build/classes:/opt/zookeeper-3.4.6/bin/../build/lib/*.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/opt/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/opt/zookeeper-3.4.6/bin/../src/java/lib/*.jar:../conf::/usr/share/antlr3/lib/antlr-3.5-complete-no-st3.jar
      2015-02-11 15:38:14,425 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
      2015-02-11 15:38:14,425 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
      2015-02-11 15:38:14,425 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
      2015-02-11 15:38:14,425 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
      2015-02-11 15:38:14,425 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
      2015-02-11 15:38:14,426 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.8.0-41-generic
      2015-02-11 15:38:14,426 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=mnovikov
      2015-02-11 15:38:14,426 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/home/mnovikov
      2015-02-11 15:38:14,426 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/opt/zookeeper-3.4.6/bin
      2015-02-11 15:38:14,428 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@3107eafc
      Welcome to ZooKeeper!
      2015-02-11 15:38:14,471 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
      2015-02-11 15:38:14,479 [myid:] - WARN  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1102] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
      java.net.ConnectException: Connection refused
      	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
      	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)
      	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
      	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
      

      PS1 I can connect to ZK at 2888 using ZK Java client from code specifying the correct port with no issues. But CLI seems just to ignore the provided host:port parameter.

      PS2 Tried to run it with the pre-defined ZOOCFGDIR environment variable (to point to the path with the config file where the client port is set to 2888). No luck, same results as shown above.

        Attachments

          Activity

            People

            • Assignee:
              surendrasingh Surendra Singh Lilhore
              Reporter:
              csbubbles Maxim Novikov
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: