nginx+redis+4个tomcat 负载均衡
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 负载均衡的更多相关文章
- Nginx反向代理实现Tomcat负载均衡
这篇短文主要介绍Tomcat的集群和用Nginx反向代理实现Tomcat负载均衡. 1.首先需要对一些知识点进行扫盲(对自己进行扫盲,囧): 集群(Cluster) 简单来说就是用N台服务器构成一个松 ...
- nginx+tomcat负载均衡和session复制
本文介绍下传统的tomcat负载均衡和session复制. session复制是基于JVM内存的,当然在当今的互联网大数据时代,有更好的替代方案,如将session数据保存在Redis中. 1.安装n ...
- nginx多tomcat负载均衡
目的 先说说我要干什么,如题:使用nginx实现多个tomcat服务器的负载均衡. nginx 大名鼎鼎,相信很多人都听过,以前感觉很厉害,用了之后发现真的很厉害.nginx可以做以下几件事: 反向代 ...
- Linux下Nginx+Tomcat负载均衡和动静分离配置要点
本文使用的Linux发行版:CentOS6.7 下载地址:https://wiki.centos.org/Download 一.安装Nginx 下载源:wget http://nginx.org/pa ...
- Nginx+tomcat负载均衡时静态页面报404
百度到的问题解决BLOG http://os.51cto.com/art/201204/326843.htm nginx+2台tomcat负载均衡,应用程序已部署,单独访问tomcat时,可以访问到所 ...
- nginx+tomcat负载均衡
最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...
- Nginx+tomcat负载均衡配置
Nginx+tomcat是目前主流的java web架构,如何让nginx+tomcat同时工作呢,也可以说如何使用nginx来反向代理tomcat后端均衡呢?直接安装配置如下: 1.JAVA JDK ...
- 基于nginx的tomcat负载均衡和集群
要集群tomcat主要是解决SESSION共享的问题,因此我利用memcached来保存session,多台TOMCAT服务器即可共享SESSION了. 你可以自己写tomcat的扩展来保存SESSI ...
- Ubuntu下配置 keepalived+nginx+tomcat 负载均衡
本文力图阐述在 Ubuntu Server 环境下使用 Keepalived + Nginx + Tomcat 搭建高可用负载均衡环境的操作步骤和简约配置,这里不涉及性能调优.先说一下他们各自扮演的角 ...
随机推荐
- Spark的word count
word count package com.spark.app import org.apache.spark.{SparkContext, SparkConf} /** * Created by ...
- 基于ionic框架封装一个图片轮播指令的几点
在这里我想在项目中封装一个图片轮播的指令 (本项目使用的是ionic框架) 1)定义指令 define(['app'],function(myapp){ myapp.directive('myslid ...
- Ajax异步上传多个文件并返回文件路径
前端JSP页面代码 <label>附件:</label><form id="fileForm"> <input type="fi ...
- java 使用POI读写Excel文件(兼容2003、2007)
package com.jadyer.demo; import java.io.File; import java.io.FileOutputStream; import java.io.IOExce ...
- 2018-2019 Exp3 免杀原理与实践
2018-2019 Exp3 免杀原理与实践 目录 一.实验内容说明及基础问题回答 二.实验过程 Task1 1.使用msf编码器生成后门程序及检测 Task1 2.msfvenom生成jar等文件 ...
- Program.cs 累积_C#
using System; using System.Diagnostics; using System.Threading; using System.Windows.Forms; using Ut ...
- Windows下python 安装Mysqldb模块
CMD执行 pip install mysql-python 报错如下: 1.如果报类似 Microsoft Visual C++ 9.0 is required < Unable to fin ...
- [UE4]解析json数据
正常的json对象是可以使用单引号的,但是在UE4中的json解析,不能如下使用单引号: {‘name’:'张三'} 而是要使用双引号写成: {"name":"张三&qu ...
- 在线学习和在线凸优化(online learning and online convex optimization)—FTRL算法6
- 第3章 文件I/O(7)_高级文件操作:存储映射
8. 高级文件操作:存储映射 (1)概念: 存储映射是一个磁盘文件与存储空间的一个缓存相映射,对缓存数据的读写就相应的完成了文件的读写. (2)mmap和munmap函数 头文件 #include&l ...