1.黑色标注的得自己写入到nginx.conf文件中
upstream serverlb {
server 127.0.0.1:9999;
server 127.0.0.1:8888;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
proxy_pass http://serverlb;
index index.html index.htm;
}
2.配置多个tomcat的环境变量
CATALINA_HOME1
C:UsersAdministratorDesktop omcat1
3.多个tomcat配置文件中得写入
所有端口号都得不同
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="9999" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
配置Tomcat中session的共享:(可能不起作用,学习了Redis有更好的方法,现在还没学)
步骤一:修改server.xml文件,最简单的集群配置只需要将节点中注释掉的下面这句取消注释即可:
Xml代码:
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
步骤二:修改项目的web.xml文件:
web.xml文件的修改很简单:只需要在节点中添加这个节点<distributable/>就可以了。
OK,有了这二步就实现了Tomcat的集群和Session的共享了。