首页 > 数据库 > > openfire Hazelcast插件集群配置
注意虽然hazelcast 官方已经有了3.5.2版本,但是openfire的hazelcast插件最新版却不是3.5.2,如果需要在openfire中使用hazelcast的最新版,请前往http://www.igniterealtime.org/projects/openfire/plugins.jsp下载
本人撰写本文的时候openfire的hazelcast插件最新版为2.1.2,2015年9月16号更新,已经是最新版本了。

主要有以下三种方式
With the multicast auto-discovery mechanism, Hazelcast allows cluster members to find each other using multicast communication. The cluster members do not need to know the concrete addresses of the other members, they just multicast to all the other members for listening. It depends on your environment if multicast is possible or allowed.
官方给的示例
<network>
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
<multicast-time-to-live>32</multicast-time-to-live>
<multicast-timeout-seconds>2</multicast-timeout-seconds>
<trusted-interfaces>
<interface>192.168.1.102</interface>
</trusted-interfaces>
</multicast>
<tcp-ip enabled="false">
</tcp-ip>
<aws enabled="false">
</aws>
</join>
<network>
这个配置并不全面,实际工作配置中,< network>标签中还有其它子标签,而官方给的< join>标签是一个完整的配置,所以如果采用这种配置,请直接拷贝< join>标签。
如果需要使用multicast
首先,设置multicast标签为true
其次,设置multicast-group, multicast-port, multicast-time-to-live,等标签(实际工作中只设置了multicast-group和multicast-port标签,我使用的版本为2.1.2)
最后,设置tcp-ip和aws标签为false
我的配置如下(openfire hazelcast 2.1.2)
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false"/>
<aws enabled="false"/>
</join>
官方解释
multicast element
The multicast element includes parameters to fine tune the multicast join mechanism.
- enabled: Specifies whether the multicast discovery is enabled or not, true or false.
- multicast-group: The multicast group IP address. Specify it when you want to create clusters within the same network. Values can be between 224.0.0.0 and 239.255.255.255. Default value is 224.2.2.3.
- multicast-port: The multicast socket port that the Hazelcast member listens to and sends discovery messages through. Default value is 54327.
- multicast-time-to-live: Time-to-live value for multicast packets sent out to control the scope of multicasts. See more information here.
- multicast-timeout-seconds: Only when the nodes are starting up, this timeout (in seconds) specifies the period during which a node waits for a multicast response from another node. For example, if you set it as 60 seconds, each node will wait for 60 seconds until a leader node is selected. Its default value is 2 seconds.
- trusted-interfaces: Includes IP addresses of trusted members. When a node wants to join to the cluster, its join request will be rejected if it is not a trusted member. You can give an IP addresses range using the wildcard () on the last digit of IP address (e.g. 192.168.1. or 192.168.1.100-110).
下面解释一下< multicast>这个标签
If multicast is not the preferred way of discovery for your environment, then you can configure Hazelcast to be a full TCP/IP cluster. When you configure Hazelcast to discover members by TCP/IP, you must list all or a subset of the members’ hostnames and/or IP addresses as cluster members. You do not have to list all of these cluster members, but at least one of the listed members has to be active in the cluster when a new member joins.
官方给的示例
<network>
...
<join>
<multicast enabled="false">
</multicast>
<tcp-ip enabled="true">
<member>machine1</member>
<member>machine2</member>
<member>machine3:5799</member>
<member>192.168.1.0-7</member>
<member>192.168.1.21</member>
</tcp-ip>
...
</join>
...
</network>
如果需要使用TCP
首先,设置multicast和aws标签为false
其次,设置tcp-ip标签为ture
最后,使用member标签将节点添加到tcp-ip中(注意:很早以前的版本使用的是标签式hostname)
官方解释
The tcp-ip element includes parameters to fine tune the TCP/IP join mechanism.
- enabled: Specifies whether the TCP/IP discovery is enabled or not. Values can be true or false.
- required-member: IP address of the required member. Cluster will only formed if the member with this IP address is found.
- member: IP address(es) of one or more well known members. Once members are connected to these well known ones, all member addresses will be communicated with each other. You can also give comma separated IP addresses using the members element.
下面解释一下tcp-ip
tcp-ip标签使用以下标签来设置使用TCP/IP 做集群的加入机制
如果不提供端口,Hazelcast会自动尝试使用5701,5702等等,从5701递增
我的配置如下(openfire hazelcast 2.1.2)
<join>
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true">
<member>172.16.181.73:5701</member>
<member>172.16.181.74:5701</member>
<member>172.16.181.75:5701</member>
<member>172.16.181.76:5701</member>
</tcp-ip>
<aws enabled="false"/>
</join>
除了使用上述配置还可以使用地址区间配置如下(注意,members中配置至少两个)
<join>
<multicast enabled="false">
</multicast>
<tcp-ip enabled="true">
<members>172.16.181.73-75,172.16.181.76</members>
</tcp-ip>
<aws enabled="false"/>
</join>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70000523/viewspace-3163625/ ,如需转载,请注明出处,否则将追究法律责任。