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 搭建高可用负载均衡环境的操作步骤和简约配置,这里不涉及性能调优.先说一下他们各自扮演的角 ...
随机推荐
- django模板里关闭特殊字符转换,在前端以html语法渲染
变量 pagination_html是一个方法返回的html代码,需要在前端渲染出来,不是当字符串显示 <!-- /.box-body --> {% autoescape off %} { ...
- angularjs 本地数据存储LocalStorage
1.定义服务 //=========本地存储数据服务============ app.factory('locals', ['$window', function ($window) { return ...
- svn 提交代码 自动过滤技巧,自动过滤不想提交的文件和文件夹
原文:http://www.cnblogs.com/codealone/p/3208620.html 打开SVN客户端-----常规设置------全局忽略样式,添加 bin obj debug Re ...
- BASIC-24_蓝桥杯_龟兔赛跑预测
示例代码: #include <stdio.h> int main(void){ int t1 = 0 , t2 = 0 , l1 = 0 , l2 = 0 ; int v1 = 0 , ...
- BASIC-9_蓝桥杯_特殊回文数
示例代码: #include <stdio.h> int main(void){ int n = 0 ; scanf("%d",&n); int i = 0 ; ...
- 利用spring的ApplicationListener实现springmvc容器的初始化加载--转
1.我们在使用springmvc进行配置的时候一般初始化都是在web.xml里面进行的,但是自己在使用的时候经常会测试一些数据,这样就只有加载spring-mvc.xml的配置文件来实现.为了更方便的 ...
- 实验三:C分支结构程序设计
3.1 #include<stdio.h> int main(){ char a; scanf("%c",&a); if(a>=65&&a ...
- AppScan代理扫描app/H5安全测试(没试过,记录在此)
标签: 1.首先设置AppScan代理,设置如下:
- press_keycode API 参数查询
用法 driver.press_ keycode(‘4’) 参数查找url:https://www.cnblogs.com/larack/p/4223465.html
- SpringMVC的注解方式配置
SpringMVC支持使用注解方式配置,比配置文件方式更加灵活易用,是SpringMVC使用的主流模式. 1.在配置文件中开启SpringMVC的注解 <!-- 开启包扫描 --> < ...