zoukankan      html  css  js  c++  java
  • tomcat多实例及负载均衡

    [root@localhost ~]# tar fx apache-tomcat-8.5.40.tar.gz
    [root@localhost ~]# tar fx jdk-8u191-linux-x64.tar.gz
    [root@localhost ~]# mv jdk1.8.0_191/ /usr/local/java
    [root@localhost ~]# vim /etc/profile
    JAVA_HOME=/usr/local/java
    PATH=$PATH:$JAVA_HOME/bin
    [root@localhost ~]# source /etc/profile
    [root@localhost ~]# mv apache-tomcat-8.5.40 /usr/local/
    [root@localhost ~]# mkdir -p /usr/local/tomcat_instance/tomcat1
    [root@localhost ~]# mkdir -p /usr/local/tomcat_instance/tomcat2
    [root@localhost ~]# cp -R /usr/local/apache-tomcat-8.5.40/conf/ /usr/local/tomcat_instance/tomcat1
    [root@localhost ~]# cp -R /usr/local/apache-tomcat-8.5.40/conf/ /usr/local/tomcat_instance/tomcat2
    [root@localhost ~]# mkdir /usr/local/tomcat_instance/{tomcat1,tomcat2}/bin
    [root@localhost ~]# touch /usr/local/tomcat_instance/{tomcat1,tomcat2}/bin/startup.sh
    [root@localhost ~]# touch /usr/local/tomcat_instance/{tomcat1,tomcat2}/bin/shutdown.sh
    [root@localhost ~]# chmod +x /usr/local/tomcat_instance/{tomcat1,tomcat2}/bin/startup.sh
    [root@localhost ~]# chmod +x /usr/local/tomcat_instance/{tomcat1,tomcat2}/bin/shutdown.sh
    [root@localhost ~]# vi /usr/local/tomcat_instance/tomcat1/bin/startup.sh
    #/bin/bash
    export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
    export CATALINA_BASE="/usr/local/tomcat_instance/tomcat1"
    export CATALINA_TMPDIR="$CATALINA_BASE/temp"
    export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
    export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat1"
    if [ ! -d "$CATALINA_BASE/logs" ]; then
    mkdir $CATALINA_BASE/logs
    fi
    if [ ! -d "$CATALINA_BASE/temp" ]; then
    mkdir $CATALINA_BASE/temp
    fi
    bash $CATALINA_HOME/bin/startup.sh "$@"
    [root@localhost ~]# vi /usr/local/tomcat_instance/tomcat2/bin/startup.sh
    #/bin/bash
    export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
    export CATALINA_BASE="/usr/local/tomcat_instance/tomcat2"
    export CATALINA_TMPDIR="$CATALINA_BASE/temp"
    export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
    export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat2"
    if [ ! -d "$CATALINA_BASE/logs" ]; then
    mkdir $CATALINA_BASE/logs
    fi
    if [ ! -d "$CATALINA_BASE/temp" ]; then
    mkdir $CATALINA_BASE/temp
    fi
    bash $CATALINA_HOME/bin/startup.sh "$@"
    [root@localhost ~]# vi /usr/local/tomcat_instance/tomcat1/bin/shutdown.sh
    #/bin/bash
    export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
    export CATALINA_BASE="/usr/local/tomcat_instance/tomcat1"
    export CATALINA_TMPDIR="$CATALINA_BASE/temp"
    export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
    bash $CATALINA_HOME/bin/shutdown.sh "$@"
    [root@localhost ~]# vi /usr/local/tomcat_instance/tomcat2/bin/shutdown.sh
    #/bin/bash
    export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
    export CATALINA_BASE="/usr/local/tomcat_instance/tomcat2"
    export CATALINA_TMPDIR="$CATALINA_BASE/temp"
    export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
    bash $CATALINA_HOME/bin/shutdown.sh "$@"
    [root@localhost ~]# vim /usr/local/tomcat_instance/tomcat2/conf/server.xml
    22 <Server port="8006" shutdown="SHUTDOWN">
    69 <Connector port="8090" protocol="HTTP/1.1"
    116 <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
    [root@localhost ~]# mkdir -p /usr/local/tomcat_instance/{tomcat1,tomcat2}/webapps/ROOT
    [root@localhost ~]# vim /usr/local/tomcat_instance/tomcat1/webapps/ROOT/index.jsp
    <html>
    <title>Tomcat-1</title>
    <body>
    Hello This is Tomcat-1
    </body>
    </html>
    [root@localhost ~]# vim /usr/local/tomcat_instance/tomcat2/webapps/ROOT/index.jsp
    <html>
    <title>Tomcat-2</title>
    <body>
    Hello This is Tomcat-2
    </body>
    </html>
    [root@localhost ~]# /usr/local/tomcat_instance/tomcat1/bin/startup.sh
    [root@localhost ~]# /usr/local/tomcat_instance/tomcat2/bin/startup.sh

    192.168.200.111 安装nginx
    [root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
    http {
    upstream tomcat_pool {
    server 192.168.200.112:8080 weight=1 max_fails=1 fail_timeout=10s;
    server 192.168.200.112:8090 weight=1 max_fails=1 fail_timeout=10s;
    }
    location / {
    root html;
    index index.html index.htm;
    proxy_pass http://tomcat_pool;
    proxy_set_header Host $http_host;
    }
    }
    [root@nginx ~]# killall -1 nginx
    访问192.168.200.111进行测试

  • 相关阅读:
    .NetCore 3.1和.NetCore 5.0 中WebApi的请求参数的验证方法
    php 使脚本持续的运行
    Elasticsearch es三种分页方式和对比
    es 大批量写入提高性能的策略
    php 使用多进程批量插入数据
    【转】EM算法MATLAB代码及详细注解
    【转】详解EM算法与混合高斯模型(Gaussian mixture model, GMM)
    【转】高斯混合模型
    【转】二维高斯分布(Two-dimensional Gaussian distribution)的参数分析
    word使用dot模板以spring word 模板为例
  • 原文地址:https://www.cnblogs.com/lyqlyqlyq/p/11641850.html
Copyright © 2011-2022 走看看