无法使用JStat连接到远程JVM

时间:2023-01-23 17:19:34

From the Jstat Documentation , jstat can be connected to a local as well as remote JVM. The URI can be formed as

从Jstat文档中,jstat可以连接到本地和远程JVM。 URI可以形成为

 [protocol:][//]lvmid[@hostname[:port]/servername]

I have a JVM running on one of the servers (CentOS) with JMX enabled -

我在其中一个启用了JMX的服务器(CentOS)上运行JVM -

xyz   23878     1  0 Jun01 ?        04:37:00 java -Xms1g -Xmx1g -XX:NewSize=512m -Xloggc:../9301/logs/gc.log -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=../9301/logs/oom.log **-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=19301 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false** -jar ../0.1.14/xyz-0.1.14.jar -serviceName <name> -dataCenter <name> servicePort 9301

I am able to connect to the JVM, from my local machine, using JVisualVM which uses a 2 step process -

我能够使用JVisualVM从我的本地机器连接到JVM,它使用两步过程 -

  1. Prompts to add the remote machine via jstatd connection on default port 1099 -> I am able to do so and server gets added proving RMI Registry is available
  2. 提示在默认端口1099上通过jstatd连接添加远程计算机 - >我能够这样做并且服务器被添加证明RMI Registry可用
  3. After Adding the server, you can add a JMX connection to the JVM on the exposed port -> Success as JMX is exposed by my program on port 19301 and I am able to view the details
  4. 添加服务器后,您可以在公开端口上将JMX连接添加到JVM - >成功,因为我的程序在端口19301上公开了JMX,我可以查看详细信息

I am, however, not able to use jstat for the same purpose though.

但是,我不能将jstat用于同一目的。

Running jstat -gc process_id@servername gives me the below exception -

运行jstat -gc process_id @ servername给出了以下异常 -

RMI Registry not available at <servername>:1099
Connection refused to host: <servername>; nested exception is: 
    java.net.ConnectException: Connection refused

Checked various sources over the net and they talk about having the jstatd running which I believe is running as VisualVM was able to add the machine.

通过网络查看了各种来源,他们谈到了运行jstatd,我相信它正在运行,因为VisualVM能够添加机器。

Ques: How should I frame the [vmid] part in the jstat command to connect

问:我应该如何构建jstat命令中的[vmid]部分来连接

1 个解决方案

#1


2  

You need to run jstatd on a remote host in order to use jstat.

您需要在远程主机上运行jstatd才能使用jstat。

Having RMI Registry running is not enough. The Registry is just for registering various RMI services. -Dcom.sun.management.jmxremote option starts jmxrmi service (which works for VisualVM), but jstat looks for JStatRemoteHost service.

让RMI Registry运行是不够的。注册表仅用于注册各种RMI服务。 -Dcom.sun.management.jmxremote选项启动jmxrmi服务(适用于VisualVM),但jstat查找JStatRemoteHost服务。

Once you've started jstatd, use jstat -options process_id@servername command to monitor the remote VM.

启动jstatd后,使用jstat -options process_id @ servername命令监视远程VM。

#1


2  

You need to run jstatd on a remote host in order to use jstat.

您需要在远程主机上运行jstatd才能使用jstat。

Having RMI Registry running is not enough. The Registry is just for registering various RMI services. -Dcom.sun.management.jmxremote option starts jmxrmi service (which works for VisualVM), but jstat looks for JStatRemoteHost service.

让RMI Registry运行是不够的。注册表仅用于注册各种RMI服务。 -Dcom.sun.management.jmxremote选项启动jmxrmi服务(适用于VisualVM),但jstat查找JStatRemoteHost服务。

Once you've started jstatd, use jstat -options process_id@servername command to monitor the remote VM.

启动jstatd后,使用jstat -options process_id @ servername命令监视远程VM。