网站首页 > 技术教程 正文
1.集群
- 生成发布包
- 项目右键export生成war包
- 再解压一个tomcat
- 把war包放入第二个tomcat,wabapps中,设置端口号,根目录conf的server.xml中
再修改第二个startup.bat增加两行代码
写在最上方
SET JAVA_HOME=D:\java //指定jdk安装的路径根路径,不用进入bin文件夹中
SET CATALINA_HOME=D:\apache-tomcat-7.0.67 //指定第二个tomcat根路径
- 1
- 2
- 3
- 启动nginx 根目录下conf下的nginx.conf
server {
listen 80;
server_name localhost;//表示进入端口自动寻找localtion
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;//默认的localtion地址
index index.html index.htm;//这个地址下有哪些页面可以访问
//添加proxy_pass
proxy_pass http://server_list/;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 在当前conf文件中添加upstream
upstream server_list{
server localhost:8080;//添加所有的tomcat访问地址
server localhost:8081;
}
- 1
- 2
- 3
- 4
示例如下:
http {
limit_conn_log_level error;
limit_conn_status 503;
limit_conn_zone $binary_remote_addr zone=one:10m;
limit_conn_zone $server_name zone=perserver:10m;
limit_req_zone binary
r
emote
a
ddrzone=allips:100mrate=10r/s;其中
binaryremoteaddrzone=allips:100mrate=10r/s;其中binary_remote_addr有时需要根据自己已有的log_format变量配置进行替换
server {
…………………….
limit_conn one 100;
- 1
- 2
- 3
- 4
limit_conn perserver 1000;
limit_req zone=allips burst=5 nodelay;
………………….
- 1
- 2
- 3
- 4
}
}
参数解释:
Zone=one或allips 表示设置了名为“one”或“allips”的存储区,大小为10兆字节
rate=10r/s 的意思是允许1秒钟不超过10个请求
burst=5 表示最大延迟请求数量不大于5。 如果太过多的请求被限制延迟是不需要的 ,这时需要使用nodelay参数,服务器会立刻返回503状态码。
limit_conn one 100表示最大并发连接数100
limit_conn perserver 1000表示该服务提供的总连接数不得超过1000,超过请求的会被拒绝
2.启动nginx
- 解压nginx压缩包
- 命令行敲代码
3.配置tomcat
多个Tomcat同步Session
分别修改tomcat的server.xml配置文件
- 为元素指定jvmRoute属性名,名称保持一致
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
- 1
- 释放开元素注释
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
- 1
- 在项目project的web.xml中配置< distributable/>元素
nginx+tomcat+redis完成session共享
安装redis、tomcat、nginx
session同步配置
下载jar包,放入到tomcat/lib目录下
tomcat-redis-session-manager-1.2-tomcat-7-java-7.jar
jedis-2.5.2.jar
commons-pool2-2.0.jar
修改tomcat中context.xml文件
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="10.10.49.20"
port="6379"
database="0"
maxInactiveInterval="60" />
</Context>
猜你喜欢
- 2024-10-13 PHP 分布式集群中session共享问题以及session有效期的设置
- 2024-10-13 spring-session的使用详解(spring sessionfactory)
- 2024-10-13 springboot集成springsession利用redis来实现session共享
- 2024-10-13 「SSO单点登录」分布式Session存在问题 spring-session的设计之妙
- 2024-10-13 【第一篇】Spring-Session实现Session共享入门教程
- 2024-10-13 如何实现集群中的 session 共享存储?什么是二进制协议?
- 2024-10-13 分布式环境session共享实战课程(分布式怎么实现session共享)
- 2024-10-13 SpringBoot一个依赖搞定session共享,没有比这更简单的方案了
- 2024-10-13 #高可用的并发解决方案nginx+keepalived(二)
- 2024-10-13 阿里十年架构师带你学分布式高性能架构Dubbo+Nginx+Session+RPC
你 发表评论:
欢迎- 最近发表
-
- Oracle 在其新的 Linux 内核中引入了热补丁功能
- CentOS 7.6下安装Oracle 11.2.0.4
- ORACLE体系 - 2(oracle体系讲解)
- ORA-12514 TNS 监听程序当前无法识别连接描述符中请求服务
- Hadoop自学系列集(二) ---- CentOS下安装JDK
- 如何升级oracle数据库安全补丁(oraclepsu补丁升级)
- 搭建Oracle数据库服务器(oracle服务器创建用户)
- OGG同步到Kafka(oggforbigdata到kafka)
- oracle是什么软件?(oracle是干什么用的)
- 脚本化修改Oracle用户的密码以及执行sql(增删改查等)
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)