Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

How to configure multiple hazelcast tcp-ip clusters in one yaml file?

To configure one cluster in one yml file, I could do:

hazelcast:
  cluster-name: cluster1
  network: 
    join:
      multicast: 
        enabled: false
      tcp-ip:
        enabled: true
        member-list:
          - machineA
          - machineB

However, because of the way the yaml file is structured, I find it difficult to do a yaml file with 2 clusters. If I do it the following way, it would not work:

hazelcast:
  cluster-name: 
   - cluster1
       network: 
         join:
           multicast: 
             enabled: false
           tcp-ip:
             enabled: true
             member-list:
               - machineA
               - machineB
   - cluster2
       network: 
         join:
           multicast: 
             enabled: false
           tcp-ip:
             enabled: true
             member-list:
               - machineC
               - machineD
question from:https://stackoverflow.com/questions/65905503/how-to-configure-multiple-hazelcast-tcp-ip-clusters-in-one-yaml-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should define separate configurations per cluster. What you did is an invalid configuration. Say you have two different configurations: cluster1.yaml config and cluster2.yaml config. Then all the members of cluster1 should start with cluster1.yaml and the ones in cluster2 should use cluster2.yaml. If you need multiple clusters to be aware of each other - e.g being synchronized, consider using WAN Replication.

In that case the configurations will look like:

cluster1.yaml:

hazelcast:
  cluster-name: cluster1
  network:
    join:
      tcp-ip:
        enabled: true
        member-list:
          - A  # uses this config
          - B  # uses this config

cluster2.yaml:

hazelcast:
  cluster-name: cluster2
  network:
    join:
      tcp-ip:
        enabled: true
        member-list:
          - C  # uses this config
          - D  # uses this config

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...