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. python3 获取int最大值

    python2 中获取int最大值 import sys i = sys.maxint print i 但是在python3中,报错: AttributeError: module 'sys' has ...

  2. selenium常用获取元素点

    //通过id WebElement element = driver.findElement(By.id("coolestWidgetEvah")); //通过className ...

  3. angularJS自定义服务的几种方式

    在angularJS中定义服务共有四种常见的方式:factory,service,provider,constant,value 使用形式的不同: 1)factory以返回对象的形式定义服务: mya ...

  4. Cenots7对lvm逻辑卷分区大小的调整

    Cenots7对lvm逻辑卷分区大小的调整 (针对xfs和ext4不同文件系统) 1.支持的文件系统类型 特别注意的是: resize2fs命令            针对的是ext2.ext3.ex ...

  5. java 字符串String

    在 Java 中,字符串被作为 String 类型的对象处理. String 类位于 java.lang 包中.默认情况下,该包被自动导入所有的程序. 创建 String 对象的方法: 只要是双引号标 ...

  6. 上Google Adsense个人的一点体验

    最近我想开通一个Google Adsense帐号,因为以前注册过一个Google帐号,所以我以为两个是可以共通的,因为很久没上Google帐号,我记不太清密码了,所以我先是登录了Google,登上去了 ...

  7. MongoDB整库备份+整库导入

    备份前检查: [root@Load29 tmp]# mongo localhost: MongoDB shell version: connecting to: localhost:/test Ser ...

  8. 1058 A+B in Hogwarts (20 分)

    1058 A+B in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic has ...

  9. Jquery_artDialog对话框弹出

    artDialog是一个基于javascript编写的对话框组件,它拥有精致的界面与友好的接口l  自适应内容artDialog的特殊UI框架能够适应内容变化,甚至连外部程序动态插入的内容它仍然能自适 ...

  10. PLSQL导出表结构

    1:进行plsql后选怎Tools--------->Exports User Ojbects------------->选中需要导出的table,squence,view,type,fu ...