Tomcat生产优化

1 建立JNDI;打开$TOMCAT_HOME/conf/context.xml,添加如下

<!--MySQL-->
    <Resource 
           name="jdbc/market" 
           auth="Container" 
           type="javax.sql.DataSource"
           maxActive="100" 
           maxIdle="30" 
           maxWait="10000"
           username="develop" 
           password="xxxxxx" 
           driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://mysql:3306/market"
    />

<!--SQL Server-->

    <Resource 
           name="jdbc/market" 
           auth="Container" 
           type="javax.sql.DataSource"
           maxActive="100" 
           maxIdle="30" 
           maxWait="10000"
           username="sa" 
           password="xxxxxx" 
           driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
           url="jdbc:sqlserver://sqlserver:1433;DatabaseName=market"
    />

2 优化连接数及压缩选项;打开$TOMCAT_HOME/conf/server.xml,替换如下代码:

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8"
               maxThreads="250" maxHttpHeaderSize="8192"
               disableUploadTimeout="true"
               acceptCount="440" emptySessionPath="true"
               enableLookups="false"
               compression="500" compressableMimeType="text/html,text/xml,text/plain,application/octet-stream"/>

3 优化JVM;打开$TOMCAT_HOME/bin/catalina.cmd(catalina.sh),在最上面添加如下

JAVA_OPTS="-Djava.awt.headless=true