Hibernate搜索、Infinispan和JGroups聚类

Hibernate搜索、Infinispan和JGroups聚类,hibernate,hibernate-search,infinispan,Hibernate,Hibernate Search,Infinispan,我们正试图在我们的项目中与Infinispan一起使用Hibernate搜索。我们查看了文档并尝试了最简单的配置,只是将Infinispan定义为提供者。在网络上的两台机器上启动应用程序(部署在Tomcat中)时,这两台机器上的索引会分别更新,但机器之间没有通信 这是我的配置。 我们使用默认的tcp通信。有什么不对劲吗 <?xml version="1.0" encoding="UTF-8"?> <infinispan xmlns:xsi="http://www.w3.org/

我们正试图在我们的项目中与Infinispan一起使用Hibernate搜索。我们查看了文档并尝试了最简单的配置,只是将Infinispan定义为提供者。在网络上的两台机器上启动应用程序(部署在Tomcat中)时,这两台机器上的索引会分别更新,但机器之间没有通信

这是我的配置。 我们使用默认的tcp通信。有什么不对劲吗

<?xml version="1.0" encoding="UTF-8"?>
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:7.0 http://www.infinispan.org/schemas/infinispan-config-7.0.xsd
                    urn:infinispan:config:store:jdbc:7.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-7.0.xsd"
xmlns="urn:infinispan:config:7.0"
xmlns:jdbc="urn:infinispan:config:store:jdbc:7.0">

<!-- *************************** -->
<!-- System-wide global settings -->
<!-- *************************** -->
<jgroups>
    <!-- Note that the JGroups transport uses sensible defaults if no configuration
        property is defined. See the JGroupsTransport javadocs for more flags.
        jgroups-udp.xml is the default stack bundled in the Infinispan core jar: integration
        and tuning are tested by Infinispan. -->
  <stack-file name="default-jgroups-tcp" path="default-configs/default-jgroups-tcp.xml" />
</jgroups>

<cache-container name="HibernateSearch" default-cache="default" statistics="false" shutdown-hook="DONT_REGISTER">

    <transport stack="default-jgroups-tcp" cluster="venkatcluster"/>

    <!-- Duplicate domains are allowed so that multiple deployments with default configuration
        of Hibernate Search applications work - if possible it would be better to use JNDI to share
        the CacheManager across applications -->
    <jmx duplicate-domains="true" />

     <!-- *************************************** -->
     <!--  Cache to store Lucene's file metadata  -->
     <!-- *************************************** -->
     <replicated-cache name="LuceneIndexesMetadata" mode="SYNC" remote-timeout="25000">
        <transaction mode="NONE"/>
        <state-transfer enabled="true" timeout="480000" await-initial-transfer="true" />
        <indexing index="NONE" />
        <locking striping="false" acquire-timeout="10000" concurrency-level="500" write-skew="false" />
        <eviction max-entries="-1" strategy="NONE"/>
        <expiration max-idle="-1"/>
        <persistence passivation="false">
            <jdbc:string-keyed-jdbc-store preload="true" fetch-state="true" read-only="false" purge="false">
                <property name="key2StringMapper">org.infinispan.lucene.LuceneKey2StringMapper</property>
                <jdbc:connection-pool connection-url="jdbc:mysql://192.168.2.15:3306/entityindex" driver="com.mysql.jdbc.Driver" password="pf_user1!" username="pf_user"></jdbc:connection-pool>
                <jdbc:string-keyed-table drop-on-exit="false" create-on-start="true" prefix="ISPN_STRING_TABLE">
                    <jdbc:id-column name="ID" type="VARCHAR(255)"/>
                    <jdbc:data-column name="DATA" type="BLOB"/>
                    <jdbc:timestamp-column name="TIMESTAMP" type="BIGINT"/>
                </jdbc:string-keyed-table>
            </jdbc:string-keyed-jdbc-store>
        </persistence>
     </replicated-cache>

     <!-- **************************** -->
     <!--  Cache to store Lucene data  -->
     <!-- **************************** -->
     <distributed-cache name="LuceneIndexesData" mode="SYNC" remote-timeout="25000">
        <transaction mode="NONE"/>
        <state-transfer enabled="true" timeout="480000" await-initial-transfer="true" />
        <indexing index="NONE" />
        <locking striping="false" acquire-timeout="10000" concurrency-level="500" write-skew="false" />
        <eviction max-entries="-1" strategy="NONE"/>
        <expiration max-idle="-1"/>
        <persistence passivation="false">
            <jdbc:string-keyed-jdbc-store preload="true" fetch-state="true" read-only="false" purge="false">
                <property name="key2StringMapper">org.infinispan.lucene.LuceneKey2StringMapper</property>
                <jdbc:connection-pool connection-url="jdbc:mysql://192.168.2.15:3306/entityindex" driver="com.mysql.jdbc.Driver" password="pf_user1!" username="pf_user"></jdbc:connection-pool>
                <jdbc:string-keyed-table drop-on-exit="false" create-on-start="true" prefix="ISPN_STRING_TABLE">
                    <jdbc:id-column name="ID" type="VARCHAR(255)"/>
                    <jdbc:data-column name="DATA" type="BLOB"/>
                    <jdbc:timestamp-column name="TIMESTAMP" type="BIGINT"/>
                </jdbc:string-keyed-table>
            </jdbc:string-keyed-jdbc-store>
        </persistence>
     </distributed-cache>

     <!-- ***************************** -->
     <!--  Cache to store Lucene locks  -->
     <!-- ***************************** -->
    <replicated-cache name="LuceneIndexesLocking" mode="SYNC" remote-timeout="25000">
        <transaction mode="NONE"/>
        <state-transfer enabled="true" timeout="480000" await-initial-transfer="true" />
        <indexing index="NONE" />
        <locking striping="false" acquire-timeout="10000" concurrency-level="500" write-skew="false" />
        <eviction max-entries="-1" strategy="NONE"/>
        <expiration max-idle="-1"/>
        <persistence passivation="false">
            <jdbc:string-keyed-jdbc-store preload="true" fetch-state="true" read-only="false" purge="false">
                <property name="key2StringMapper">org.infinispan.lucene.LuceneKey2StringMapper</property>
                <jdbc:connection-pool connection-url="jdbc:mysql://192.168.2.15:3306/entityindex" driver="com.mysql.jdbc.Driver" password="pf_user1!" username="pf_user"></jdbc:connection-pool>
                <jdbc:string-keyed-table drop-on-exit="false" create-on-start="true" prefix="ISPN_STRING_TABLE">
                    <jdbc:id-column name="ID" type="VARCHAR(255)"/>
                    <jdbc:data-column name="DATA" type="BLOB"/>
                    <jdbc:timestamp-column name="TIMESTAMP" type="BIGINT"/>
                </jdbc:string-keyed-table>
            </jdbc:string-keyed-jdbc-store>
        </persistence>
    </replicated-cache>

