1、在远程服务器安装jdk和tomcat
此处省略
2、编辑jmxremote.access和jmxremote.password
===============================================================
进入默认按照的 jdk 目录:
cd /usr/local/jdk1.8.0_91/jre/lib/management
cp jmxremote.password.template jmxremote.password
vi /usr/local/jdk1.8.0_91/jre/lib/management/jmxremote.password
# Following are two commented-out entries. The "measureRole" role has
# password "QED". The "controlRole" role has password "R&D".
#
monitorRole QED##
controlRole R#
把文件改为运行 tomcat 的用户,如果已经是不用修改
chown admin jmxremote.password jmxremote.access
chgrp admin jmxremote.password jmxremote.access
修改文件权限600,防止别的用户看到你密码
chmod 600 jmxremote.access jmxremote.password
下面是修改完后的图片
重启tomcat
sh bin/shutdown.sh
sh bin/startup.sh
===============================================================
3、配置tomcat的bin/catalina.sh文件
===============================================================
# Uncomment the following line to make the umask available when using the
# org.apache.catalina.security.SecurityListener
#JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`"
if [ -z "$USE_NOHUP" ]; then
if $hpux; then
USE_NOHUP="true"
else
USE_NOHUP="false"
fi
fi
unset _NOHUP
if [ "$USE_NOHUP" = "true" ]; then
_NOHUP=nohup
fi
#新增一行
CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=192.168.1.11(远程服务器ip) -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
# ----- Execute The Requested Command -----------------------------------------
# Bugzilla 37848: only output this if we have a TTY
if [ $have_tty -eq 1 ]; then
echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
if [ "$1" = "debug" ] ; then
echo "Using JAVA_HOME: $JAVA_HOME"
else
echo "Using JRE_HOME: $JRE_HOME"
fi
echo "Using CLASSPATH: $CLASSPATH"
if [ ! -z "$CATALINA_PID" ]; then
echo "Using CATALINA_PID: $CATALINA_PID"
fi
fi
if [ "$1" = "jpda" ] ; then
if [ -z "$JPDA_TRANSPORT" ]; then
JPDA_TRANSPORT="dt_socket"
fi
if [ -z "$JPDA_ADDRESS" ]; then
#JPDA_ADDRESS="localhost:8000" // 修改前
JPDA_ADDRESS="8000" // 修改后
fi
if [ -z "$JPDA_SUSPEND" ]; then
JPDA_SUSPEND="n"
fi
if [ -z "$JPDA_OPTS" ]; then
JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
fi
CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS"
shift
fi
===============================================================
4、启动tomcat
sh /usr/local/tomcat/bin/startup.sh
本地浏览器访问tomcat是否正常:http://192.168.1.11:7081/
5、检测JMX是否启动成功
打开cmd输入jvisualvm
6、Idea配置
此处不用在服务器端搭建sftp,user name是远程服务器用户名,password是远程服务器密码
7、dubug启动本地服务
===============================================================