我想在ehcache上啓用2節點之間的項目之一的分佈式緩存,但我遇到了問題。 我使用的Ehcache核心2.6.11在Java Spring項目Ehcache - 無法獲得分佈式緩存工作
下面是每個服務器上的
節點我的Ehcache配置的相關部分1
節點2
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="
peerDiscovery=manual,
rmiUrls=//node1.mydomain.com:40001/myCache1|//node1.mydomain.com:40001/myCache2"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="port=40002"/>
當我更新緩存並期望它被複制 - 這裏有
03.03.2016 06:44:50 DEBUG [net.sf.ehcache.distribution.RMICacheManagerPeerProvider.lookupRemoteCachePeer():126] Lookup URL //node2.mydomain.com:40002/myCache1
03.03.2016 06:44:50 WARN [net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.writeReplicationQueue():325] Unable to send message to remote peer. Message was: Connection refused to host: <node 2 IP Address>; nested exception is:
java.net.ConnectException: Connection refused
java.rmi.ConnectException: Connection refused to host: <node 2 IP Address>; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at net.sf.ehcache.distribution.RMICachePeer_Stub.send(Unknown Source)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.writeReplicationQueue(RMIAsynchronousCacheReplicator.java:314)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThreadMain(RMIAsynchronousCacheReplicator.java:127)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.access$000(RMIAsynchronousCacheReplicator.java:58)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread.run(RMIAsynchronousCacheReplicator.java:389)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at net.sf.ehcache.distribution.ConfigurableRMIClientSocketFactory.createSocket(ConfigurableRMIClientSocketFactory.java:70)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 8 more
節點2
03.03.2016 06:44:50 DEBUG [net.sf.ehcache.distribution.RMICacheManagerPeerProvider.lookupRemoteCachePeer():126] Lookup URL //node1.mydomain.com:40001/myCache1
03.03.2016 06:44:50 WARN [net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.writeReplicationQueue():325] Unable to send message to remote peer. Message was: Connection refused to host: <node 2 IP Address>; nested exception is:
java.net.ConnectException: Connection refused
java.rmi.ConnectException: Connection refused to host: <node 2 IP Address>; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at net.sf.ehcache.distribution.RMICachePeer_Stub.send(Unknown Source)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.writeReplicationQueue(RMIAsynchronousCacheReplicator.java:314)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThreadMain(RMIAsynchronousCacheReplicator.java:127)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.access$000(RMIAsynchronousCacheReplicator.java:58)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread.run(RMIAsynchronousCacheReplicator.java:389)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at net.sf.ehcache.distribution.ConfigurableRMIClientSocketFactory.createSocket(ConfigurableRMIClientSocketFactory.java:70)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 8 more
UPDATE
我已經改變了錯誤,我得到我的節點
節點1
我的配置現在使用自動發現而不是手動。 我有四臺服務器,2在站點A和2在站點B 複製的現在工作作爲兩個節點,但是沒有複製是發生在站點B或站點A和站點B.之間預期站點A我在每個節點和其他節點之間使用了netcat和telnet,並且接受了所有連接。
這裏是我的Ehcache配置爲自動發現的有關章節
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic,
multicastGroupAddress=230.3.0.0,
multicastGroupPort=4700,
timeToLive=255"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="port=43000,
socketTimeoutMillis=20000"/>
誰能提供任何深入瞭解如何複製不工作在站點B或我可以嘗試任何想法?
感謝
你使用IPV4嗎?如果您使用IPV6,那麼在ehcache複製中可能會出現一些問題 –
我們正在使用IPV4 – Damien