</cache-container>

org.infinispan.lucene.LuceneKey2StringMapper
org.infinispan.lucene.LuceneKey2StringMapper
org.infinispan.lucene.LuceneKey2StringMapper

您可能需要对本地网络配置或JGroups配置文件进行一些调整

Infinispan附带的默认配置在大多数情况下都是开箱即用的,但无法确保这一点:网络可以以多种不同的方式设置

我建议首先在环回网络上测试这个问题,在同一台机器上运行两个Tomcat实例,确保可以先让它工作

设置基于JGroups的集群的一个有用步骤是首先运行一个JGroups演示;它们非常简单,可能有助于确认您的基本配置是否正常

运行JGroups演示 JGroups jar包含一些简单的演示。它不需要任何依赖项,因此很容易直接从命令行运行

有关几个示例,请参见

使用JGroups演示测试您的自定义配置 在多台计算机上运行演示后,使用它测试自定义配置文件

注意:您可能需要调整一些网络路由选项,例如,许多系统没有合理的多播IP默认值


还要检查数据包必须通过的网络跳数。在JGroups配置文件中,您会发现ip_ttl设置,如果不够高,您的数据包将在到达目的地之前被路由器丢弃。

您可能需要对本地网络配置或JGroups配置文件进行一些调整

Infinispan附带的默认配置在大多数情况下都是开箱即用的,但无法确保这一点:网络可以以多种不同的方式设置

我建议首先在环回网络上测试这个问题,在同一台机器上运行两个Tomcat实例,确保可以先让它工作

设置基于JGroups的集群的一个有用步骤是首先运行一个JGroups演示;它们非常简单,可能有助于确认您的基本配置是否正常

运行JGroups演示 JGroups jar包含一些简单的演示。它不需要任何依赖项,因此很容易直接从命令行运行

有关几个示例,请参见

使用JGroups演示测试您的自定义配置 在多台计算机上运行演示后,使用它测试自定义配置文件

注意:您可能需要调整一些网络路由选项,例如,许多系统没有合理的多播IP默认值


还要检查数据包必须通过的网络跳数。在JGroups配置文件中,您会发现ip#ttl设置,如果不够高,您的数据包将在到达目的地之前被路由器丢弃。

未正确群集的第一个原因是双堆栈计算机上的配置。请尝试设置-Djava.net.preferIPv4Stack=true不能正确集群的#1原因是双堆栈计算机上的配置。尝试设置-Djava.net.preferIPv4Stack=trueNow数据正在系统间同步。我发现当多人访问系统时,索引会被删除,这可能是个问题。现在数据在系统之间同步。我发现当多人访问系统时,索引会被删除,这可能是个问题。