zoukankan      html  css  js  c++  java
  • zookeeper 故障重连机制

    一、连接多个服务器,用逗号隔开

      

    1. 如果在连接时候zk服务器宕机  
    2. To create a client session the application code must provide a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server (e.g.   
    3.   
    4. "127.0.0.1:4545" or "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"). The ZooKeeper client library will pick an arbitrary server and try to connect to it. If this connection fails, or if the client   
    5.   
    6. becomes disconnected from the server for any reason, the client will automatically try the next server in the list, until a connection is (re-)established.  
    7.   
    8.   
    9.   
    10.   
    11. 创建一个client session 应用代码必须提供一个连接字符串包含一个逗号分隔的主机:端口 列表,  
    12.   
    13. 每个对应到一个ZooKeeper server (e.g.   
    14.   
    15. "127.0.0.1:4545" or "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002").   
    16.   
    17. ZooKeeper 客户端库 会选择一个任意的server 和尝试连接到它。  
    18.   
    19. 如果这个连接失败,或者 如果客户端变的不能连接,客户端会自动 尝试下一个server 在列表里,知道一个连接重新创建。  
    20.   
    21.   
    22.   
    23. 如果已经连接之后服务器宕机  
    24. SessionMovedException. There is an internal exception that is generally not seen by clients called the SessionMovedException. This exception occurs because a request was received on a connection   
    25.   
    26. for a session which has been reestablished on a different server. The normal cause of this error is a client that sends a request to a server, but the network packet gets delayed, so the client   
    27.   
    28. times out and connects to a new server. When the delayed packet arrives at the first server, the old server detects that the session has moved, and closes the client connection. Clients normally do   
    29.   
    30. not see this error since they do not read from those old connections. (Old connections are usually closed.) One situation in which this condition can be seen is when two clients try to reestablish   
    31.   
    32. the same connection using a saved session id and password. One of the clients will reestablish the connection and the second client will be disconnected (causing the pair to attempt to re-establish   
    33.   
    34. its connection/session indefinitely).  
    35.   
    36.   
    37. SessionMovedException. 有一个内部的异常,那是通常不被客户端请求SessionMovedException 看到。  
    38.   
    39.   
    40.   
    41. 这个exception 因为 一个请求被接收在一个连接对于一个会话 精被重新建立到一个不同的zk server.  
    42.   
    43. 这个错误的通常情况是一个客户端发送一个请求到一个服务器,  
    44.   
    45. 但是网络包延时了,因此客户端超时 ,连接到一个新的服务器.当延迟的packet 到达第一个server,  
    46.   
    47.   
    48. old server 检测倒 session 已经移动了,关闭客户端连接。  
    49.   
    50. 客户端通常不会看到这个错误 因为它们不会从老的连接读取(老的连接通常是被关闭的)  
    51.   
    52.   
    53. 一种情况是这个状况可以被看到当 2个客户端尝试重建建立相同的连接使用一个保存的会话id和密码。  

    参考链接:http://blog.csdn.net/zhaoyangjian724/article/details/52218172  

  • 相关阅读:
    分享5个viewport相关的jQuery插件
    超棒的响应式jQuery网格布局插件 grida licious
    6款不容错过的超棒倒计时jQuery插件
    分享45套2011年和2012年的高质量免费网站模板
    分享11个使用方便的免费智能手机UI套件
    推荐30款超精致的体育类型的网站设计
    HDOJ1001
    HDOJ1003
    HDOJ1000
    HDOJ1002
  • 原文地址:https://www.cnblogs.com/mxh1099/p/6068545.html
Copyright © 2011-2022 走看看