Steps to exclude Tom from the wrong cat
Ps-ef | grep java or JPS–LVM view Java PID process
Netstat–lntup | grep Java to see if Java port is booting
View the Tomcat log tailf/application/tomcat/logs/catalina.out
show-busy-java-threads.sh Print System The top five Java process to see that the process is taking up high memory.
Tomcat Java remote monitoring download JKDhttp://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Find Jconsole.exe under the C:\Program files\java\jdk1.8.0_31\bin.
Turn on the Tomcat remote monitoring feature
- Vim/application/tomcat8_1/bin/catalina.sh +97
- catalina_opts= "$CATALINA _opts
- -dcom.sun.management.jmxremote
- -dcom.sun.management.jmxremote.port=12345
- -dcom.sun.management.jmxremote.authenticate=false
- -dcom.sun.management.jmxremote.ssl=false
- -djava.rmi.server.hostname=10.0.0.17 "
Do an analysis or an error
- Need to do a resolution echo "10.0.0.17 web03" >>/etc/hosts
Restart Tom Cat View Port
- /application/tomcat8_1/bin/shutdown.sh
- /application/tomcat8_1/bin/startup.sh
- Netstat-tunlp|grep 12345
- TCP6 0 0::: 12345:::* LISTEN 24388/java
Connect with Jconsole
Port 12345
JVISUALVM Remote Link
Right-click Add Host
Right-click to add JVM
Zabbix monitoring Tomcatzabbix need to turn on Java monitoring
Modifying the Zabbix-server configuration file
- Sed-i-E ' 220a javagateway=127.0.0.1 '-e ' 236a startjavapollers=5 '/etc/zabbix/zabbix_server.conf
javagateway=127.0.0.1 gateway address (native IP address)
startjavapollers=5 Java Threads
Installing Zabbix_java_gateway on the service side
Need to install JDK (OPENJDK)
Yum Installation Automatic Installation
Start Zabbix_java_gateway
- Systemctl Start Zabbix-java-gateway.service
- Netstat-tunlp|grep Java
Tomcat enables remote monitoring (every strength)
New Key Host
Search JMX Add two default template
JMX is connected.
Tomcat security optimized down right start
Kill the Java process first
[Email protected] ~]# Pkill java
[Email protected] ~]# Pkill java
- [[email protected] ~]# useradd Tomcat create a new user
- [[email protected] ~]# cp-a/application/tools/tomcat8_1/home/tomcat/Copy the test file to the home directory
- [[email protected] ~]# chown-r tomcat.tomcat/home/tomcat/tomcat8_1/to file permissions
- [[email protected] ~]# su-c '/home/tomcat/tomcat8_1/bin/startup.sh ' Tomcat launched with Tomcat user
- Using catalina_base:/home/tomcat/tomcat8_1
- Using Catalina_home:/home/tomcat/tomcat8_1
- Using Catalina_tmpdir:/home/tomcat/tomcat8_1/temp
- Using Jre_home:/APPLICATION/JDK
- Using CLASSPATH:/home/tomcat/tomcat8_1/bin/bootstrap.jar:/home/tomcat/tomcat8_1/bin/tomcat-juli.jar
- Tomcat started.
- [[email protected] ~]# Ps-ef|grep Tomcat view Tomcat process user
Other security optimizations are in http://www.cnblogs.com/jksbaduen/p/7903539.html
Tomcat optimization
The best policy: Java code optimization
Policy: JVM optimization mechanism garbage collection mechanism, the unnecessary memory recycling.
Optimizing jvm-is optimizing garbage collection mechanism
The worst: Buy buy buy Add memory
The worst: Restart Tomcat at timed intervals
Simple JVM Optimizations
1G Memory optimization
Memory to tomcat around 75% or 3/4
To modify a core configuration file
- Vim/home/tomcat/tomcat8_1/bin/catalina.sh +97
Insert the following code
Java_opts= "-DJAVA.AWT.HEADLESS=TRUE?-DFILE.ENCODING=UTF-8?-SERVER?-XMS800M?-XMX800M?-XX:NEWSIZE=400M?-XX: maxnewsize=400m?-xx:permsize=400m?-xx:maxpermsize=400m "
- Server: Be sure to act as the first parameter in multiple CPU good performance when
- -xms : initial heap Memory Heap size, minimum memory used , the CPU This value should be larger when performance is high
- -xmx : initial heap Memory Heap maximum value, maximum memory used
- the above two values are assigned JVM minimum and maximum memory, depending on the size of the hardware physical memory, is recommended to be set to half of physical memory.
- -xx:permsize: setting a permanent storage area for memory
- -xx:maxpermsize: set a permanent storage area for maximum memory
- -xx:maxnewsize:
- -xss 15120 This makes the jboss Each additional thread ( thread) immediately. 15m memory, and the best value should be 128k, 512k.
- +xx:aggressiveheap Xms JVM ignore xmx , g physical memory , eat one more g swap
- -XSS : Each thread's Stack size
- -VERBOSE:GC Real garbage Collection information
- -xloggc:gc.log Specify garbage collection log files
- -xmn : Young Generation of the Heap size, generally set to Xmx of the 3 , 4 part of
- -XX:+USEPARNEWGC : Shorten Minor Time of collection
- -XX:+USECONCMARKSWEEPGC : Shorten Major Time of collection
Restart Service
- Su-c '/home/tomcat/tomcat8_1/bin/shutdown.sh ' tomcat
- Su-c '/home/tomcat/tomcat8_1/bin/startup.sh ' tomcat
Tomcat Java Zabbix Monitoring