在跨多个节点在docker中运行时,JGroups不会形成集群

时间:2017-05-12 17:47:45

标签: docker overlay jgroups swarm

我在docker容器中运行jgroups应用程序。容器在两个节点(A& B)上运行,并且它们都使用docker swarm模式覆盖网络连接。

我提到https://docs.docker.com/engine/swarm/networking/

这就是我所做的和观察到的。

  1. Jgroup绑定地址设置为容器的覆盖网络IP
  2. 在同一节点内运行的容器正在形成一个集群。
  3. 我使用nslookup确保节点A中运行的容器的覆盖网络IP可由节点B中运行的容器访问
  4. docker node ls正确显示节点,并能够成功安排容器实例。
  5. Docker版本:Docker版本17.03.1-ce,build c6d412e

    操作系统:Ubuntu 16.04.2

    云:AWS(端口7946 TCP / UDP和4789 UDP已打开)

    JGroups:3.6.6

    Jgroups XML:

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="urn:org:jgroups"
        xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
    <TCP bind_port="7600"
         recv_buf_size="${tcp.recv_buf_size:5M}"
         send_buf_size="${tcp.send_buf_size:5M}"
         max_bundle_size="64K"
         max_bundle_timeout="30"
         use_send_queues="true"
         sock_conn_timeout="300"
    
         timer_type="new3"
         timer.min_threads="4"
         timer.max_threads="10"
         timer.keep_alive_time="3000"
         timer.queue_max_size="500"
    
         thread_pool.enabled="true"
         thread_pool.min_threads="2"
         thread_pool.max_threads="8"
         thread_pool.keep_alive_time="5000"
         thread_pool.queue_enabled="true"
         thread_pool.queue_max_size="10000"
         thread_pool.rejection_policy="discard"
    
         oob_thread_pool.enabled="true"
         oob_thread_pool.min_threads="1"
         oob_thread_pool.max_threads="8"
         oob_thread_pool.keep_alive_time="5000"
         oob_thread_pool.queue_enabled="false"
         oob_thread_pool.queue_max_size="100"
         oob_thread_pool.rejection_policy="discard"/>
    
    <JDBC_PING connection_url="jdbc:mysql://${database.host:localhost}:3306/mydb"
               connection_username="root"
               connection_password="root"
               connection_driver="com.mysql.jdbc.Driver"
               initialize_sql="CREATE TABLE JGROUPSPING (
                        own_addr varchar(200) NOT NULL,
                        bind_addr varchar(200) NOT NULL,
                        created timestamp NOT NULL,
                        cluster_name varchar(200) NOT NULL,
                        ping_data varbinary(5000) DEFAULT NULL,
                        PRIMARY KEY (`own_addr`,`cluster_name`))"
       insert_single_sql="INSERT INTO JGROUPSPING (own_addr, bind_addr, created, cluster_name, ping_data) values (?,
       '${jgroups.bind_addr:127.0.0.1}',now(), ?, ?)"
       delete_single_sql="DELETE FROM JGROUPSPING WHERE own_addr=? AND cluster_name=?"
       select_all_pingdata_sql="SELECT ping_data FROM JGROUPSPING WHERE cluster_name=?"
    />
    
    <MERGE3  min_interval="10000"
             max_interval="30000"/>
    <FD_SOCK/>
    <FD timeout="3000" max_tries="3" />
    <VERIFY_SUSPECT timeout="1500"  />
    <BARRIER />
    <pbcast.NAKACK2 use_mcast_xmit="false"
                    discard_delivered_msgs="true"/>
    <UNICAST3 />
    <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
                   max_bytes="4M"/>
    <pbcast.GMS print_local_addr="true" join_timeout="2000"
                view_bundling="true"/>
    <MFC max_credits="2M"
         min_threshold="0.4"/>
    <FRAG2 frag_size="60K"  />
    <RSVP resend_interval="2000" timeout="10000"/>
    <pbcast.STATE_TRANSFER/>
    

    感谢任何帮助

1 个答案:

答案 0 :(得分:0)

除了--net=host之外,您可能还需要在传输中使用主机网络external_addr)或使用bind_addr

如果您有DNS可用的替代方法是DNS_PING [2]。

有关详情,请参阅[1]。

[1] https://github.com/belaban/jgroups-docker

[2] http://www.jgroups.org/manual4/index.html#_dns_ping