DC / OS JMX访问 [英] DC/OS JMX Access
问题描述
我已经部署了一个DC / OS群集以进行天蓝色。我已经将带有Java应用程序的容器部署到集群中。但是我无法通过jmx访问它。
I have a dc/os cluster deployed to azure. I have deployed to the cluster a container with my java application. But I can't access it via jmx.
让我们以部署标准的tomcat图像为例:
Let's take the example of deploying a standart tomcat image:
1)我根据下一条指令打开了端口8081: https://docs.microsoft.com/zh-CN/azure/container-service/container-service-enable-public-access#open-a-port-portal 。
1) I opened a port 8081 according the next instruction: https://docs.microsoft.com/en-us/azure/container-service/container-service-enable-public-access#open-a-port-portal.
2)我使用下一个json部署了服务:
2) I deployed service using the next json:
{
"id": "/tomcat",
"instances": 1,
"cpus": 1,
"mem": 512,
"container": {
"type": "DOCKER",
"docker": {
"image": "tomcat:8.0",
"network": "BRIDGE",
"portMappings": [
{ "protocol": "tcp", "hostPort": 8080 , "containerPort": 8080 },
{ "protocol": "tcp", "hostPort": 8081 , "containerPort": 8081 }
]
}
},
"requirePorts": true,
"acceptedResourceRoles": [
"slave_public"
],
"env": {
"JAVA_OPTS": "-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=10.0.0.4 -Dcom.sun.management.jmxremote.port=8081 -Dcom.sun.management.jmxremote.rmi.port=8081 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
},
"healthChecks": [
{
"gracePeriodSeconds": 120,
"intervalSeconds": 30,
"maxConsecutiveFailures": 3,
"path": "/",
"portIndex": 0,
"protocol": "HTTP",
"timeoutSeconds": 5
}
]
}
要连接,我使用Oracle Java Mission Control。我将主机和端口字段分别填写为 prefixagents.westeurope.cloudapp.azure.com和 8081。但是我无法连接,并收到一条消息:无法连接。
To connect I use Oracle Java Mission Control. I fill fields 'Host' and 'Port' as 'prefixagents.westeurope.cloudapp.azure.com' and '8081'. But I can't connect and I get a message: 'Unable to connect'.
但是我可以使用telnet客户端成功连接到此端口:
But for all that I can succesfully connect to this port using telnet client:
telnet prefixagents.westeurope.cloudapp.azure.com 8081
我也可以连接到端口8080,并可以通过以下URL打开tomcat Web控制台:http://agents.westeurope.cloudapp.azure.com:8080
Also I can connect to port 8080 and I can open tomcat web console at the following URL: http://agents.westeurope.cloudapp.azure.com:8080
我又安装了一个jmx命令行客户端- http://wiki.cyclopsgroup.org/jmxterm/并尝试连接到该服务:
I installed one more jmx command line client - http://wiki.cyclopsgroup.org/jmxterm/ and tried to connect to the service:
java -jar jmxterm-1.0-alpha-4-uber.jar --url service:jmx:rmi:///jndi/rmi://<prefix>agents.westeurope.cloudapp.azure.com:8081/jmxrmi
我得到了下一个异常: java.rmi.ConnectException:连接被拒绝托管:10.0.0.4。 10.0.0.4是我的公共代理程序节点的主机名。
I got the next exception: "java.rmi.ConnectException: Connection refused to host: 10.0.0.4". And 10.0.0.4 is hostname of my public agents node.
我使用 https://docs.microsoft.com/en-us/azure/container-service/container-服务连接。我还在那里安装了jmxterm,并尝试通过jmx连接到该服务:
I connected to my dc/os cluster ( master node ) using https://docs.microsoft.com/en-us/azure/container-service/container-service-connect. I also installed there jmxterm and tried to connect to the service via jmx:
java -jar jmxterm.jar --url service:jmx:rmi:///jndi/rmi://10.0.0.4:8081/jmxrmi
我已成功连接。
没有人知道为什么我可以从主节点通过jmx连接到服务,但不能从本地计算机连接吗?打开端口8081。
Does anybody have any ideas why I can connect to the service via jmx from my master node but I can't from my local machine? Port 8081 is opened.
推荐答案
我在JAVA_OPTS字符串中更改了-Djava.rmi.server.hostname属性的值:-Djava .rmi.server.hostname =公共代理IP。它对我有用。
在端口8081打开的情况下,标准的tomcat容器的工作配置:
I changed a value of property -Djava.rmi.server.hostname in JAVA_OPTS string: -Djava.rmi.server.hostname="public agent ip". And it works for me. Working configuration for a standart tomcat container in case that port 8081 is open:
{
"id": "/tomcat",
"instances": 1,
"cpus": 1,
"mem": 512,
"container": {
"type": "DOCKER",
"docker": {
"image": "tomcat:8.0",
"network": "BRIDGE",
"portMappings": [
{ "protocol": "tcp", "hostPort": 8080 , "containerPort": 8080 },
{ "protocol": "tcp", "hostPort": 8081 , "containerPort": 8081 }
]
}
},
"requirePorts": true,
"acceptedResourceRoles": [
"slave_public"
],
"env": {
"JAVA_OPTS": "-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=<public agent ip> -Dcom.sun.management.jmxremote.port=8081 -Dcom.sun.management.jmxremote.rmi.port=8081 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
},
"healthChecks": [
{
"gracePeriodSeconds": 120,
"intervalSeconds": 30,
"maxConsecutiveFailures": 3,
"path": "/",
"portIndex": 0,
"protocol": "HTTP",
"timeoutSeconds": 5
}
]
}
我可以通过jmx连接到tomcat从本地计算机使用:host = public agent ip and port = 8081
And I can connect to tomcat via jmx using from local machine: host="public agent ip" and port=8081
public agent ip = prefix agents.westeurope.cloudapp.azure.com
public agent ip = "prefix"agents.westeurope.cloudapp.azure.com
这篇关于DC / OS JMX访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!