Java远程服务器调优

Java远程调优可采用两种方式进行连接,jmx与jstatd

1. 配置jmx进行连接调优

配置指南

官网说明

配置 功能 备注
-Dcom.sun.management.jmxremote.authenticate connection authenticate true / false
-Dcom.sun.management.jmxremote.port jmx connection remote port 1~65535
-Dcom.sun.management.jmxremote.local.only remote can connection true / false
-Dcom.sun.management.jmxremote.ssl enable ssl connection true / false
-Djava.rmi.server.hostname multi eth choose ip / domain
-Dcom.sun.management.jmxremote.access.file remote access roles file path
-Dcom.sun.management.jmxremote.password.file remote authenticate file when auth config enable file path

1.1 配置实例

Demo1--不启用认证

java 
 -Dcom.sun.management.jmxremote.authenticate=false 
 -Dcom.sun.management.jmxremote.port=9091 
 -Dcom.sun.management.jmxremote.ssl=false 

Demo2--启用用户认证

java 
 -Dcom.sun.management.jmxremote.authenticate=true 
 -Dcom.sun.management.jmxremote.port=9091 
 -Dcom.sun.management.jmxremote.access.file=./jmxremote.access 
 -Dcom.sun.management.jmxremote.password.file=./jmxremote.password 
 -Dcom.sun.management.jmxremote.ssl=false 

1.2 修改权限文件和密码文件,并赋权

a. 编辑./jmxremote.access权限文件
monitorRole readonly
controlRole readwrite

b. 编辑./jmxremote.password密码文件
monitorRole你的密码

c. 修改访问权限

chmod 400 ./jmxremote.access
chmod 400 ./jmxremote.password

1.3 启动Java服务

待服务启动后,查看9091端口是否开启
netstat -nltp
Java远程服务器调优

1.4 启动jvisualvm或者jconsole

运行JAVA_HOME/bin目录下的jconsole或jvisualvm,打开控制台,然后建立连接,填写地址、端口号、用户名、口令即可连接。

1.4.1 jvisualvm

添加远程主机地扯
添加jmx端口
已连接视图如下
Java远程服务器调优
Java远程服务器调优

1.4.2 jconsole

新建连接--远程进程
已连接视图如下
Java远程服务器调优

2. 配置jstatd进行连接调优

待补充