• Nginx实现HTTP及TCP负载均衡


    这种通过一台apache的服务器把客户请求分别传递给两台tomcat叫负载均衡 

    ========================================= ========================

    材料:准备两台Tomcat主机

    第一台tomcat主机配置:IP为192.168.200.130

    [root@localhost ~]# mkdir -pv /web/webapp
    mkdir: 已创建目录 "/web"
    mkdir: 已创建目录 "/web/webapp"
    [root@localhost ~]# vim /web/webapp/index.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
    <head>
    <title>JSP test page</title>
    </head>
    <body>
    <% out.println("Welcome to test site,http://www.test.com");%>
    </body>
    </html>

    [root@localhost ~]# cd /usr/local/tomcat8/conf/

    [root@localhost conf]# cp server.xml server.xml.bak                           //备份一份主配置文件
    [root@localhost conf]# vim server.xml

    在150行左右的Host下添加Context文件
     <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="true">
            <Context docBase="/web/webapp" path="" reloadable="flase">
           </Context>

    [root@localhost conf]# /usr/local/tomcat8/bin/startup.sh
    Using CATALINA_BASE: /usr/local/tomcat8
    Using CATALINA_HOME: /usr/local/tomcat8
    Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
    Using JRE_HOME: /usr/local/java
    Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
    Tomcat started.
    [root@localhost conf]# netstat -anpt | grep :8080
    tcp6 0 0 :::8080 :::* LISTEN 61263/java
    [root@localhost conf]# systemctl stop firewalld
    [root@localhost conf]# iptables -F
    [root@localhost conf]# setenforce 0

    测试:

    第二台Tomcat主机配置:IP为192.168.200.122

    [root@localhost ~]# mkdir -pv /web/webapp1
    mkdir: 已创建目录 "/web"
    mkdir: 已创建目录 "/web/webapp1"
    [root@localhost ~]# vim /web/webapp1/index.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
    <head>
    <title>JSP test page</title>
    </head>
    <body>
    <% out.println("Welcome to test site,http://www.test1.com");%>
    </body>
    </html>

    [root@localhost ~]# cd /usr/local/tomcat8/conf/

    [root@localhost conf]# cp server.xml server.xml.bak                           //备份一份主配置文件
    [root@localhost conf]# vim server.xml

    在150行左右的Host下添加Context文件
     <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="true">
            <Context docBase="/web/webapp1" path="" reloadable="flase">
           </Context>

    [root@localhost conf]# /usr/local/tomcat8/bin/startup.sh 
    Using CATALINA_BASE: /usr/local/tomcat8
    Using CATALINA_HOME: /usr/local/tomcat8
    Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
    Using JRE_HOME: /usr/local/java
    Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
    Tomcat started.
    [root@localhost conf]# netstat -anpt | grep :8080
    tcp6 0 0 :::8080 :::* LISTEN 61263/java 
    [root@localhost conf]# systemctl stop firewalld
    [root@localhost conf]# iptables -F
    [root@localhost conf]# setenforce 0

    测试:

  • 相关阅读:
    类似小红书标签效果(补间动画)
    Android学习之volley
    Android学习之xUtils --- HttpUtils模块
    Android学习之初识xUtils
    Android复习随笔之SharedPreferences
    Android学习随笔之UI美化(二)--------- shape的使用
    Android学习随笔之UI美化(一)--------- 样式和主题
    Eclipse 启动时弹出无法创建Java虚拟机窗口,解决办法
    Android学习随笔之百度地图(一)
    武汉欧凯德信息科技有限公司
  • 原文地址:https://www.cnblogs.com/CMX_Shmily/p/11587302.html
Copyright © 2020-2023  润新知