In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
With regard to tomcat monitoring on linux systems, many platforms only judge that the service is normal, ignoring the situation of tcp links (zabbix-agentd about tcp connection monitoring should be defined in the monitoring item), whether the tomcat parent process is dead, if there is no monitoring check mechanism, in many application servers, using cluster load, there is still a tomcat thread accumulation, resulting in service deadlock, resulting in an increasing number of sockets that cannot be released. But the service is still there, if you use zabbix monitoring, use ready-made module jmx monitoring.
Tomcat monitoring item
1. The application port of tomcat (such as 8080) is limited.
2. Jmx monitoring of tomcat is the performance monitoring of tomcat. Heap memory size, thread peak
3. Tomcat can write a static file curl-I URL, and it is normal to get the http return code of the header.
# the method is below #
-JMX monitoring tomcat-
Install the jdk and tomcat environment on the monitored side of tomcat, and then the catalina.sh file in the bin directory of the installation directory of tomcat
# user authentication is required
#-Execute The Requested Command-"
Insert a new line before (there is no line break in the middle)
CATALINA_OPTS= "$CATALINA_OPTS-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=true
-Djava.rmi.server.hostname=192.168.182.5 "
=
Matters needing attention
The IP address in 1mai Djava.rmi.server.hostnamekeeper 192.168.182.5 should be written into the local configuration IP, or it can be configured as 0.0.0.0, otherwise the listening may not start normally.
Using JConsole to monitor local applications is very effective in developing and prototyping, but the user production environment is not recommended because the JConsole province also consumes a lot of system resources
2. Do not repeat the ports of each tomcat. For example, there are multiple tomcat instances on an ip, and each instance has one port.
=
Before restarting the tomcat service, you must ensure that there is a mapping between ip and hostname in the hosts.
Authenticate users and configure user permissions under the installation directory of jdk
Edit jmxremote.access and jmxremote.password in the jdk installation directory
Which java
Cd / usr/local/jdk/jre/lib/management
Cp jmxremote.password.template jmxremote.password
Chmod 600 jmxremote.access jmxremote.password
Cp jmxremote.password.template jmxremote.password / opt/tomcat/tomcat1/conf/
Cd / opt/tomcat/tomcat1/conf/
Chmod 600 jmxremote.access jmxremote.password
Vi jmxremote.password-both jdk and tomcat jmxremote.password have been modified
In the jmxremote.password file, uncomment or add your own user name and password
MonitorRole QED
ControlRole rotated D
Uncomment on jmxremote.access
MonitorRole readonly
ControlRole readwrite\
Create javax.management.monitor.*,javax.management.timer.*\
Unregister
Restart the tomcat service
You can use the netstat-an | grep 9999 command to see if the port starts properly. You can see the network connection on port 9999
Start configuring the terminal and get the native windows client ip,linux machine to execute export DISPLAY=10.35.40.26:0.0 (this is my windowsIP. I will open the graphical interface later. If the linux machine is a native virtual machine, then IP should write the gateway 192.168.182.1 of LINUX's IP).
Open Xmanager-Passive
[root@db1 bin] #. / jconsole
Enter 192.168.182.5R 9999 monitorRole QED to enter
OK
# talking about tomcat Optimization and time-out #
[tomcat]
Start the environment variable of the user where the club is located
TIME_WAIT related sysctl parameters and timeout
[root@lvs ~] # sysctl-a | grep tw
Net.ipv4.tcp_max_tw_buckets / / the maximum number of socket in the TIME_WAIT state
Net.ipv4.tcp_tw_recycle = 1 / / turn on the TIME_WAIT fast recovery mechanism
Net.ipv4.tcp_tw_reuse / / TIME_WAIT stateful socket reuse
Sysctl-w net.ipv4.tcp_tw_len = 2 sets TIME_WAIT to time out after 2 seconds
The default TIME_WAIT timeout is 60 seconds, which cannot be adjusted through sysctl.
If specified by tomcat itself: vi bin/setclasspath.sh
JAVA_HOME=/mall/jdk/jdk1.7.0_80
JRE_HOME=/mall/jdk/jdk1.7.0_80/jre
For the sake of httpsession security, prevent client script from reading session cookie content such as CSRF/XSS malicious http***, can be found in the tomcat6
Conf/context.xml configuration file is configured to add HttpOnly attributes for custom cookie and attributes, and "httponly" can be added when the set-Cookie header information is set.
Tomcat accesses url without adding project name, but directly IP+port
Tomcat monitors the application port of 1 and tomcat (such as 8080), which is quite limited.
2. The jmx monitoring of tomcat is the performance monitoring of tomcat and the operation of tomcat.
3. Tomcat can write a static file curl-I URL, and it is normal to get the http return code of the header.
-
This configuration file is server.xml of tomcat7 about thread pool
The maximum possible number of threads for Tomcat is the parameter maxConnections and the number of concurrency.
The maximum number of threads that can be raised in the maxThreads:Tomcat thread pool; the number of threads is pool, which is used to handle the number of connections
Requests (connections) that can be processed concurrently by maxConnections:Tomcat
KeepAliveTimeout: the maximum retention time of a persistent connection (in milliseconds), indicating how long Tomcat will keep the connection before the next request comes. The default is to use connectionTimeout time, and-1 is an unlimited timeout.
Thread dump, in fact, very few threads are in the RUNNABLE state, and most of the threads are in the TIMED_WAITING state.
Netstat-nat | grep 8098 | grep TIME_WAIT | wc-l 2980
Netstat-nat | grep 8098 | wc-l 3000 people are beginning to wonder why threads have risen to 3000, and have found that the number of threads does not fall even after the peak.
The first thing that comes to mind is that the processing of back-end applications is instantly slow and "blocked" leads to an increase in the number of front-end threads. However, after the launch of an optimized version, it is found that although the increase has improved, the thread pool will eventually reach the maximum value of 3000.
Let me tell you directly what I have come to know so far:
1. First of all, why doesn't the thread be released?
Briefly describe the working mechanism of the Tomcat (7.0.54) thread pool that I verified.
If there is no request when Tomcat starts, the number of threads (which all refer to the thread pool) is 0. Once there is a request, Tomcat initializes the number of threads set by minSapreThreads.
Tomcat will not actively shrink the thread pool, and Tomcat will not shrink the thread pool to the size set by minSpareThreads unless it is certain that there are no requests.
Previous versions of Tomcat6 had a maxSpareThreads parameter, but it was removed in 7, so Tomcat will not release more than idle threads as long as there is only one request before. As for why Tomcat removes the maxSpareThreads parameter, I think it is also due to performance considerations. The performance of constantly shrinking thread pool is certainly not high, and the advantage of extra threads waiting is that they can be processed as soon as a new request comes.
And a large number of Tomcat threads waiting will not consume CPU, but will consume some JVM storage. Further verification found that this is only true when using Keep-Alive (supported by both the client and the server), and if the client does not use Keep-Alive, then the thread will be reclaimed as the TCP connection is released.
Note: according to what I said earlier, only at that moment of concurrency, Tomcat will start 800 threads to process requests, but when it is stable, only a few threads may be in RUNNABLE state, and most of them are TIMED_WAITING, if your application processing time is fast enough.
So the maximum number of threads that can be reached by Tomcat is the parameter maxConnections and the number of concurrency. When the number of concurrency exceeds this parameter, the request will be queued, and the speed of response depends on the performance of your program.
Tomcat stops threads that have been idle for a long time. Tomcat also has a parameter called maxIdleTime: in fact, you can see from the interpretation of this parameter that Tomcat will stop threads that have been idle for more than a certain period of time, which is maxIdleTime
Add virtual memory
JAVA_OPTS= "- server-Xms2048m-Xmx4086m-XX:PermSize=256M-XX:MaxNewSize=512m-XX:MaxPermSize=512m-Djava.awt.headless=true"
Xms:jvm initializes heap size
Xmx: the maximum java heap size, if exceeded, will cause memory overflow
CATALINA_OPTS= "
-server
-Xms6000M jvm initializes the heap size
-Xmx6000M maximum java heap size. Memory overflow occurs if the heap size is exceeded.
-Xss512k represents the stack size of each Java thread. After JDK 5.0, the stack size of each thread is 1m, compared with 256m before.
-XX:NewSize=2250M sets the memory size of the new generation.
-XX:MaxNewSize=2250M sets the maximum Cenozoic memory size
-XX:PermSize=128M sets persistent memory size
-XX:MaxPermSize=256M sets the maximum persistent generation memory size. Permanent generation does not belong to heap memory. Heap memory only contains the new generation and the old generation.
-XX:+AggressiveOpts
-XX:+UseBiasedLocking
-XX:+DisableExplicitGC
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:MaxTenuringThreshold=31
-XX:+CMSParallelRemarkEnabled
-XX:+UseCMSCompactAtFullCollection
-XX:LargePageSizeInBytes=128m
-XX:+UseFastAccessorMethods
-XX:+UseCMSInitiatingOccupancyOnly
-Duser.timezone=Asia/Shanghai
-Djava.awt.headless=true "
Second, the current network zabbix uses jvm tools to monitor tomcat performance.
1. Install Zabbix-Java-gateway (ignore)
2. Add parameters to the tomcat startup script and enable JMX (ignore)
3. Zabbix New Monitoring item-trigger-Graph
Graphical:
Monitoring item definition, tomcat performance monitoring item:
Heap memory used, committed (complementary to system tcp monitoring), total active threads, peak
Refer to the blog http://www.cnblogs.com/Eivll0m/p/5446311.html
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.