Java 在服务器上配置jconsole还需要什么

Java 在服务器上配置jconsole还需要什么,java,configuration,jmx,jconsole,Java,Configuration,Jmx,Jconsole,我想将jmx与Jconsole一起使用 ## enable jconsole access JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.password.file=/usr/pkg/tomcat-rusznak/jmxremote.password -Dcom.sun.management.

我想将jmx与Jconsole一起使用

## enable jconsole access
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote  -Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.password.file=/usr/pkg/tomcat-rusznak/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/usr/pkg/tomcat-rusznak/jmxremote.access -Djava.rmi.server.hostname=ba.accra.com"
下面是jmxremote.password文件的内容

monitorRole password
controlRole password
以下是jmxremote.access文件的内容

monitorRole   readonly
controlRole   readwrite \
              create javax.management.monitor.*,javax.management.timer.* \
              unregister
但是,当我提供正确的主机名、端口并尝试使用monitorOLE-密码对登录时,我得到的是:

Connection failed: connection refused.
为什么?

我检查了很多类似的问题,例如,我从stackoverflow知道我也需要包含主机名(-Djava.rmi.server.hostname=ba.accra.com),但这并不能解决问题,显然有些地方出错了。我还需要什么

已编辑

我不知道它是否相关,但我想补充一点,我在本地启动jconsole没有问题(尽管连接总是被拒绝),但我甚至无法在服务器上启动它

jconsole: not found

好的,实际上,默认情况下会启用以下选项:

  • com.sun.management.jmxremote.authenticate
  • com.sun.management.jmxremote.ssl
如前所述,如果启用了SSL,则需要在正确配置SSL的情况下运行JConsole。
我认为您应该尝试通过在启动应用程序的脚本中添加此选项来禁用SSL:
com.sun.management.jmxremote.SSL=false

我有一个解决方案:

另见:

如果您的Java进程在防火墙后面的Linux上运行,并且您希望在本地计算机上的Windows上启动Jconsole

注意:如果您没有putty.exe(如果您是linux Order mac os用户),也可以使用ssh命令添加隧道


1.您需要在此处为Windows计算机安装putty套件:

至少是putty.exe文件


2.首先检查linux机器上的ip地址

3.在linux计算机上定义两个可用端口:

4.在linux机器上向java进程添加参数

5.使用putty从Windows计算机启用两个SSH隧道

6.在启用此SSH隧道的情况下登录到Linux计算机。 当您登录时,Putty将通过隧道将所有TCP连接传输到

localhost:15666 and localhost:15667


7.启动JConsole并使用以下URL连接到Java进程


8.享受:)你如何运行你的JConsole?您是否使用一些选项启动它?在服务器上,您是否将端口9999视为侦听?当您尝试telnet到服务器端口9999时,它是否工作?有防火墙吗?记住,这涉及到两个端口,任何防火墙都需要允许这两个端口。格雷:是的,当我尝试telnet时,9999端口会监听。我不是在跟踪你,另一个端口是什么?Sylvain:我在启动应用程序的脚本中添加了上面的行。我在服务器上运行它。然后我转到我的本地计算机,只需键入jconsole,当弹出窗口出现时,我会给出主机名、端口、用户名和密码。我在这里发布了一个有效的解决方案:我添加了这些行,但没有任何更改:-(-Dcom.sun.management.jmxremote.authenticate=false-Dcom.sun.management.jmxremote.ssl=false)设置身份验证后,只需定义
-Dcom.sun.management.jmxremote.ssl=false
。使用
authenticate=false
,您应该能够在没有用户名/密码的情况下进行连接。您在JConsole中设置了哪个URL?我记得因为仅仅输入hostname:port对我来说从来都不起作用,我总是使用
服务:jmx:///jndi/rmi://...
url。
your-linux-ip-adress = 10.20.30.40
<jmx-remote-port>
<jndi-remote-port>
jmx-remote-port = 15666      
jndi-remote-port = 15667
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=<jmx-remote-port>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.local.only=false
-Djava.rmi.server.hostname=<your-linux-ip-adress>
-Djava.rmi.activation.port=<jndi-remote-port>
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=15666 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=10.20.30.40 -Djava.rmi.activation.port=15667 ch.sushicutta.jmxremote.Main
Source port: <jmx-remote-port>
Destination: <your-linux-ip-adress>:<jmx-remote-port>
[x] Local       
[x] Auto       

Source port: <jndi-remote-port>
Destination: <your-linux-ip-adress>:<jndi-remote-port>
[x] Local       
[x] Auto
Source port: 15666
Destination: 10.20.30.40:15666
[x] Local       
[x] Auto       

Source port: 15667
Destination: 10.20.30.40:15667
[x] Local       
[x] Auto
localhost:15666 and localhost:15667
10.20.30.40:15666 and 10.20.30.40:15667
[x] Remote Process:
service:jmx:rmi://localhost:**<jndi-remote-port>**/jndi/rmi://localhost:<jmx-remote-port>/jmxrmi
[x] Remote Process:
service:jmx:rmi://localhost:15667/jndi/rmi://localhost:15666/jmxrmi