In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Main points of content:
I. tomcat virtual host configuration
II. Tomcat optimization
III. Demonstration of examples
I. Tomcat virtual host configuration
1. When a company has multiple projects running at the same time, it is not recommended to run multiple Tomcat services on one server. Virtual hosts need to be configured.
2. Access different project contents through two domain names
3. Steps
1 >. Create www and bbs project directories and files
2. > modify the Tomcat main configuration file
3. > restart the Tomcat service
4. > Test
II. Tomcat optimization
The default configuration of Tomcat is not suitable for the production environment, it will frequently appear fake death phenomenon and need to be rebooted. Only through continuous stress testing and optimization can it run stably and efficiently. There are three main aspects of optimization, including operating system optimization (kernel parameter optimization), Tomcat profile parameter optimization, Java virtual machine (JVM) tuning.
Optimization related parameters commonly used in Tomcat
[maxThreads] Tomcat uses threads to process each request received, and this value represents the maximum number of threads that Tomcat can create. The default value is 200. [minSpareThreads] minimum number of idle threads, the number of threads initialized when Tomcat starts, indicating that there are so many empty threads waiting even if no one is using them. The default value is 10 [maxSpareThreads] the maximum number of standby threads. Once the created threads exceed this value, Tomcat will shut down socket threads that are no longer needed. The default value is-1 (unlimited). Generally, you do not need to specify [URIEncoding] to specify the URL encoding format of the Tomcat container. The language encoding format is not as convenient as other Web server software configuration. You need to specify [connnectionTimeout] network connection timeout respectively, in milliseconds. Setting it to 0 means never timeout. This setting has hidden dangers. Usually, by default, you can [enableLookups] check the domain name in 20000 milliseconds to return the hostname of the remote host. The value is true or false. If set to false, the IP address is returned directly. In order to improve the processing power, it should be set to false. [disableUploadTimeout] whether to use timeout mechanism when uploading. Should be set to true. [connectionUploadTimeout] upload timeout. After all, file upload may take more time. Adjust this according to your own business needs, so that Servlet has a longer time to complete its execution. You need to use it with the previous parameter to take effect. [acceptCount] specify the maximum queue length that can be passed in connection requests when all available threads for processing requests are used. Requests exceeding this number will not be processed. The default is 100. [compression] whether to perform GZIP compression on the response data. Off: disable compression. On: compression is allowed (text will be compressed), force: compression is carried out in all cases. The default value is off. After compressing the data, the page size can be effectively reduced. Generally, the size of the page can be reduced by about 1 compressionMinSize. Saving bandwidth [compressionMinSize] indicates the minimum value of the compression response. The message will be compressed only when the response message size is greater than this value. If the compression function is enabled, the message will be compressed. The default value is the 2048 [compressableMimeType] compression type, which specifies which types of files are compressed. [noCompressionUserAgents= "gozilla, traviata"] for the following browsers, compression is not enabled. If the code has been separated, static pages and images and other data do not need to be processed by Tomcat, then there is no need to configure compression in Tomcat. Because there is only one Tomcat server, and the pressure test is the home page of Tomcat, there will be pictures and static resource files, so compression is enabled here.
III. Demonstration of examples
Step 1: install and configure the domain name resolution service
[root@localhost ~] # yum install bind-y [root@localhost ~] # vim / etc/named.conf listen-on port 53 {any;};... allow-query {any;}; [root@localhost ~] # vim / etc/named.rfc1912.zones zone "kgc.com" IN {type master; file "kgc.com.zone"; allow-update {none;};}; zone "accp.com" IN {type master File "accp.com.zone"; allow-update {none;};}; [root@localhost ~] # cd / var/named/ [root@localhost named] # cp-p named.localhost kgc.com.zone [root@localhost named] # vim kgc.com.zone$TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H; retry 1W; expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.235.158 [root@localhost named] # cp-p kgc.com.zone accp.com.zone# copy kgc file and rename it to accp file without modification [root@localhost named] # systemctl start named# start domain name resolution service [root@localhost named] # systemctl stop firewalld.service [root@localhost named] # setenforce "disable firewall and enhanced security features
Step 2: create kgc and accp project directories and files
[root@localhost named] # mkdir / usr/local/tomcat/webapps/kgc# create kgc site directory [root@localhost named] # echo "This is kgc web" > / usr/local/tomcat/webapps/kgc/index.jsp# Edit kgc homepage [root@localhost named] # mkdir / usr/local/tomcat/webapps/accp [root@localhost named] # echo "This is accp web" > / usr/local/tomcat/webapps/accp/index.jsp
Step 3: modify the Tomcat main configuration file server.xml
[root@localhost named] # vim / usr/local/tomcat/conf/server.xml # define the www.kgc.com virtual host configuration # turn off the xml namespace # specify the classes loaded by path by default and turn on the reloadable monitoring class # Note the tag closing # define the www.accp.com virtual host configuration [root@localhost named] # shutdown.sh # close Using CATALINA_BASE: / usr/local/tomcatUsing CATALINA_HOME: / usr/local/tomcatUsing CATALINA_TMPDIR: / usr/local/tomcat/tempUsing JRE_HOME: / usr/java/jdk1.8.0_201-amd64Using CLASSPATH: / usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar [ Root@localhost named] # startup.sh # Open the Tomcat service Using CATALINA_BASE: / usr/local/tomcatUsing CATALINA_HOME: / usr/local/tomcatUsing CATALINA_TMPDIR: / usr/local/tomcat/tempUsing JRE_HOME: / usr/java/jdk1.8.0_201-amd64Using CLASSPATH: / usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jarTomcat started.
Step 4: browse the test web page
1. Use a browser to access the http://www.kgc.com:8080 page to display This is kgc web
two。 Use a browser to access the http://www.accp.com:8080 page to display This is accp web
Step 5: optimize Tomcat
1. Before optimization, use apache-jmeter to test and compare.
two。 Modify the main configuration file server.xml
[root@localhost ~] # vim / usr/local/tomcat/conf/server.xml # supported compression types
3. The optimized Tomcat after pressure test again
Online pressure testing can be carried out many times and continue to be optimized according to the pressure test results, so that users have a better sense of experience!
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.