首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用JGroups实现Hibernate搜索、无限搜索和集群

使用JGroups实现Hibernate搜索、无限搜索和集群
EN

Stack Overflow用户
提问于 2017-06-08 06:49:32
回答 1查看 627关注 0票数 0

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

这是我的配置。我们使用默认的tcp通信。会出什么问题呢?

代码语言:javascript
复制
<?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>

EN

回答 1

Stack Overflow用户

发布于 2017-06-08 19:13:23

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

Infinispan中包含的默认配置在大多数情况下都是为开箱即用而设计的,但无法确保这一点:网络可以通过许多不同的方式进行设置。

我建议首先在环回网络上测试,在同一台机器上运行两个Tomcat实例,确保您可以首先使其工作。

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

运行JGroups演示

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

有关几个示例,请参阅the JGroups documentation

使用JGroups演示测试您的自定义配置

在多台机器上运行演示后,可以使用它来测试自定义配置文件。

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

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44423972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档