设置 ehcache 复制 - 我需要哪些多播设置?

发布于 2024-07-21 05:32:13 字数 1141 浏览 14 评论 0原文

我正在尝试按照此处记录的方式设置 ehcache 复制: http://ehcache.sourceforge .net/EhcacheUserGuide.html#id.s22.2
这是在 Windows 计算机上进行的,但最终将在生产环境中在 Solaris 上运行。

说明说要设置一个提供者,如下所示:

 <cacheManagerPeerProviderFactory
     class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
     properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
     multicastGroupPort=4446, timeToLive=32"/>

和一个这样的监听器:

<cacheManagerPeerListenerFactory
    class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
    properties="hostName=localhost, port=40001,
    socketTimeoutMillis=2000"/>

我的问题是:
多播 IP 地址和端口是任意的(我知道该地址必须位于特定范围内,但它们必须是特定的数字)吗?
它们是否需要由我们的系统管理员以某种方式设置(我在办公网络上)?

我想在本地测试它,所以我使用上述配置运行两个单独的 tomcat 实例。 我需要对每一项进行哪些更改? 我知道两个侦听器无法侦听同一端口 - 但提供商呢?
另外,侦听器端口也是任意的吗?

我已尝试按上述方式进行设置,但在我的测试中,缓存似乎没有被复制 - 一个 tomcat 缓存中添加的值不存在于另一个缓存中。
我可以做些什么来调试这种情况(除了数据包嗅探之外)?

预先感谢您的任何帮助,我一直在为这个问题而烦恼!

I am trying to set up ehcache replication as documented here: http://ehcache.sourceforge.net/EhcacheUserGuide.html#id.s22.2
This is on a Windows machine but will ultimately run on Solaris in production.

The instructions say to set up a provider as follows:

 <cacheManagerPeerProviderFactory
     class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
     properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
     multicastGroupPort=4446, timeToLive=32"/>

And a listener like this:

<cacheManagerPeerListenerFactory
    class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
    properties="hostName=localhost, port=40001,
    socketTimeoutMillis=2000"/>

My questions are:
Are the multicast IP address and port arbitrary (I know the address has to live within a specific range but do they have to be specific numbers)?
Do they need to be set up in some way by our system administrator (I am on an office network)?

I want to test it locally so am running two separate tomcat instances with the above config.
What do I need to change in each one? I know both the listeners can't listen on the same port - but what about the provider?
Also, are the listener ports arbitrary too?

I've tried setting it up as above but in my testing the caches don't appear to be replicated - the value added in one tomcat's cache is not present in the other cache.
Is there anything I can do to debug this situation (other than packet sniffing)?

Thanks in advance for any help, been tearing my hair out over this one!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

笑忘罢 2024-07-28 05:32:13

我想在本地测试它,所以我
运行两个单独的 tomcat 实例
与上述配置。

因为我刚刚提交了有关 cherouvims 相关问题我也想在这里强调一下,他们实际上提供了一个至少执行类似操作的示例(每个主机有多个节点,尽管只有一个实例):请参阅完整示例 在 RMI 分布式缓存 文档中。

更改每个 cacheManagerPeerListenerFactory 的 TCP 端口确实很重要,但多播设置可以(我认为它们必须)保持不变:您可以在 ehcache.xml完整示例 上面提到:每个节点的端口号从 40001 一一增加到 40006,同时多播设置保持不变。

如果您遵守了这一点,您的问题可能与在 Windows 上运行的 Tomcat 有关 - 请参阅 RMI 分布式缓存

Tomcat 和/或 JDK 中存在一个错误,任何 RMI 监听器都会
如果安装路径中有空格,Tomcat 启动失败。
[...]
由于 Windows 上默认将 Tomcat 安装在“Program Files”中,
默认情况下会出现此问题。

I want to test it locally so am
running two separate tomcat instances
with the above config.

As I have just submitted an answer regarding cherouvims related question I'd just like to highlight here too that they are in fact providing an example doing something similar at least (multiple nodes per host, though one instance only): see section Full Example in the RMI Distributed Caching documentation.

It's indeed important to change the TCP port for each cacheManagerPeerListenerFactory but the multicast settings can (I'd think they must) stay the same: you can see this in action within the ehcache.xml's for the Full Example mentioned above: the port number is increased one by one from 40001 up to 40006 per node while the multicast settings stay identical.

If you have obeyed that, your problem might just be related to Tomcat running on Windows - see the related paragraph within section Common Problems in RMI Distributed Caching:

There is a bug in Tomcat and/or the JDK where any RMI listener will
fail to start on Tomcat if the installation path has spaces in it.
[...]
As the default on Windows is to install Tomcat in "Program Files",
this issue will occur by default.

み青杉依旧 2024-07-28 05:32:13

我在EHCache对等复制过程中遇到的一个错误。 这可能很有用,因此有人尝试在单个本地机器上进行对等复制。

我想使用peerDiscovery=automatic(最终目标环境是Linux)在单个Windows Vista 机器上运行3 个对等复制的EhCache 实例。

对等复制不起作用。 奇怪的是,所有 EhCache 实例都在启动,日志中没有任何错误或投诉。

我花了一段时间才弄清楚我的错误; 日志中没有任何内容,我不得不摸索:我在每个 EhCache 实例的对等侦听器配置中使用相同的侦听器端口(40001)。 使用不同的监听器端口(40001、40002...)就可以了。

<cacheManagerPeerListenerFactory 
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
properties="port=40001, socketTimeoutMillis=3000"/>

<cacheManagerPeerListenerFactory 
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
properties="port=40002, socketTimeoutMillis=3000"/>

请注意,这是需要不同端口号的“对等侦听器”配置。 多播“对等发现”仍然对每个 ehcache 实例使用相同的多播地址和端口号。

One mistake I encountered during EHCache peer replication. This might be useful so someone attempting peer replication on a single local box.

I wanted to run 3 peer-replicated instances of EhCache on a single Windows Vista box using peerDiscovery=automatic (the eventual target environment was Linux).

The peer-replication did not work. Oddly, all EhCache instances were starting-up without any errors or complaints in the log.

Took me a while to figure my mistake; without anything in the logs I had to grok around: I was using the same listenerPort (40001) in the peer listener configuration for each of the EhCache instances. Using different listenerPorts (40001, 40002...) did the trick.

<cacheManagerPeerListenerFactory 
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
properties="port=40001, socketTimeoutMillis=3000"/>

<cacheManagerPeerListenerFactory 
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
properties="port=40002, socketTimeoutMillis=3000"/>

Note that this is the 'peer listener' configuration that needed different port numbers. The multicast 'peer discovery' still uses identical multicast address and port numbers for every ehcache instance.

天荒地未老 2024-07-28 05:32:13

首先确保您的服务器启用了多播。 不确定您在哪个平台上运行。

Make sure your servers have multicast enabled for starters. Not sure what platform you are running on.

又怨 2024-07-28 05:32:13

就像快速跟进一样。

我们确实用两台独立的机器解决了这个问题,解决了让它工作的最初问题。
据我记得,多播应该“开箱即用”,但值得与您的本地系统管理员检查(我们建议对多播组地址进行调整)。

我们最终在 Solaris 上遇到了各种各样的问题,最终放弃了多播,转而使用手动对等发现反而。

最后,在调试方面,使用 jconsole 来监视缓存值被证明是最好的方法。 不必诉诸数据包嗅探。 :-)

Just as a quick follow-up.

We did get this working with two separate machines which solved the original problem of getting it to work at all.
As far as I recall Multicast should work "out of the box" but it's worth checking with your local sysadmin (ours suggested a tweak to the multicastGroupAddress).

We eventually hit all sorts of problems on Solaris and ended up abandoning multicast for Manual Peer Discovery instead.

Finally, in terms of debugging, using jconsole to monitor cache values proved to be the best way to do it. Didn't have to resort to packet sniffing. :-)

伴随着你 2024-07-28 05:32:13
 <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/>

只需执行上述操作,ehcache 将使用下一个可用的! 因此,您不必担心要在集群中部署的新节点上的配置。

 <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/>

just doing the above, ehcache will use the next available one ! So you don't have to worry about configuration on new nodes that you want to deploy in the cluster.

