NAT集群部署solo之session server
author:JevonWei
版权声明:原创作品
使用Nginx做代理服务器,部署solo,使用session server做会话黏滞
拓扑图
环境
tomcatA 172.16.253.108
tomcatB 172.16.253.105
memcachedA 172.16.253.108
memcachedB 172.16.253.105
代理服务器 172.16.253.191
在Tomcat主机上搭建httpd服务,使httpd代理本机Tomcat应用,Nginx代理Tomcat
搭建Tomcat和Httpd服务器
TomcatA
[root@TomcatA ~]# yum -y install java-1.8.0-openjdk*
[root@TomcatA ~]# yum -y install tomcat-lib tomcat tomcat-webapps tomcat-docs-webapp tomcat-admin-webapps
[root@TomcatA ~]# iptables -F
[root@TomcatA ~]# setenforce 0
[root@TomcatA ~]# systemctl start tomcat
配置Tomcat测试页
[root@TomcatA ~]# mkdir /data/webapps/ROOT/{classes,lib,WEB-INF} -pv
[root@TomcatA ~]# vim /data/webapps/ROOT/index.jsp
<%@ page language="java" %>
<html>
<head><title>TomcatB</title></head>
<body>
<h1><font color="blue">TomcatB.magedu.com</font></h1>
<table align="centre" border="1">
<tr>
<td>Session ID</td>
<% session.setAttribute("magedu.com","magedu.com"); %>
<td><%= session.getId() %></td>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
</body>
</html>
[root@TomcatA ~]# vim /etc/tomcat/server.xml
<Engine name="Catalina" defaultHost="www.jevon1.com">
</Host>
<Host name="www.jevon1.com" appBase="/data/webapps"
unpackWARs="true" autoDeploy="true">
</Host>
[root@TomcatA ~]# systemctl restart tomcat
搭建Httpd
[root@TomcatA ~]# yum -y install httpd
[root@TomcatA ~]# vim /etc/httpd/conf.d/tomcat.conf
<VirtualHost *:80>
ServerName www.jevon1.com
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://172.16.253.108:8080/
ProxyPassReverse / http://172.16.253.108:8080/
<Location />
Require all granted
</Location>
</VirtualHost>
[root@TomcatA ~]# systemctl start httpd
TomcatB
[root@TomcatB ~]# yum -y install java-1.8.0-openjdk*
[root@TomcatB ~]# yum -y install tomcat-lib tomcat tomcat-webapps tomcat-docs-webapp tomcat-admin-webapps
[root@TomcatB ~]# iptables -F
[root@TomcatB ~]# setenforce 0
[root@TomcatB ~]# systemctl start tomcat
配置Tomcat测试页
[root@TomcatB ~]# mkdir /data/webapps/ROOT/{classes,lib,WEB-INF} -pv
[root@TomcatB ~]# vim /data/webapps/ROOT/index.jsp
<%@ page language="java" %>
<html>
<head><title>TomcatA</title></head>
<body>
<h1><font color="red">TomcatA.magedu.com</font></h1>
<table align="centre" border="1">
<tr>
<td>Session ID</td>
<% session.setAttribute("magedu.com","magedu.com"); %>
<td><%= session.getId() %></td>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
</body>
</html>
[root@TomcatB ~]# vim /etc/tomcat/server.xml
<Engine name="Catalina" defaultHost="www.jevon2.com">
</Host>
<Host name="www.jevon2.com" appBase="/data/webapps"
unpackWARs="true" autoDeploy="true">
</Host>
[root@TomcatB ~]# systemctl restart tomcat
搭建Httpd
[root@TomcatB ~]# yum -y install httpd
[root@TomcatB ~]# vim /etc/httpd/conf.d/tomcat.conf
<VirtualHost *:80>
ServerName www.jevon2.com
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://172.16.253.108:8080/
ProxyPassReverse / http://172.16.253.108:8080/
<Location />
Require all granted
</Location>
</VirtualHost>
[root@TomcatB ~]# systemctl start httpd
Haproxy代理
[root@nginx ~]# yum -y install haproxy
[root@nginx ~]# vim /etc/hosts
172.16.253.108 www.jevon1.com
172.16.253.105 www.jevon2.com
172.16.250.127 www.danran.com
[root@nginx ~]# vim /etc/nginx/nginx.conf
http {
upstream appsrvs {
server www.jevon1.com:8080;
server www.jevon2.com:8080;
}
server {
listen 80;
server_name www.danran.com;
index index.jsp index.html;
location / {
proxy_pass http://appsrvs/;
}
}
}
[root@nginx ~]# nginx -t
[root@nginx ~]# systemctl start nginx
安装后端memcached服务集群
下载相关程序到Tomcat主机的//usr/share/java/tomcat目录下
javolution-5.4.3.1.jar
memcached-session-manager-1.8.3.jar
memcached-session-manager-tc7-1.8.3.jar
msm-javolution-serializer-1.8.3.jar
spymemcached-2.11.1.jar /usr/share/java/tomcat
memcachedA
[root@TomcatA ~]# yum -y install memcached
[root@TomcatA ~]# systemctl start memcached.service
[root@TomcatA ~]# ss -ntl
memcachedB
[root@TomcatB ~]# yum -y install memcached
[root@TomcatB ~]# systemctl start memcached.service
[root@TomcatB ~]# ss -ntl
配置Tomcat连接memcached服务端
TomcatA
[root@TomcatA ~]# vim /etc/tomcat/server.xml
<Engine name="Catalina" defaultHost="www.jevon1.com" jvmRoute="tcA">
<Host name="www.jevon1.com" appBase="/data/webapps"
unpackWARs="true" autoDeploy="true">
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.16.253.108:11211,n2:172.16.253.105:11211"
failoverNodes="n1"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
/>
</Host>
[root@TomcatB ~]# systemctl restart tomcat
TomcatB
[root@TomcatB ~]# vim /etc/tomcat/server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tcB">
</Host>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.16.253.108:11211,n2:172.16.253.105:11211"
failoverNodes="n1"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
/>
</Host>
[root@TomcatB ~]# systemctl restart tomcat
部署solo
[root@TomcatA ~]# vim /etc/tomcat/server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tcA">
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="/solo-2.2.0" docBase="solo-2.2.0" reloadable="true">
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.16.253.108:11211,n2:172.16.253.105:11211"
failoverNodes="n1"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
/>
</Context>
[root@TomcatA ~]# vim /etc/tomcat/tomcat-users.xml
<role rolename="manager-gui"/> \\启用manager-gui管理组
<user username="tomcat" password="tomcat" roles="manager-gui"/> \\添加用户到manager-gui管理组中,用户为tomcat,密码为tomcat
[root@danran ~]# systemctl restart tomcat
浏览器http://172.16.253.105:8080/进入Manager App管理界面
选择solo应用的war文件部署
配置Tomcat的服务代理
[root@TomcatB webapps]# vim /etc/httpd/conf.d/tomcat.conf
<VirtualHost *:80>
ServerName www.jevon2.com
ProxyRequests Off
ProxyVia On
ProxyPreserveHost On
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://172.16.253.105:8080/solo-2.2.0/
ProxyPassReverse / http://172.16.253.105:8080/solo-2.2.0/
<Location />
Require all granted
</Location>
</VirtualHost>
[root@TomcatB webapps]# systemctl restart httpd
修改solo的服务器配置文件
[root@TomcatB ~]# vim /usr/share/tomcat/webapps/solo-2.2.0/WEB-INF/classes/latke.properties
serverHost=172.16.253.105 \\本机Tomcat的IP
[root@TomcatB ~]# systemctl restart tomcat
[root@TomcatB ~]# ss -ntl
TomcatB配置同TomcatA一致
client测试访问
NAT集群部署solo之session server的更多相关文章
- 使用Tomcat-redis-session-manager来实现Tomcat集群部署中的Session共享
一.工作中因为要使用到Tomcat集群部署,此时就涉及到了Session共享问题,主要有三种解决方案: 1.使用数据库来存储Session 2.使用Cookie来存储Session 3.使用Redis ...
- 使用Tomcat+Redis来实现集群部署中的Session共享问题
一.工作中因为要使用到Tomcat集群部署,此时就涉及到了Session共享问题,主要有三种解决方案: 1.使用数据库来存储Session 2.使用Cookie来存储Session 3.使用Redis ...
- CAS 集群部署session共享配置
背景 前段时间,项目计划搞独立的登录鉴权中心,由于单独开发一套稳定的登录.鉴权代码,工作量大,最终的方案是对开源鉴权中心CAS(Central Authentication Service)作适配修改 ...
- Spring Boot+redis存储session,满足集群部署、分布式系统的session共享
本文讲述spring-boot工程中使用spring-session机制进行安全认证,并且通过redis存储session,满足集群部署.分布式系统的session共享. 原文链接:https://w ...
- Nginx+Tomcat+Memcached 实现集群部署时Session共享
Nginx+Tomcat+Memcached 实现集群部署时Session共享 一.简介 我们系统经常要保存用户登录信息,有Cookie和Session机制,Cookie客户端保存用户信息,Sessi ...
- ArcGIS Server 9.3集群部署(多som+多soc)
关键字:集群 SOC 分布式 ArcGIS Server http://t.cn/8F8yPF3 http://t.cn/8F8yM4b http://www.netfoucs.com/nj19862 ...
- 理解 OpenStack + Ceph (1):Ceph + OpenStack 集群部署和配置
本系列文章会深入研究 Ceph 以及 Ceph 和 OpenStack 的集成: (1)安装和部署 (2)Ceph RBD 接口和工具 (3)Ceph 物理和逻辑结构 (4)Ceph 的基础数据结构 ...
- Nginx+Tomcat集群部署
为了获取更好的性能,我们常常需要将tomcat进行集群部署.下文通过nginx转发实现tomcat集群,并通过nginx-upstream-jvm-route插件保证session的粘滞. 应用场景环 ...
- HP DL160 Gen9服务器集群部署文档
HP DL160 Gen9服务器集群部署文档 硬件配置=======================================================Server Memo ...
随机推荐
- iptables中DNAT的配置方法
1.一对一流量完全DNAT 首先说一下网络环境,普通主机一台做防火墙用,网卡两块 eth0 192.168.0.1 内网 eth1 202.202.202.1 外网 内网中一台主机 192.168. ...
- IntelliJ idea学习资源
工作需要, 最近得从Eclipse转战到Idea, 找了些不错的学习资料: 1, 从eclipse上迁移过来的用户说明: https://www.jetbrains.com/help/idea/201 ...
- Nlpir Parser智能语义平台全文搜索
全文索引用于处理大文本集合,利用它人们可以在海量文本中快速获取需要的信息.全文检索系统是按照全文检索理论建立起来的用于提供全文检索服务的软件系统.一般来说,全文检索需要具备建立索引和提供查询的基本功能 ...
- 51. leetcode 530. Minimum Absolute Difference in BST
530. Minimum Absolute Difference in BST Given a binary search tree with non-negative values, find th ...
- HDU5723 Abandoned country (最小生成树+深搜回溯法)
Description An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since aban ...
- python--DenyHttp项目(2)--ACM监考客户端测试版☞需求分析
写脚本之前,先写个需求分析 以后会多写一些脚本,会注意这方面的 禁止HTTP请求☞需求分析 核心功能: 通过修改Hosts文件,禁止用户访问百度等搜索引擎 实现方法: 通过CMD控制台命令COPY覆盖 ...
- 小兴趣:用python生成excel格式座位表
脚本分两个文件: 1.生成二维随机列表:GenerateLocaltion.py 2.将列表导入excel文件:CreateExcel.py 先上GenerateLocaltion.py: impor ...
- pudian
https://zh.wikipedia.org/wiki/%E7%89%B9%E5%BE%81%E7%A0%81 http://www.voidcn.com/blog/lionzl/article/ ...
- linux 自动备份数据库
首先在你的项目合适的地方建立一个执行备份数据库的脚本 下面我建立一个叫 mysqlBackups.sh 的脚本内人如下: #!/bin/sh # Database info DB_NAME=" ...
- NYOJ 252 01串(斐波那契数列变形)
01串 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 ACM的zyc在研究01串,他知道某一01串的长度,但他想知道不含有“11”子串的这种长度的01串共有多少个, ...