Tomcat clustering + Haproxy

1. High Availability of Tomcat

or you can use

If one backend is down, you will lose sessions.

2. Haproxy + Tomcat Clustering

How to enable Tomcat Clustering

1)  Edit server.xml

2 = Channel.SEND_OPTIONS_USE_ACK(确认发送)

4 = Channel.SEND_OPTIONS_SYNCHRONIZED_ACK(同步发送)

8 = Channel.SEND_OPTIONS_ASYNCHRONOUS(异步发送)

2) Edit your project’s web.xml, ie, /opt/apache-tomcat-8.0.12/webapps/examples/WEB-INF/web.xml , add <distributable/>

3) Edit server.xml , add jvmRoute.

 3. Test

Access the SessionExample page and add some data: http://192.168.56.21:82/examples/servlets/servlet/SessionExample

session1
Now stop jvm1, and then accees the page. our session data is still there!
session2

Logs

发表评论