Nginx配置Tomcat8集群,redis共享session
- 修改两台tomcat的启动端口分别为9001和9002
- 修改nginx的conf/nginx.conf 文件 配置多台tomcat的ip和port
upstream server_list {
server 127.0.0.1:9091 ;
server 127.0.0.1:9092 ;
}
- 修改nginx的conf/nginx.conf 文件 配置负载均衡
server {
listen 80;
# 这里配置域名
server_name www.bos.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
# 这里指向集群列表 server_list
proxy_pass http://server_list ;
index index.html index.htm;
}
-
复制jar包到tomcat的lib 目录
commons-pool2-2.2.jar
jedis-2.5.2.jar
tomcat-redis-session-manager-2.0.0.jar -
配置tomcat的conf下 context.xml
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="localhost"
port="6379"
database="0"
maxInactiveInterval="60"
/>