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,即可。