VisualVM监控远程服务SpringBoot

2023-12-23 07:50:18
1.启动参数

java -jar \
-Djava.rmi.server.hostname=192.168.14.11 \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=2622 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.access.file=/usr/jmxremote.access \
-Dcom.sun.management.jmxremote.password.file=/usr/jmxremote.password \
user.jar

-Djava.rmi.server.hostname 远程服务的地址

需要设置文件权限

chmod 0400 jmxremote.password

2.visual gc提示not supported for this jvm

在自己的jdk里 vim jdk/jre/lib/security/java.policy 加入permission java.security.AllPermission;

如下:

grant {?
// Allows any thread to stop itself using the java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to remain
// backwards compatible.
// It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe.
// See the API specification of java.lang.Thread.stop() for more
? ? ? ? // information.
permission java.lang.RuntimePermission "stopThread";


// allows anyone to listen on un-privileged ports
permission java.net.SocketPermission "localhost:1024-", "listen";


// "standard" properies that can be read by anyone


permission java.util.PropertyPermission "java.version", "read";
permission java.util.PropertyPermission "java.vendor", "read";
permission java.util.PropertyPermission "java.vendor.url", "read";
permission java.util.PropertyPermission "java.class.version", "read";
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "os.version", "read";
permission java.util.PropertyPermission "os.arch", "read";
permission java.util.PropertyPermission "file.separator", "read";
permission java.util.PropertyPermission "path.separator", "read";
permission java.util.PropertyPermission "line.separator", "read";


permission java.util.PropertyPermission "java.specification.version", "read";
permission java.util.PropertyPermission "java.specification.vendor", "read";
permission java.util.PropertyPermission "java.specification.name", "read";


permission java.util.PropertyPermission "java.vm.specification.version", "read";
permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
permission java.util.PropertyPermission "java.vm.specification.name", "read";
permission java.util.PropertyPermission "java.vm.version", "read";
permission java.util.PropertyPermission "java.vm.vendor", "read";
permission java.util.PropertyPermission "java.vm.name", "read";
permission java.security.AllPermission;
};

3.启动 jstatd -J-Djava.security.policy=jstatd.all.policy

jstatd -J-Djava.security.policy=jstatd.all.policy -p 端口xxx

Could not bind //:xxx/JStatRemoteHost to RMI Registry
java.rmi.NoSuchObjectException: no such object in table
?? ?at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
?? ?at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
?? ?at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:379)
?? ?at sun.rmi.registry.RegistryImpl_Stub.rebind(RegistryImpl_Stub.java:158)
?? ?at java.rmi.Naming.rebind(Naming.java:177)

端口被占用了

文章来源:https://blog.csdn.net/wangbang1/article/details/135140313
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。