1. 首先准备两个同时启动的Tomcat
修改tomcat2的配置文件:server.xml修改端口号,使两个tomcat可以同时启动
2.拷贝对应jar包到tomcat下lib包中
commons-pool2-2.0.jar
jedis-2.5.2
tomcat-redis-session-manager1.2.jar
Java培训之启动结合redis配置负载均衡
3.修改tomcat的下content.xml(加到最下方)
<Valve className=”com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve” />
<Manager className=”com.orangefunction.tomcat.redissessions.RedisSessionManager”
host=”127.0.0.1″
port=”6379″
database=”0″
maxInactiveInterval=”60″ />
Java培训之启动结合redis配置负载均衡
4. 启动redis
5. 配置nginx.conf
http {
……
upstream myserver{
ip_hash;
server 115.28.52.63:8080 weight=1;
server 115.28.52.63:8180 weight=1;
}
…..
server{
location / {
………
proxy_pass http://myserver;
proxy_connect_timeout 10;
}
………
}
}
了解更多java培训课程相关技术内容欢迎关注小编!