Hazelcast management-center
1 | docker pull hazelcast/management-center |
Hazelcast镜像单节点部署
下载镜像1
docker pull hazelcast/hazelcast
启动1
docker run -d -e JAVA_OPTS="-Dhazelcast.local.publicAddress=192.168.1.40:5701 -Dhazelcast.rest.enabled=true -Xms128M -Xmx256M" -p 5701:5701 hazelcast/hazelcast
注意:
- hazelcast.rest.enabled=true,需要开启,不然管理节点连不上
- docker需要后台启动服务-d,内部端口为5701
- 最好指定publicAddress且需要设置JVM大小
节点输出1
2
3Members {size:1, ver:1} [
Member [192.168.1.40]:5701 - dbbe08e2-ed8c-4228-9cf8-a0ab0ae08632 this
]
Hazelcast镜像多节点multicast
集群部署
节点1:1
docker run -d -e JAVA_OPTS="-Dhazelcast.local.publicAddress=192.168.1.43:5701 -Dhazelcast.rest.enabled=true -Xms128M -Xmx256M" -e MANCENTER_URL="http://192.168.1.40:8200/hazelcast-mancenter" -p 5701:5701 hazelcast/hazelcast
节点2:1
docker run -d -e JAVA_OPTS="-Dhazelcast.local.publicAddress=192.168.1.43:5702 -Dhazelcast.rest.enabled=true -Xms128M -Xmx256M" -e MANCENTER_URL="http://192.168.1.40:8200/hazelcast-mancenter" -p 5702:5701 hazelcast/hazelcast
注意:
- 指定MANCENTER_URL管理节点地址
- multicast广播必须为同一台集群,因为docker下广播必须本机容器才能连接
Hazelcast镜像多节点TCP-IP
集群部署
hazelcast.xml配置:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <management-center enabled="true">http://192.168.1.40:8200/hazelcast-mancenter</management-center>
...
<port auto-increment="true" port-count="10">5701</port>
...
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true">
<interface>192.168.1.40-45</interface>
<member-list>
<member>192.168.1.40</member>
<member>192.168.1.43</member>
</member-list>
</tcp-ip>
节点11
docker run -d -e JAVA_OPTS="-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml -Dhazelcast.local.publicAddress=192.168.1.40:5701 -Dhazelcast.rest.enabled=true -Xms128M -Xmx512M" -v /home/xxx:/opt/hazelcast/config_ext -p 5701:5701 hazelcast/hazelcast
节点21
docker run -d -e JAVA_OPTS="-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml -Dhazelcast.local.publicAddress=192.168.1.43:5701 -Dhazelcast.rest.enabled=true -Xms128M -Xmx512M" -v /home/xxx:/opt/hazelcast/config_ext -p 5701:5701 hazelcast/hazelcast
输出1
2
3
4Members {size:2, ver:2} [
Member [192.168.1.40]:5701 - cd40d155-d993-46a5-b07c-19f001c71f3c
Member [192.168.1.43]:5701 - 34d0798c-37d0-42e8-88f0-1268eab9a90a this
]
注意:
- 端口自增限制为10,即每个机器端口限制为5701-5711,以提高发现效率
- multicast关闭,tcp-ip开启
- 限制interface,指定ip范围
- 指定member-list,指定集群成员
- 指定宿主机配置文件地址
配置
登录management-center
- 打开地址:http://192.168.1.40:8200/hazelcast-mancenter
- 第一次设置初始化账户和密码,密码有格式要求
- 添加成员节点,即Change URL
- 输入Cluster Name and Password,即集群名和集群密码
- 输入Server UR,为Management Center URL,即管理系统地址;例如http://192.168.1.40:8200/hazelcast-mancenter
测试连接
引入包pom.xml
1 | <dependency> |
client代码
1 | 4j |