简体   繁体   中英

Running 2 instance of tomcat on a single server

I am trying to run 2 instance of tomcat on a single. I have updated server.xml for both the tomcat instance so that the http/https ports are different. Also I have updated CATALINA_OPTS in the setenv.sh so that remote jmx port is different.

CATALINA_OPTS for tomcat 1:

CATALINA_OPTS="-Dcom.sun.management.jmxremote \
    -Dcom.sun.management.jmxremote.port=7061 \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -javaagent:/mnt/production/tomcat/bin/remoteagent.jar"

CATALINA_OPTS for tomcat 2:

CATALINA_OPTS="-Dcom.sun.management.jmxremote \
    -Dcom.sun.management.jmxremote.port=7065 \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -javaagent:/mnt/production/tomcat/bin/remoteagent.jar \
    -Djava.security.auth.login.config=$CATALINA_HOME/conf/crowd.conf"

But when I try to start the second instance of tomcat I get a bind exception on port 3000. I greped the logs for 1st instance of tomcat and I see the following line in the catalina log file:

Created service URL service:jmx:rmi://localhost:3001/jndi/rmi://localhost:3000/jmxrmi

I greped the entire tomcat directory for 3000 but there isn't a config regarding port 3000. So I think this is some default config. Does someone know how to modify this config.

server.xml is used to set tomcat server ports,such as http, https, shutdown, AJP, etc. But not for jmx remote.

Seems you have a separate environment file setenv.sh (unix) or setenv.bat (windows) which set JMX connection URL

Attribute   Description               Example
url         Set JMX connection URL    service:jmx:rmi:///jndi/rmi://localhost:8050/jmxrmi

Please find it out in second instance and update to other port.

Here is the document for tomcat 6 regarding jmx remote setting. https://tomcat.apache.org/tomcat-6.0-doc/monitoring.html

If you still can't find the port in which file, please confirm the command you used to grep entire tomcat directory

cd $TOMCAT_HOME
find . -type f -exec grep -l 3000 {} \;

您可以在CATALINA_OPTS中设置-Dcom.sun.management.jmxremote.port =%my.jmx.port%,以更改JMX端口。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM