1,先配置nginx ,如果80接口被占用,且80 的端口又惹不起,参考:https://www.cnblogs.com/xiaohu1218/p/10267602.html

2,下载redis,并配置。、

3,下载tomcat ,两个tomcat8,两个tomcat9。并修改端口号(如不在同一个电脑,可以不用需改),我是同一个电脑,为了方便,标记如下:

 <h3>tomcatX:</h3>   // X 1,2,3,4

<% HttpSession session = request.getSession(); %>

<%= session.getId() %>

4,修改tomcat中%Home%\conf 中context.xml  ,加入

   <Manager className="tomcat.request.session.redis.SessionManager"
host="localhost"
port=""
database=""
maxInactiveInterval="" />

5,将 这四个jar包,加入到%home%lib中,

. jedis.jar
. commons-pool2.jar
. commons-logging.jar
.tomcat-cluster-redis-session-manager.jar

或者:

. Move the downloaded jars to tomcat/lib directory
* tomcat/lib/ . Add tomcat system property "catalina.base"
* catalina.base="TOMCAT_LOCATION" . Extract downloaded package (tomcat-cluster-redis-session-manager.zip) to configure Redis credentials in redis-data-cache.properties file and move the file to tomcat/conf directory
* tomcat/conf/redis-data-cache.properties . Add the below two lines in tomcat/conf/context.xml
<Valve className="tomcat.request.session.redis.SessionHandlerValve" />
<Manager className="tomcat.request.session.redis.SessionManager" /> . Verify the session expiration time (minutes) in tomcat/conf/web.xml
<session-config>
<session-timeout><session-timeout>
<session-config>
配置redis-data-cache.properties

#-- Redis data-cache configuration

#- redis hosts ex: 
redis.hosts=127.0.0.1:6379

#- redis password (for stand-alone mode)
#redis.password=

#- set true to enable redis cluster mode
redis.cluster.enabled=false

#- redis database (default 0)
redis.database=0

#- redis connection timeout (default 2000)
redis.timeout=2000

6,启动四个tomcat

7,修改niginx中的config/nginx.conf,

加入

    #服务器集群
upstream localhost {
server localhost: weight=;
server localhost: weight=;
server localhost: weight=;
server localhost: weight=;
}
server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
proxy_pass http://localhost;
root html;
index index.html index.htm;
}

8,启动nginx,即可。

nginx+redis+4个tomcat 负载均衡的更多相关文章

  1. Nginx反向代理实现Tomcat负载均衡

    这篇短文主要介绍Tomcat的集群和用Nginx反向代理实现Tomcat负载均衡. 1.首先需要对一些知识点进行扫盲(对自己进行扫盲,囧): 集群(Cluster) 简单来说就是用N台服务器构成一个松 ...

  2. nginx+tomcat负载均衡和session复制

    本文介绍下传统的tomcat负载均衡和session复制. session复制是基于JVM内存的,当然在当今的互联网大数据时代,有更好的替代方案,如将session数据保存在Redis中. 1.安装n ...

  3. nginx多tomcat负载均衡

    目的 先说说我要干什么,如题:使用nginx实现多个tomcat服务器的负载均衡. nginx 大名鼎鼎,相信很多人都听过,以前感觉很厉害,用了之后发现真的很厉害.nginx可以做以下几件事: 反向代 ...

  4. Linux下Nginx+Tomcat负载均衡和动静分离配置要点

    本文使用的Linux发行版:CentOS6.7 下载地址:https://wiki.centos.org/Download 一.安装Nginx 下载源:wget http://nginx.org/pa ...

  5. Nginx+tomcat负载均衡时静态页面报404

    百度到的问题解决BLOG http://os.51cto.com/art/201204/326843.htm nginx+2台tomcat负载均衡,应用程序已部署,单独访问tomcat时,可以访问到所 ...

  6. nginx+tomcat负载均衡

    最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...

  7. Nginx+tomcat负载均衡配置

    Nginx+tomcat是目前主流的java web架构,如何让nginx+tomcat同时工作呢,也可以说如何使用nginx来反向代理tomcat后端均衡呢?直接安装配置如下: 1.JAVA JDK ...

  8. 基于nginx的tomcat负载均衡和集群

    要集群tomcat主要是解决SESSION共享的问题,因此我利用memcached来保存session,多台TOMCAT服务器即可共享SESSION了. 你可以自己写tomcat的扩展来保存SESSI ...

  9. Ubuntu下配置 keepalived+nginx+tomcat 负载均衡

    本文力图阐述在 Ubuntu Server 环境下使用 Keepalived + Nginx + Tomcat 搭建高可用负载均衡环境的操作步骤和简约配置,这里不涉及性能调优.先说一下他们各自扮演的角 ...

随机推荐

  1. 转 JMeter之修改Sampler响应数据的编码格式

    问题:JMeter的sampler响应数据中有中文时,会解析出错. JMeter的Sampler中的响应数据默认的编码格式是:ISO-8859-1.来自文件: jmeter.properties中的语 ...

  2. Gitlab Jenkins WebHook 持续集成配置踩坑记

    Jenkins相关介绍 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. 目的 配置Gitla ...

  3. c# 多线程排队队列实现的源码

    [csharp] view plaincopy using System; using System.Threading; using System.Collections; using System ...

  4. vue 操作数组,原数组怎么不让它改变

    vue中肯定遇到过这个问题,想对数组操作,可是原数组又会改变,怎么办呢,提前copy一份能行吗, todo: [1,2,3,4,5], var arr = this.todo: 这样肯定不行的,那么肯 ...

  5. spring boot学习(1) hello world

    第一节:SpringBoot 简介 主要是简化开发: 1. 创建独立的Spring应用程序 2. 嵌入的Tomcat,无需部署WAR文件 3. 简化Maven配置 4. 自动配置Spring 5. 提 ...

  6. Network Emulator Toolkit (NEWT) 网络限速工具 (手机和电脑方面)

    下载地址: https://blog.mrpol.nl/2010/01/14/network-emulator-toolkit/ 参考博客: http://blog.csdn.net/lluozh20 ...

  7. linux 添加secondary ip

    linux下ip地址除了primary外,还有两种:1. ip alias(子接口)2. secondary ip(辅助ip) 都可在一块物理网卡上添加,alias由ifconfig添加,ifconf ...

  8. 032:基于Consul和MGR的MySQL高可用架构

    目录 一.Consul 1.Consul简介 2.准备环境 3.Consul 安装 4.Consul配置文件 5.Consul 服务检查脚本 6.Consul启动 二.MGR搭建 1.MGR配置 2. ...

  9. php中的释放语句unset和释放函数mysql_free_result()

    首先要强调的一点是unset在php中已经不再是一个函数了,既然不是函数,那么就没有了返回值,所以用的时候不能够用unset的返回值来做判断. 其次,在函数中,unset只能销毁局部变量,并不能销毁全 ...

  10. IIS6.0 IIS7.5应用程序池自动停止的解决方法 搜集整理

    来源:http://www.guchengnet.com/1499.html IIS6.0 IIS7.5应用程序池自动停止的解决方法 搜集整理 发表于2016年12月14日 有2.3个月没有用本地的i ...