环境:centos 6
1.首先检查hostname是否正确,输入以下命令
hostname -i
如果输出机器ip,则表示正确,如果输出
hostname: Unknown host
查看/etc/hosts内容:
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
则需要在/etc/hosts中加入以下内容:
127.0.0.1 yourHostName localhost.localdomain localhost4 localhost4.localdomain4
2.修改tomcat配置catalina.sh
#CATALINA_OPTS
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
CATALINA_OPTS="${CATALINA_OPTS} -Djava.rmi.server.hostname=192.168.200.41"
截图如下:
不要使用JAVA_OPTS,不然关闭tomcat时,会报错
java.rmi.server.ExportException: Port already in use: