EhCache Distributed Caching With Terracotta in GlassFish v3

本文介绍如何安装配置Terracotta服务器实现缓存集群,并结合Glassfish V3搭建应用服务器集群,包括Terracotta的安装启动、Glassfish V3的安装部署及测试过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Terracotta

1.1 DownLoad the Terracotta

http://www.terracotta.org/dl/oss-download-catalog

terracotta-3.3.0-installer.jar

1.2 Install the Terracotta

java –jar terracotta-3.3.0-installer.jar

1.3   Start the Terracotta server

run the bat file:

 

terracotta-3.3.0/bin start-tc-server.bat

but if your system is linux or unix,you should run the terracotta-3.3.0/bin start-tc-server.sh

1.4   Start the Terracotta Developer Console and view the cluster

Run the bat file :

terracotta-3.3.0/bin dev-console.bat ,

but if your system is linux or unix,you should run the terracotta-3.3.0/bin dev-console.sh

If you have the desktop shorcut or start menu,also can start the console.

 

 

                                        Figure 1

 

 

 

 

 

                                                     Figure 2

2 Glassfish V3

2.1 Download the Glassfish v3

https://glassfish.java.net/downloads/3.0.1-final.html

glassfish-3.0.1-web-windows-ml.exe

2.2   Install the Glassfish v3

Next...

2.3   Start the Glassfish

You can use the default domain(domain1),but you can create your own domain,just like this:

glassfishv3/bin>asadmin create-domain --profile cluster --adminport 4848 robin

by the way ,during the installing ,need to enter the user name and password,

eg:username  admin

      password   adminadmin

then you can start the server:

glassfishv3/bin>asadmin start-domain robin

(note: need to enter the password:adminadmin)

2.4 About version

If you using the cluster server, we should create the node, but for version 3,it doesn’t support (Maybe support it later.) The version 2 can work.

2.5   Deploy the application

Copy the war to the ../domains/robin/autodeploy , then will generate the app under the folder:

domains/robin/applications

2.6   Install another Glassfish v3

Repeat the setp 2 to 5

2.7   Test

http://server1ip:8080/colorcache/index.jsp

http://server2ip:8080/colorcache/index.jsp

For the server1,

Input 'black' and Review Color,

 

 

 

then change to server 2,refresh the page,you'll see the cache color 'black'

 

     

3. Demo

This demo I got from the sample,and modified the coding and configuration.

commons-logging.jar ,ehcache-core-2.2.0.jar,ehcache-terracotta-2.2.0.jar,slf4j-api-1.5.11.jar,slf4j-jdk14-1.5.11.jar,terracotta-toolkit-1.0-runtime-1.0.0.jar,servlet-api-2.5-6.1.8.jar

I remove the jar from the attachment,you can added them by yourself.

 You can downlode the demo(src file) from here: http://download.youkuaiyun.com/source/3224633

ehcache.xml

 

Maybe you should copy this file to overwrite the default config of the terracotta if the dev console can’t show Ehcache node.

/terracotta-3.3.0/ehcache ehcache.xml

 

By the way, there have more configuration in the demo file:

under the folder terracotta-3.3.0/ehcache


ehcache.xml

 

reference:

http://ehcache.org/documentation/  

http://www.terracotta.org/start/distributed-cache-tutorial  

http://www.terracotta.org/dl/ehcache-oss-download-catalog


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值