title: Zookeeper connecting to localhost
body: <p>While running Pig Script which is inserting data into HBase i got following error.</p>
  
  <pre><code>2013-10-25 14:57:03,147 [main-SendThread(localhost:2181)] INFO 
  org.apache.zookeeper.ClientCnxn - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
  2013-10-25 14:57:03,147 [main-SendThread(localhost:2181)] INFO  org.apache.zookeeper.ClientCnxn - Socket connection established to localhost/127.0.0.1:2181, initiating session
  2013-10-25 14:57:03,169 [main-SendThread(localhost:2181)] INFO  org.apache.zookeeper.ClientCnxn - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x41ead7bb150092, negotiated timeout = 180000
  </code></pre>
  
  <p>Also when i see slave logs it says that unable to establish connection to master, But master says that connection is established successfully. Below are the logs of both:</p>
  
  <p><strong>Master Log :</strong></p>
  
  <pre><code>zookeeper.ZooKeeper: Initiating client connection, connectString=slave:2181,hadoop-master:2181,ubuntu:2181 sessionTimeout=180000 watcher=hconnection
  13/10/24 19:51:56 INFO zookeeper.ClientCnxn: Opening socket connection to server slave:2181. Will not attempt to authenticate using SASL (unknown error)
  13/10/24 19:51:56 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 104744@hadoop-master
  13/10/24 19:51:56 INFO zookeeper.ClientCnxn: Socket connection established to slave:2181, initiating session
  13/10/24 19:51:56 INFO zookeeper.ClientCnxn: Session establishment complete on server slave:2181, sessionid = 0x141ead77c250002, negotiated timeout = 180000
  </code></pre>
  
  <p><strong>Slave Log</strong></p>
  
  <pre><code>2013-10-24 19:51:32,174 INFO org.apache.zookeeper.server.quorum.FastLeaderElection: New election. My id =  1, proposed zxid=0x80000002a
  2013-10-24 19:51:32,180 WARN org.apache.zookeeper.server.quorum.QuorumCnxManager: Cannot open channel to 0 at election address hadoop-master:3888
  java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
  </code></pre>
  
  <p>Below are my configurations:</p>
  
  <p><strong>hbase-env.sh</strong></p>
  
  <pre><code>export HBASE_MANAGES_ZK=true
  </code></pre>
  
  <p><strong>hbase-site.xml</strong></p>
  
  <pre><code>&lt;configuration&gt;
      &lt;property&gt;
          &lt;name&gt;hbase.master&lt;/name&gt; 
          &lt;value&gt;hadoop-master:60000&lt;/value&gt;
          &lt;description&gt;
              The host and port that the HBase master runs at.
              A value of 'local' runs the master and a regionserver in a single process.
          &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hbase.rootdir&lt;/name&gt;
          &lt;value&gt;hdfs://hadoop-master:54310/hbase&lt;/value&gt;
          &lt;description&gt;
              The directory shared by RegionServers.
          &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hbase.cluster.distributed&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
          &lt;description&gt;
              The mode the cluster will be in. Possible values are
              false: standalone and pseudo-distributed setups with managed Zookeeper
              true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh)
          &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hbase.zookeeper.property.clientPort&lt;/name&gt;
          &lt;value&gt;2181&lt;/value&gt;
          &lt;description&gt;
              Property from ZooKeeper's config zoo.cfg.
              The port at which the clients will connect.
          &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hbase.zookeeper.quorum&lt;/name&gt;
          &lt;value&gt;hadoop-master,slave,ubuntu&lt;/value&gt;
          &lt;description&gt;
              Comma separated list of servers in the ZooKeeper Quorum.
              For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
              By default this is set to localhost for local and pseudo-distributed modes
              of operation. For a fully-distributed setup, this should be set to a full
              list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh
              this is the list of servers which we will start/stop ZooKeeper on.
          &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;dfs.replication&lt;/name&gt;
          &lt;value&gt;2&lt;/value&gt;
          &lt;description&gt;
              Default block replication.
              The actual number of replications can be specified when the file is created.
              The default is used if replication is not specified in create time.
          &lt;/description&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>By entering command jps i get following output:</p>
  
  <p><strong>At Master:</strong></p>
  
  <pre><code>104744 HMaster
  91841 JobTracker
  80184 TaskTracker
  91475 DataNode
  91222 NameNode
  105062 HRegionServer
  91747 SecondaryNameNode
  104666 HQuorumPeer
  </code></pre>
  
  <p><strong>At Slave:</strong></p>
  
  <pre><code>11533 HQuorumPeer
  2444 SecondaryNameNode
  5970 TaskTracker
  11756 HRegionServer
  </code></pre>