HazelCast独立集群配置

HazelCast

独立配置成集群

配置文件hazelcast.xml,默认配置:

Specifies the name and password for a cluster group you connect to.
Cluster groups allow you to create separate sub-cluster with different
names. The password is only checked when security is enabled on
Hazelcast members (Enterprise edition feature)

group:
	name: dev
	password: dev-pass

若想要hazelcast成群,node之间需要配置为相同的group name。

when Hazelcast instances are created, they are put in a global
registry with their creation names. “instance-name” gives you the
ability to get a specific Hazelcast instance from this registry by
giving the instance’s name.

instance-name: CLIENT_NAME

集群发现
Tcp机制发现集群
1、设置节点下除了以外的其他所有节点的设置enabled为false。
2、设置节点下节点的属性enabled为true
3、设置节点下为需要绑定的本机ip地址。
4、为集群中已启动节点的ip, 可只设置其中一个节点的ip。第一个启动的节点可配置为自己的ip地址。


```yaml
 hazelcast:
  #  serialization:
  #    serializers:
  #      - type-class: tech.deepq.info.common.message.ItemMessage
  #        class-name: info.jerrinot.subzero.Serializer

  network:
    join:
      multicast:
        enabled: false
      tcp-ip:
        enabled: true
#        interface: 127.0.0.1
#        required-member: 127.0.0.1:5701
#        member-list:
#          - 127.0.0.1:5751
#          - 127.0.0.1:5752
#          - 127.0.0.1:5753

如上文的第4点,member list 可以写入具体的节点地址。如果能用一些手段自动获取到部署的节点ip, 想更灵活一些可以不配置, 自动解析出ip端口后可以调用以下方法自动成群

config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(instance.getHost() + ":" + port) 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值