zoukankan      html  css  js  c++  java
  • centos服务器搭建-Tomcat 8.0.39

    cd   /home

    rm    -rf   apache-tomcat-8.0.39.tar.gz

    mkdir    /usr/local/tomcat

    wget   archive.apache.org/dist/tomcat/tomcat-8/v8.0.39/bin/apache-tomcat-8.0.39.tar.gz

    tar    -zxvf   apache-tomcat-8.0.39.tar.gz   -C   /usr/local/

    ln   -s   /usr/local/apache-tomcat-8.0.39/   /usr/local/tomcat

    tomcat内存优化,tomcatinsetclasspath.sh

    这下面的 JAVA_HOME环境,若在安装JDK时配置了,可以省略。

    PermSize=64M-XX:MaxPermSize=128m在TOMCAT8中开始去除了。

    vim/usr/local/tomcat/bin/setclasspath.sh

    export JAVA_HOME="/usr/local/jdk"

    export JAVA_OPTS=" -Xms512m-Xmx1024m -Dfile.encoding=UTF-8   -Duser.timezone=Asia/Shanghai"

     

    tomcat线程优化,tomcatconfserver.xml 

    命令:sed -i's/redirectPort="8443"/redirectPort="8443" maxThreads="2000" minSpareThreads="100" maxSpareThreads="1000" acceptCount="1000"/'//usr/local/tomcat/conf/server.xml

    下面手动个性

    <Connectoraddress="127.0.0.1" port="8080" protocol="HTTP/1.1"      connectionTimeout="20000"     

     maxThreads="2000"minSpareThreads="100" maxSpareThreads="1000" acceptCount="1000"   redirectPort="8443" />

    如果使用apache和tomcat做集群的负载均衡,并且使用ajp协议做apache和tomcat的协议转发

    <Connector port="8009" protocol="AJP/1.3"      connectionTimeout="20000"

    maxThreads="2000"minSpareThreads="100" maxSpareThreads="1000" acceptCount="1000" redirectPort="8443" />

    由于tomcat有多个connector,所以tomcat线程的配置,又支持多个connector共享一个线程池。

    <Executor name="tomcatThreadPool"namePrefix="catalina-exec-" maxThreads="500"minSpareThreads="20" maxIdleTime="60000" />

    最大线程500(一般服务器足以),最小空闲线程数20,线程最大空闲时间60秒。

    然后,修改<Connector ...>节点,增加executor属性,executor设置为线程池的名字:

    <Connector executor="tomcatThreadPool"port="80" protocol="HTTP/1.1"  connectionTimeout="60000" keepAliveTimeout="15000"maxKeepAliveRequests="1" redirectPort="443" />

    可以多个connector公用1个线程池,所以ajp connector也同样可以设置使用tomcatThreadPool线程池。

    /etc/init.d 是 /etc/rc.d/init.d的软链接(soft link)

    添加/etc/init.d/tomcat

    vim  /etc/init.d/tomcat

    内容附文件

    chmod    755  /etc/init.d/tomcat

    servicetomcat start[stop/restart]

     

    wget   http://localhost:8080       //验证安装成功否

    tail  -f  /usr/local/tomcat/logs/catalina.out

     

    解决多个实例多个Tomcat启动、停止端口冲突问题

    如果需要启动多个tomcat,则需要修改server.xml文件如:

    <Serverport="8005" shutdown="SHUTDOWN">   ----> 

    <Serverport="8195"shutdown="SHUTDOWN">

    <Connectorport="8080" protocol="HTTP/1.1" connectionTimeout="20000"redirectPort="8443" />   ---->   

    <Connectorport="8091"protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25"maxSpareThreads="75" enableLookups="false"redirectPort="8443" acceptCount="100" debug="0"connectionTimeout="20000" disableUploadTimeout="true" />

    <Connectorport="8009" protocol="AJP/1.3" redirectPort="8443" />    ---->   

    <Connectorport="8199"protocol="AJP/1.3" redirectPort="8443" />

    <Host name="localhost"  appBase="webapps"unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false">    ---->   

    <Host name="10.10.3.54" appBase="/home/defaut"unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false" >

    或者虚拟目录

    <Host>

    <Contextpath="" docBase="/var/wwwroot"reloadable="true">

    </Host>

    或者

    <Hostname="localhost" appBase="/home/default"  unpackWARs="true"autoDeploy="true">

            <!-- SingleSignOn valve, shareauthentication between web applications

                 Documentation at:/docs/config/valve.html -->

            <!--

            <ValveclassName="org.apache.catalina.authenticator.SingleSignOn" />

            -->

            <!-- Access log processes allexample.

                 Documentation at:/docs/config/valve.html

                 Note: The pattern used isequivalent to using pattern="common" -->

            <ValveclassName="org.apache.catalina.valves.AccessLogValve"directory="logs"

                  prefix="localhost_access_log." suffix=".txt"

                   pattern="%h %l %u %t&quot;%r&quot; %s %b" />

     </Host>

    布署文件拷贝到/home/tomcat/

  • 相关阅读:
    [Java多线程]-并发,并行,synchonrized同步的用法
    [大数据可视化]-saiku的源码打包运行/二次开发构建
    [大数据可视化]-saiku的源码包Bulid常见问题和jar包
    [Java多线程]-线程池的基本使用和部分源码解析(创建,执行原理)
    [机器学习]-PCA数据降维:从代码到原理的深入解析
    [Java多线程]-Thread和Runable源码解析之基本方法的运用实例
    [Java多线程]-学习多线程需要来了解哪些东西?(concurrent并发包的数据结构和线程池,Locks锁,Atomic原子类)
    [Java多线程]-Thread和Runable源码解析
    [机器学习]-Adaboost提升算法从原理到实践
    月是故乡明
  • 原文地址:https://www.cnblogs.com/ncepu/p/13695096.html
Copyright © 2011-2022 走看看