Tomcat访问量大的情况下, 经常出现问题,调用别人接口很慢时,tomcat会一直堆积,因为没有配置maxThreads=“3000”,默认只有200,线程数配置的太小。
所以导致这tomcat经常告警,出问题。
浏览器访问:
http://192.168.0.30:8080/manager
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" maxThreads="3000" acceptCount="1000" />
maxThreads:tomcat起动的最大线程数,即同时处理的任务个数,默认值为200
acceptCount:当tomcat起动的线程数达到最大时,接受排队的请求个数,默认值为100
修改文件 bin/catalina.sh
CATALINA_OPTS="-Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=192.168.0.30 -Dcom.sun.management.jmxremote.port=18888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="-Xms4096m -Xmx4096m" ####配置4G内存
cygwin=false
darwin=false
os400=false
ps aux|grep tomcat
/userdata/java8/bin/java -Djava.util.logging.config.file=/userdata/apache-tomcat-8.0.5/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms4096m -Xmx4096m -Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=192.168.0.30 -Dcom.sun.management.jmxremote.port=18888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.endorsed.dirs=/userdata/apache-tomcat-8.0.5/endorsed -classpath /userdata/apache-tomcat-8.0.5/bin/bootstrap.jar:/userdata/apache-tomcat-8.0.5/bin/tomcat-juli.jar -Dcatalina.base=/userdata/apache-tomcat-8.0.5 -Dcatalina.home=/userdata/apache-tomcat-8.0.5 -Djava.io.tmpdir=/userdata/apache-tomcat-8.0.5/temp org.apache.catalina.startup.Bootstrap start
bin/catalina.sh
CATALINA_OPTS="-Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=192.168.0.209 -Dcom.sun.management.jmxremote.port=18888 -Dcom.sun.management.jmxremote.rmi.port=18888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=/userdata/apache-tomcat-8.0.5/bin/jmxremote.access -Dcom.sun.management.jmxremote.password.file=/userdata/apache-tomcat-8.0.5/bin/jmxremote.password"
JAVA_OPTS="-Xms4096m -Xmx4096m"
cygwin=false
darwin=false
os400=false
或
bin/catalina.sh
CATALINA_OPTS="-Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=52.76.173.129 -Dcom.sun.management.jmxremote.port=18888 -Dcom.sun.management.jmxremote.rmi.port=18888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
jmx获取tomcat监控信息 需要配置下面这句, 参考链接:
http://blog.csdn.net/cenfei78325747/article/details/8443254
http://www.cnblogs.com/likehua/p/4087320.html
http://blog.arganzheng.me/posts/tomcat-monitor.html
http://blog.vfocus.net/archives/000470.html
https://blog.linuxeye.com/262.html
注意这个配置,不然远程的jconsole连接不上, 因为每次启动tomcat端口会随机生成,这个是固定端口
-Dcom.sun.management.jmxremote.rmi.port=18888
java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: ip-192-168-0-59.ap-southeast-1.compute.internal: ip-192-168-0-59.ap-southeast-1.compute.internal: unknown error
增加内网 外网 192.168.0.16 ip-192-168-0-59.ap-southeast-1.compute.internal 到hosts
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.16 ip-192-168-0-59.ap-southeast-1.compute.internal
192.168.0.16 ip-192-168-0-16
iptables -L -n
netstat -tpnl
netstat -lntp |grep java
vim /etc/sysconfig/iptables
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 80,443,18888 -j ACCEPT
service iptables restart
需要配置下面这句, 参加链接
http://blog.csdn.net/cenfei78325747/article/details/8443254
http://elf8848.iteye.com/blog/471676
http://lib.csdn.net/article/linux/32843
http://blog.csdn.net/jz20110918/article/details/44059997
http://www.cnblogs.com/likehua/p/4087320.html
http://www.cnblogs.com/yezhaohui/p/3875567.html
/software/jdk1.8.0_11/bin$ ./jconsole 或 ./jvisualvm
远程进程 连接
192.168.0.16:18888
52.71.73.129:18888
hostname=192.168.0.16配置内网ip时,v-p-n连接时,内网外网都能连接上,程序jmx也能连接上。当断开v-p-n时,都连接不上
hostname=52.71.73.129配置外网ip时,v-p-n连接时,内网外网都能连接上,程序jmx也能连接上。当断开v-p-n时,内网连接不上, 外网和jmx程序能连接上
http://it.nfsq.com.cn/index.php/2016/04/17/linux-tomcat8-jmx-monitor/
https://my.oschina.net/manmao/blog/637930
http://www.ibm.com/support/knowledgecenter/zh/SS2L6K_6.0.0/com.ibm.jazz.repository.web.admin.doc/topics/t_server_mon_tomcat_option2.html
cd /userdata/apache-tomcat-8.0.21/bin/
cp /userdata/jre1.8.0_45/lib/management/jmxremote.password.template jmxremote.password
cp /userdata/jre1.8.0_45/lib/management/jmxremote.access jmxremote.access
chmod 600 jmxremote.access jmxremote.password
vim jmxremote.password
monitorRole autoTestTomcat
controlRole autoTestTomcat
vim catalina.sh
CATALINA_OPTS="-Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=52.71.73.129 -Dcom.sun.management.jmxremote.port=18888 -Dcom.sun.management.jmxremote.rmi.port=18888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=jmxremote.access -Dcom.sun.management.jmxremote.password.file=jmxremote.password"
tomcat manager密码配置
http://chat.xxx.im/manager
username="liang" password="liang_123456"
conf/tomcat-users.xml
其他的tomcat后台管理用户密码是一样的
tomcat-users.xml
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="liang" password="liang_123456" roles="manager-script,admin,manager,manager-gui"/>
</tomcat-users> 它前面