For ZK to be available, you need a majority of the servers in ZK to be available. If you only have 2 servers in ZK, ZK service will be unavailable if either of them is down. You should use at least 3 servers in ZK if you want any fault tolerance.
Thanks, Jun On Mon, Feb 27, 2012 at 12:14 AM, 刘明敏 <[email protected]> wrote: > I get two nodes for ZooKeeper(XX.XX.XX.231 and 229) and one node for > Broker(XX.XX.XX.227),it works well until I shutdown one of the two > ZooKeeper nodes:the broker fails to connect to the other living zookeeper. > > This is the log from zookeeper(firstly it tried to connect to the living > node XX.XX.XX.231,then tried the dead node:XX.XX.XX.229,Both failed): > > [2012-02-27 14:09:19,685] INFO Unable to read additional data from server > sessionid 0x135bd82dbe90001, likely server has closed socket, closing > socket connection and attempting reconnect > (org.apache.zookeeper.ClientCnxn) > [2012-02-27 14:09:19,786] INFO zookeeper state changed (Disconnected) > (org.I0Itec.zkclient.ZkClient) > [2012-02-27 14:09:20,028] INFO Opening socket connection to > server XX.XX.XX.231/XX.XX.XX.231:2182 (org.apache.zookeeper.ClientCnxn) > [2012-02-27 14:09:20,035] INFO Socket connection established > to XX.XX.XX.231/XX.XX.XX.231:2182, initiating session > (org.apache.zookeeper.ClientCnxn) > [2012-02-27 14:09:20,037] INFO Unable to read additional data from server > sessionid 0x135bd82dbe90001, likely server has closed socket, closing > socket connection and attempting reconnect > (org.apache.zookeeper.ClientCnxn) > [2012-02-27 14:09:20,527] INFO Opening socket connection to > server XX.XX.XX.229/XX.XX.XX.229:2181 (org.apache.zookeeper.ClientCnxn) > [2012-02-27 14:09:20,528] WARN Session 0x135bd82dbe90001 for server null, > unexpected error, closing socket connection and attempting reconnect > (org.apache.zookeeper.ClientCnxn) > java.net.ConnectException: Connection refused > at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) > at > sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:701) > at > org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119) > > > This is the log from the living zookeeper(zooKeeper refuse session request > due to `zxid` staff,which I don't quite get it): > > [2012-02-27 14:54:50,261] INFO Accepted socket connection from > /XX.XX.XX.227:48602 (org.apache.zookeeper.server.NIOServerCnxn) > [2012-02-27 14:54:50,261] INFO Refusing session request for client > /XX.XX.XX.227:48602 as it has seen zxid 0x1120 our last zxid is 0x2c client > must try another server (org.apache.zookeeper.server.NIOServerCnxn) > [2012-02-27 14:54:50,261] INFO Closed socket connection for client > /XX.XX.XX.227:48602 (no session established for client) > (org.apache.zookeeper.server.NIOServerCnxn) > > Why am I causing this `zxid` error , anything I am doing wrong here? > > I thought the broker can automatic connect to another zookeeper if the one > that it is connecting to fails,right? > > Thanks > > -- > Best Regards > > ---------------------- > 刘明敏 | mmLiu >
