In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Tomcat virtual host configuration
Sometimes, 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.
Access to different project content through two domain names
Steps:
1. Create www and bbs project directories and files
two。 Modify the Tomcat main configuration file
3. Restart the Tomcat service
4. test
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.
The optimization-related parameter commonly used by Tomcat [maxThreads] Tomcat uses threads to process each request received, which 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 here, and the pressure test is the home page of Tomcat, there will be pictures and static resource files, so the compression experiment is enabled here.
This experiment is carried out when the Tomcat service has been installed. I wrote about the experiment of deploying and installing the Tomcat service in my last blog.
(1) install and configure the domain name resolution service [root@localhost security] # yum install bind-y.amp / omission process [root@localhost security] # vim / etc/named.confoptions {listen-on port 53 {any;}; listen-on-v6 port 53 {:: 1;}; directory "/ var/named" Dump-file "/ var/named/data/cache_dump.db"; statistics-file "/ var/named/data/named_stats.txt"; memstatistics-file "/ var/named/data/named_mem_stats.txt"; recursing-file "/ var/named/data/named.recursing"; secroots-file "/ var/named/data/named.secroots"; allow-query {any;} [root@localhost security] # vim / etc/named.rfc1912.zones zone "abc.com" IN {type master; file "abc.com.zone"; allow-update {none;};} zone "xyz.com" IN {type master; file "xyz.com.zone"; allow-update {none;};} [root@localhost security] # cd / var/named/ [root@localhost named] # cp-p named.localhost abc.com.zone [root@localhost named] # vim abc.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.52.132 [root@localhost named] # cp-p abc.com.zone xyz.com.zone # copy the abc file and rename it to xyz file Without modification [root@localhost named] # lsabc.com.zone data dynamic named.ca named.empty named.localhost named.loopback slaves xyz.com.zone [root@localhost named] # [root@localhost named] # systemctl start named # start the domain name resolution service [root@localhost named] # [root@localhost named] # systemctl stop firewalld.service # turn off the firewall [root@localhost named] # setenforce 0 # turn off enhanced security (2) create abc and xyz Project directory and files [root@localhost named] # cd / usr/local/tomcat/ [root@localhost tomcat] # mkdir / usr/local/tomcat/webapps/abc # create abc site directory [root@localhost tomcat] # echo "This is abc page\!" > / usr/local/tomcat/webapps/abc/index.jsp # Edit abc homepage [root@localhost tomcat] # mkdir / usr/local/tomcat/webapps/xyz # create xyz site directory [root@localhost tomcat] # echo "This is xyz page\!" > / usr/local/tomcat/webapps/xyz/index.jsp # Edit xyz homepage [root@localhost tomcat] # (3) modify Tomcat main configuration file server.xml [root@localhost tomcat] # vim / usr/local/tomcat/conf/server.xml # define www.abc.com virtual host configuration # define www.xyz.com virtual host configuration [root@localhost tomcat] # / usr/local/tomcat/bin/shutdown.sh # disable the 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 .jar [root@localhost tomcat] # / usr/local/tomcat/bin/startup.sh # enable the 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. [root@localhost tomcat] # name= "www.kgc.com" # define virtual hostname appBase= "/ usr/local/tomcat/webapps" # specify site file path unpackWARs= "true" # Open update of war package autoDeploy= "true" # enable automatic deployment of xmlValidation= "false" # turn off xml verify xmlNamespaceAware= "false" # close xml namespace docBase= "/ usr/local/tomcat/webapps/kgc" # specify the web site path path= "" reloadable= "true" # specify the classes loaded by path by default and open the reloadable monitoring class (4) browse the test web page
1. Use a browser to access the http://www.abc.com:8080 page to display This is abc page
two。 Use a browser to access the http://www.xyz.com:8080 page to display This is xyz page
(5) optimize Tomcat
1. Use apache-jmeter to pressure test before optimization.
two。 Modify the main configuration file server.xml
[root@localhost tomcat] # vim / usr/local/tomcat/conf/server.xml # supported compression type [root@localhost tomcat] # shutdown.sh # disable 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.jar [root@localhost tomcat] # startup.sh # enable the 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. [root@localhost tomcat] #
3. The optimized Tomcat after pressure test again
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.