2019独角兽企业重金招聘Python工程师标准>>>
一、环境相关
操作系统:CentOS7
软件版本:nginx/1.9.15 Apache Tomcat/7.0.69 redis 3.20
网络环境:Nginx 192.168.5.250 Tomat1:192.168.5.251 Tomcat2:192.168.5.252 Redis:192.168.5.253
相关软件网盘地址:http://pan.baidu.com/s/1skBIlXV
二、相关软件配置
1、Nignx编译与添加自启脚本:http://my.oschina.net/huangweibin/blog/665239
Nginx 192.168.5.250
[root@nginx ~]# vim /etc/nginx/nginx.conf
http上下文
upstream tomcat {
server 192.168.5.251:8080;
server 192.168.5.252:8080;
}
server上下文
location / {
proxy_pass tomcat;
}
2、Reids编译与添加自启脚本:http://my.oschina.net/huangweibin/blog/671408
3、Tomcat编译与添加自启脚本:CentOS7 编译Tomcat并添加自启动脚本(注意:本文Tomcat要求版本为tomcat-7.x)
http://my.oschina.net/huangweibin/blog/668412
四、编译tomcat-redis-session-manager
1.官方下载地址 https://github.com/jcoleman/tomcat-redis-session-manager
2.配置编译环境Gradle:http://my.oschina.net/huangweibin/blog/671419
[root@localhost ~]# unzip tomcat-redis-session-manager-master.zip
[root@localhost ~]# cd tomcat-redis-session-manager-master/
[root@localhost tomcat-redis-session-manager-master]# vim build.gradle
注释以下内容:
//signing {
// sign configurations.archives
//}
//repository(url: "
https://oss.sonatype.org/service/local/staging/deploy/maven2/
") {
// authentication(userName: sonatypeUsername, password: sonatypePassword)
//}
增加依赖包的输出脚本
task copyJars(type: Copy) {
from configurations.runtime
into 'dist'
}
3.执行gradle命令构建源码,编译输出tomcat-redis-session-manager-master 及依赖jar包(其他Tomcat只需要复制jar文件到tomcat目录)
[root@localhost tomcat-redis-session-manager-master]# gradle build -x test copyJars
[root@localhost tomcat-redis-session-manager-master]# mkdir /tmp/jar
[root@localhost tomcat-redis-session-manager-master]# cp -a build/libs/*.jar /tmp/jar/ && cp -a dist/*.jar /tmp/jar/
[root@localhost jar]# ls /tmp/jar
commons-pool2-2.2.jar
jedis-2.5.2.jar
tomcat-annotations-api-7.0.27.jar
tomcat-api-7.0.27.jar
tomcat-catalina-7.0.27.jar
tomcat-juli-7.0.27.jar
tomcat-redis-session-manager-master-2.0.0.jar
tomcat-redis-session-manager-master-2.0.0-javadoc.jar
tomcat-redis-session-manager-master-2.0.0-sources.jar
tomcat-servlet-api-7.0.27.jar
tomcat-util-7.0.27.jar
[root@localhost jar]# cp -a /tmp/jar/* /usr/local/tomcat/lib/
五、配置Tomcat参数并创建测试页面(其他Tomcat配置类似)
[root@localhost jar]# vim /usr/local/tomcat/conf/context.xml
[root@localhost jar]# mkdir -pv /usr/local/tomcat/webapps/session/WEB-INF/{classes,lib}
[root@localhost jar]# vim /usr/local/tomcat/webapps/session/index.jsp
<%@ page language="java" %>
Tomcat1
Tomcat1.example.com
Session ID
<% session.setAttribute("Tomcat.example.com","Tomcat.example.com"); %>
<%= session.getId() %>
Created on
<%= session.getCreationTime() %>