杯别 2024-07-28 05:32:13

可以帮助某人实现多播。 我已经通过在 eclipse 中在本地 tomcat 中运行我的应用程序并从同事的 eclipse 中在本地 tomcat 中运行相同的应用程序来进行验证。

在 Windows 计算机上运行以下命令将向您显示一些 ip,并确保多播正常工作。

netsh interface ip show joins

属性multicastGroupAddress=230.0.0.1 表示您的应用程序想要使用此IP,可以更改此设置,但确保仅使用D 类IP 范围。 运行应用程序后,您可以看到此 IP 230.0.0.1 也如下所示
输入图片此处描述

要查看所有魔法,请确保正确启用日志。

    <logger name="net.sf.ehcache">  <level value="debug"/></logger>
   <logger name="net.sf.ehcache.distribution.RMICachePeer" level="debug" />

确保在您的默认缓存或所需的缓存配置中具有以下列表。

         <cacheManagerPeerProviderFactory
       class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
       properties="port=40003, peerDiscovery=automatic,
                   multicastGroupAddress=230.0.0.1,
                   multicastGroupPort=4446,
                   timeToLive=32"/>
    <cacheManagerPeerListenerFactory 
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
        properties="port=40001, socketTimeoutMillis=3000" />
    <cacheManagerPeerListenerFactory 
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
        properties="port=40002, socketTimeoutMillis=3000"/>
 <defaultCache
     eternal="false"
     timeToIdleSeconds="300"
     timeToLiveSeconds="300"
     diskExpiryThreadIntervalSeconds="305"
     memoryStoreEvictionPolicy="LRU"
     statistics="true">
     <persistence strategy="localTempSwap"/>
     <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
     <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"/>
        </defaultCache>

部署应用程序后,您可以在日志中看到以下内容,

13:31:27.073  DEBUG n.s.e.d.PayloadUtil assembleUrlList - Cache peers for this CacheManager to be advertised:......
15:15:14.110  DEBUG net.sf.ehcache.distribution.MulticastKeepaliveHeartbeatReceiver processPayload rmiUrls received....(YOur configured caches with Ips)

如果您需要配置手动对等发现过程,这将很有帮助。

May help Someone implementing multicasting. I have verified by running my app in my local tomcat from eclipse and running the same app in the local tomcat from eclipse of my colleague.

Running below on your Windows Machine will show you some ips and ensures that multi-casting should work.

netsh interface ip show joins

the attribute multicastGroupAddress=230.0.0.1 means that your application want to use this IP, this can be changed but ensure to use the Class D IP Range only. After running your application, you could see this IP 230.0.0.1 Also in as below
enter image description here

To see all magics, ensure to enable logs properly.

    <logger name="net.sf.ehcache">  <level value="debug"/></logger>
   <logger name="net.sf.ehcache.distribution.RMICachePeer" level="debug" />

Ensure to Have below lisners in your default cache or required cache configuration

         <cacheManagerPeerProviderFactory
       class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
       properties="port=40003, peerDiscovery=automatic,
                   multicastGroupAddress=230.0.0.1,
                   multicastGroupPort=4446,
                   timeToLive=32"/>
    <cacheManagerPeerListenerFactory 
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
        properties="port=40001, socketTimeoutMillis=3000" />
    <cacheManagerPeerListenerFactory 
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
        properties="port=40002, socketTimeoutMillis=3000"/>
 <defaultCache
     eternal="false"
     timeToIdleSeconds="300"
     timeToLiveSeconds="300"
     diskExpiryThreadIntervalSeconds="305"
     memoryStoreEvictionPolicy="LRU"
     statistics="true">
     <persistence strategy="localTempSwap"/>
     <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
     <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"/>
        </defaultCache>

After Deploying the application you could see below in logs

13:31:27.073  DEBUG n.s.e.d.PayloadUtil assembleUrlList - Cache peers for this CacheManager to be advertised:......
15:15:14.110  DEBUG net.sf.ehcache.distribution.MulticastKeepaliveHeartbeatReceiver processPayload rmiUrls received....(YOur configured caches with Ips)

Which will be helpfull if you need to configure manual peer discovery process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文