Cluster computing 未在liferay群集中复制ehcache

Cluster computing 未在liferay群集中复制ehcache,cluster-computing,replication,liferay-6,ehcache,jgroups,Cluster Computing,Replication,Liferay 6,Ehcache,Jgroups,我有以下设置 1.AWS上有2台机器的liferay群集 2.tcp上使用JGroups的单播群集复制 我在portal-ext.properties中有以下参数 #Setup hibernate net.sf.ehcache.configurationResourceName=/myehcache/hibernate-clustered.xml #Setup distributed ehcache ehcache.multi.vm.config.location=/myehcache/lif

我有以下设置

1.AWS上有2台机器的liferay群集

2.tcp上使用JGroups的单播群集复制

我在portal-ext.properties中有以下参数

#Setup hibernate
net.sf.ehcache.configurationResourceName=/myehcache/hibernate-clustered.xml

#Setup distributed ehcache
ehcache.multi.vm.config.location=/myehcache/liferay-multi-vm-clustered.xml

#
# Clustering settings
#
cluster.link.enabled=true
ehcache.cluster.link.replication.enabled=true
cluster.link.channel.properties.control=tcp.xml
cluster.link.channel.properties.transport.0=tcp.xml
lucene.replicate.write=true

#In order to make use of jgroups
    ehcache.bootstrap.cache.loader.factory=com.liferay.portal.cache.ehcache.JGroupsBootstrapCacheLoaderFactory
ehcache.cache.event.listener.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory
 ehcache.cache.manager.peer.provider.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory
net.sf.ehcache.configurationResourceName.peerProviderProperties=file=/myehcache/tcp.xml
ehcache.multi.vm.config.location.peerProviderProperties=file=/myehcache/tcp.xml

cluster.executor.debug.enabled=true
ehcache.statistics.enabled=true
我无法使群集缓存复制正常工作。有人能给我指一下正确的方向吗?
如果以后需要,我可以发布更多细节。我还试图修改hibernate-clustered.xml和liferay-multi-vm-clustered.xml,但没有任何效果。

我花了很多时间让liferay 6.1.1 CE群集在AWS上工作

这是我的“portal-ext.properties”,与您的

##
## JDBC
##

# Tomcat datasource
jdbc.default.jndi.name=jdbc/LiferayPool

##
## Mail
##

# Tomcat mail session
mail.session.jndi.name=mail/MailSession

##
## Document Library Portlet
##

# NFS shared folder
dl.store.file.system.root.dir=/opt/document_library/

##
## Cluster Link
##

# Cluster Link over JGroups TCP unicast
cluster.link.enabled=true
cluster.link.channel.properties.control=custom_cache/tcp.xml
cluster.link.channel.properties.transport.0=custom_cache/tcp.xml

# Any VPC internal IP useful to detect local eth interface
cluster.link.autodetect.address=10.0.0.19:22

##
## Lucene Search
##

# Lucene index replication over Cluster Link
lucene.replicate.write=true

##
## Hibernate
##

# Second Level cache distributed with Ehcache over JGroups TCP unicast
net.sf.ehcache.configurationResourceName=/custom_cache/hibernate-clustered.xml
net.sf.ehcache.configurationResourceName.peerProviderProperties=file=custom_cache/tcp.xml

##
## Ehcache
##

# Liferay cache distributed with Ehcache over JGroups TCP unicast
ehcache.multi.vm.config.location=/custom_cache/liferay-multi-vm-clustered.xml
ehcache.multi.vm.config.location.peerProviderProperties=file=custom_cache/tcp.xml

ehcache.bootstrap.cache.loader.factory=com.liferay.portal.cache.ehcache.JGroupsBootstrapCacheLoaderFactory
ehcache.cache.event.listener.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory
ehcache.cache.manager.peer.provider.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory
我添加了以下属性

singleton_name="custom_cache"
到“custom_cache/TCP.xml”JGroups配置的TCP信封

最后,我为节点1的Liferay启动脚本添加了以下选项

JAVA_OPTS="$JAVA_OPTS -Djgroups.bind_addr=NODE_1 -Djgroups.tcpping.initial_hosts=NODE_1[7800],NODE_2[7800] -Djava.net.preferIPv4Stack=true"
和节点2

JAVA_OPTS="$JAVA_OPTS -Djgroups.bind_addr=NODE_2 -Djgroups.tcpping.initial_hosts=NODE_1[7800],NODE_2[7800] -Djava.net.preferIPv4Stack=true"

我希望这能帮助您节省时间。

在花了几天时间阅读了无数的博客文章、论坛主题,当然还有一些问题之后,我想在这里总结一下我们最终是如何在Liferay 6.2集群中配置缓存复制的,使用单播TCP来适应Amazon EC2的

JGroups配置 在为缓存复制配置Liferay之前,您必须了解Liferay依赖于JGroups通道。基本上,JGroups允许发现远程实例并与之通信。默认情况下(至少在Liferay中),它利用多播UDP来实现这些目标。更多信息,请参阅

要启用单播TCP,必须首先从Liferay webapp中的
JGroups.jar
获取JGroups的TCP配置文件(类似于
$Liferay\u HOME/tomcat-7.0.42/webapps/ROOT/WEB-INF/lib/JGroups.jar
)。将此文件解压缩到Liferay webapp的类路径可用的位置。比如说
$LIFERAY\u HOME/tomcat-7.0.42/webapps/ROOT/WEB-INF/classes/custom\u jgroups/tcp.xml
。注意这条路

要使此配置在Liferay集群中工作,只需将
singleton\u name=“Liferay”
属性添加到
TCP
标记:

<config xmlns="urn:org:jgroups"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.1.xsd">
    <TCP singleton_name="liferay"
         bind_port="7800"
         loopback="false"
         ...
绑定地址定义要侦听的网络接口(在TCP配置文件中,JGroups端口设置为7800)。初始主机属性必须包含群集的每个实例(有关详细信息,请参阅),以及它们的侦听端口。远程实例可以通过其主机名、本地地址或公共地址来引用

提示:如果要在Amazon EC2上设置Liferay群集,则每次重新启动后,实例的本地IP地址和主机名都可能不同。要解决此问题,您可以使用hostname命令的结果替换setenv.sh中的本地地址:
`hostname`
——请注意此处的反勾)

提示:如果在EC2上使用安全组,还应确保向同一安全组中的所有实例打开端口7800)

Liferay配置 通过将以下属性添加到您的portal-ext.properties,可以在Liferay上启用JGroups复制:

-Djava.net.preferIPv4Stack=true
-Djgroups.bind_addr=192.168.0.1
-Djgroups.tcpping.initial_hosts=192.168.0.1[7800],80.200.230.2[7800]
# Tells Liferay to enable Cluster Link. This sets up JGroups control and transport channels (necessary for indexes and cache replication)
cluster.link.enabled=true
# This external address is used to determine which network interface must be used. This typically points to the database shared between the instances.
cluster.link.autodetect.address=shareddatabase.eu-west-1.rds.amazonaws.com:5432
为单播TCP配置JGroups只需指向正确的文件:

# Configures JGroups control channel for unicast TCP
cluster.link.channel.properties.control=/custom_jgroups/tcp.xml
# Configures JGroups transport channel for unicast TCP
cluster.link.channel.properties.transport.0=/custom_jgroups/tcp.xml
在同一文件中,Lucene索引复制需要以下单个属性:

# Enable Lucene indexes replication through Cluster Link
lucene.replicate.write=true
EhCache缓存复制更微妙。必须为Hibernate缓存和Liferay的内部缓存配置JGroups。要了解此配置,您必须知道,自Liferay 6.2以来,默认的EhCache配置文件是“群集的”(不设置这些属性):

这些配置文件都依赖于必须设置为enable JGroups的EhCache工厂:

# Enable EhCache caches replication through JGroups
ehcache.bootstrap.cache.loader.factory=com.liferay.portal.cache.ehcache.JGroupsBootstrapCacheLoaderFactory
ehcache.cache.event.listener.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory
ehcache.cache.manager.peer.provider.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory
JGroups的缓存管理器对等提供程序工厂需要一个包含JGroups配置的
文件
参数。指定单播TCP配置文件:

# Configure hibernate cache replication for unicast TCP
net.sf.ehcache.configurationResourceName.peerProviderProperties=file=/custom_jgroups/tcp.xml

# Configure internal caches replication for unicast TCP
ehcache.multi.vm.config.location.peerProviderProperties=file=/custom_jgroups/tcp.xml
提示:如有疑问,应参考属性定义和默认值:)

调试 此外,您还可以通过以下方式启用调试跟踪:

cluster.executor.debug.enabled=true
您甚至可以告诉Liferay在每个页面上显示处理请求的节点的名称:

web.server.display.node=true
最后,JGroups通道公开了一个诊断服务,可通过

最后说明 请记住,这仅包括索引和缓存复制。在设置LIFELAY集群时,还应该考虑设置:

  • 共享数据库(AWS上的RDS)
  • 共享(AWS上的S3或RDS)
  • Tomcat上的会话复制
  • 也许更多取决于你如何使用Liferay

似乎
singleton\u name=“custom\u cache”
是一个非常重要的属性:)如果没有此设置,缓存复制将无法工作。谢谢分享!我认为这是一个更完整的答案,它帮助我解决了集群问题。谢谢您在列表中提到了tomcat会话复制。LR Portal不应该跨集群处理它吗?@HakunaM如前所述,Liferay的集群功能仅限于索引和缓存复制。此外,您可能希望也可能不希望在整个tomcat实例中启用会话复制,这取决于您的负载平衡策略。有关Liferay群集体系结构的更全面的视图,请参考Liferay知识库,例如。
web.server.display.node=true