Ok, our tutorial will end by adding Apache web server to load balance the traffic between both Tomcats.
install Apache Web Server
just run the msi installer or install it from an RPM or from the OS repositories, i will refer to the installation directory as ${APACHE_HOME}.
point your browser to localhost and make sure you are welcomed with the most famous message
IT WORKS!
install mod_jk
extract the file tomcat-connectors-x.x.xx-windows-arch-httpd-2.2.x.zip, copy mod_jk.so to ${APACHE_HOME}\modules
Configure Apache Web Server
httpd.conf
edit the file ${APACHE_HOME}\conf\httpd.conf to add the following settings:
LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkShmFile logs/mod_jk.shm JkLogFile logs/mod_jk.log JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkMount /examples loadbalancer JkMount /examples/* loadbalancer JkMount /status status JkMount /status/* status
here we are loading the mod_jk module, the mod_jk will load cluster members (Tomcats) from a file named workers.properties under ${APACHE_HOME}\conf directory.
also, any requests coming to apache at /examples will be forwarded to one of our Tomcats.
while /status will direct us to the mod_jk control panel.
workers.properties
create a new file under the directory ${APACHE_HOME}\conf namedworkers.properties with the following content:
# Define list of workers that will be used worker.list=loadbalancer,status # Define tomcat1 worker.tomcat1.port=8009 worker.tomcat1.host=127.0.0.1 worker.tomcat1.type=ajp13 worker.tomcat1.lbfactor=1 # Define tomcat2 worker.tomcat2.port=8010 worker.tomcat2.host=127.0.0.1 worker.tomcat2.type=ajp13 worker.tomcat2.lbfactor=1 # Load-balancing behaviour worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=tomcat1,tomcat2 worker.loadbalancer.sticky_session=0 # Status worker for managing load balancer worker.status.type=status
note that the worker names must match the jvmRoute configurations on the Tomcats. also, you can enable sticky sessions or disable to fit your need, however, i have turned it off here.
restart apache web server, if everything went as it should, navigating to http://localhost/examples would result in this page.
if you have debugging installed on your browser, like firebug, you can check your JSESSIONID value, you will find it post fixed with the jvmRoute value of the tomcat server who served the response.
if you hit the refresh button you can see that you are moving for every hit from one Tomcat to the other.
Testing Sessions Failover
point your browser to http://localhost/examples/servlets/servlet/SessionExample add a couple of values in the session.
now it is up to you, bring any Tomcat down (not both, of course) or any Terracotta (not both, of course), play around, your minimal setup is one Tomcat and one Terracotta server.
your values in the session should never disappear!!!
Have Fun.
相关推荐
terracotta-toolkit-1.3-runtime-3.2.0.jar 集群实现JAR
Terracotta集群Tomcat的配置是一项复杂而关键的任务,它涉及到分布式系统中的高可用性和负载均衡。以下将详细解释这个过程中的各个步骤和相关知识点。 首先,安装Terracotta 3.2.1版本是非常基础的一步。需要注意的...
3. **热备与故障切换**:在集群中,如果一台服务器出现故障,Terracotta能自动将工作负载转移到其他健康节点,实现无缝故障切换,保障服务连续性。 4. **可扩展性**:随着业务增长,可以轻松添加更多服务器到集群,...
【 Terracotta + Tomcat 集群配置详解】 在分布式计算环境中,集群技术是提升系统可用性和性能的重要手段。本文将深入探讨 Terracotta 与 Tomcat 集群的配置,以及如何利用 Terracotta 实现高效、可靠的 session ...
terracotta-3.7.7-installer.jar
### 通过Terracotta实现基于Tomcat的Web应用集群 #### 概述 本文主要介绍了如何利用Terracotta与Tomcat构建高效的Web应用集群。在实际应用中,通过集群技术可以显著提升系统的可用性和伸缩性,特别是对于高流量、...
terracotta-eclipse-plugin-3.7.7-2013-08-19_16-03-48.tar(terracotta的Eclipse插件) 发现官网挺卡的,有时候下不了,先传上来吧,供国内用户下载,这个算最新的吧。2014-02-17下载的。
terracotta-3.7.7-2013-08-19_16-03-48-installer(jar安装包) 官方网站卡得要死,有时候不一定能下载,把最近自己用的,算最新版吧,提供在国内网站下载吧。 2014-02-17下载的。
terracotta-ee-3.5.2破解版
### 通过 Terracotta 实现基于 Tomcat 的 Web 应用集群 #### 一、引言 随着互联网技术的发展和用户需求的增长,单一服务器已经难以满足高并发访问的需求。因此,构建高性能、高可用性的 Web 应用集群成为了当前 IT...
3. 配置Ehcache 首先,你需要在项目中添加Ehcache和Terracotta的依赖。在Maven项目中,可以在pom.xml文件中添加如下依赖: ```xml <groupId>net.sf.ehcache</groupId> <artifactId>ehcache 您的版本号 ...
记载了terracotta如何与tomcat、jetty等服务器的集群,解释了tc-config.xml中各个配置的作用
3. Tomcat 7:Tomcat是一个开源的Java Servlet容器,主要用于部署和运行Java Web应用。在集群中,多个Tomcat实例可以并行运行,每个实例都包含一部分应用负载,这样可以提升系统处理能力。mod_JK会将Apache接收到的...
### Terracotta:分布式内存管理解决方案 #### 一、Terracotta概述 Terracotta是一种分布式内存管理和数据共享平台,其核心产品BigMemory Max旨在帮助应用程序实现数据在内存中的高效管理,尤其适用于分布式服务器...
jar包,官方版本,自测可用
【标题】"Terracotta - Web CMS-开源" 指的是一个名为Terracotta的开源Web内容管理系统。这个系统采用PHP编程语言开发,具备高度灵活性和可扩展性,允许用户管理和发布网站内容。"开源"意味着源代码对公众开放,用户...
资源分类:Python库 所属语言:Python 资源全名:terracotta-toolbelt-0.0.5.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
- **Session 同步优化**:Terracotta 的 session 同步机制是对传统 Tomcat 集群机制的一种优化。传统的 session 复制机制会在 session 发生任何变化时将整个 session 数据进行序列化并广播到所有节点,这可能导致...
Terracotta是一款强大的Java应用程序管理工具,特别是对于处理Tomcat服务器的session集群有着显著的优势。在本场景中,我们关注的是“terracotta-3.7.7.tar.gz”这个Linux安装包,它包含了实现Tomcat session集群所...