docker - Hazelcast 无法连接到 Hazelcast-mancenter
问题描述
我编写了以下 docker-compose.yml 来使用 Mancenter 构建一个正在运行的 Hazelcast Docker-Instance。
version: "3"
services:
hazelcast:
image: hazelcast/hazelcast:3.12.9
container_name: hazelcast
restart: unless-stopped
environment:
MAX_HEAP_SIZE: "512m"
MIN_HEAP_SIZE: "512m"
JAVA_OPTS: "-Dhazelcast.rest.enabled=true
-Dhazelcast.mancenter.enabled=true
-Dhazelcast.mancenter.url=http://localhost:8080/hazelcast-mancenter"
ports:
- "5701:5701"
networks:
- default
hazelcast-management:
image: hazelcast/management-center:3.12.9
container_name: hazelcast-management
restart: unless-stopped
ports:
- "8080:8080"
networks:
- default
networks:
default:
driver: bridge
日志总是显示以下错误,即使我使用“127.0.0.1”或我的 IP 而不是 localhost。我对两者都使用相同的版本:hc 和 hc-mancenter。
hazelcast | Sep 23, 2020 11:38:35 AM com.hazelcast.internal.management.ManagementCenterService
hazelcast | INFO: [192.168.160.3]:5701 [dev] [3.12.9] Failed to pull tasks from Management Center
hazelcast | Sep 23, 2020 11:38:35 AM com.hazelcast.internal.management.ManagementCenterService
hazelcast | INFO: [192.168.160.3]:5701 [dev] [3.12.9] Failed to connect to: http://localhost:8080/hazelcast-mancenter/collector.do
问候, 多姆
解决方案
docker-compose 中的服务位于同一个“docker 网络”上,可以通过服务名称访问。当您使用 localhost 或 127.0.0.1 时,容器会尝试与其“自己的”localhost 进行通信。因此,Dhazelcast.mancenter.url=http://localhost:8080
您应该连接到Dhazelcast.mancenter.url=http://hazelcast-management:8080
. hazelcast 服务的容器应该有一个主机条目,将名称hazelcast-management
指向正确的容器 ip。
推荐阅读
- java - 设计审查:带有“版本切换”的 Spring JPA 实体版本控制
- android - 数据绑定:将 LiveData 原样传递给 BindingAdapter 并使用 LifecycleOwner 观察它
- regex - 模式匹配后的下一个单词
- verification - 在dafny中验证条件下的序列和
- android - MaterialDatePicker : 今天如何设置自定义
- c# - 使用 roslyn 在 c# 源代码中查找类引用
- angular - 量角器:为所有 browser.wait 调用设置超时
- c# - 使用 DisplayModeProvider 指定移动视图的 ASP.NET 应用程序启动时要转到的路由
- java - 使用 OR 检查 if 语句中的多个空值并将错误存储在数组中
- typescript - 从对象创建简单的字符串数组