2017-06-07 60 views
0

我們正試圖在Infinispan中與我們的項目一起使用Hibernate Search。我們查看了文檔並嘗試了最簡單的配置,只是將Infinispan定義爲提供商。在網絡上的兩臺機器上啓動應用程序(部署在Tomcat中)時,兩臺機器上的索引都會單獨更新,但機器之間沒有通信。Hibernate搜索,Infinispan和使用JGroups羣集

這是我的配置。 我們使用默認的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> 

+0

未正確聚合的第一個原因是雙堆棧機器上的配置。嘗試設置-Djava.net.preferIPv4Stack = true –

回答

2

那麼很可能需要作出一些調整到您的本地網絡配置或到JGroups的配置文件。

Infinispan包含的默認配置旨在在大多數情況下可以開箱即用,但無法確保:網絡可以通過多種不同方式進行設置。

我建議首先在同一臺機器上運行兩個Tomcat實例在環回網絡上進行測試,確保可以先完成這項工作。

設置基於JGroups的羣集的一個有用步驟是首先運行其中一個JGroups演示;它們非常簡單,可能有助於確認您的基本配置是否正常。

運行JGroups演示

JGroups jar包含一些簡單的演示。它不需要任何依賴,所以很容易直接從命令行運行。

查看the JGroups documentation幾個例子。

測試使用的JGroups演示

一旦你在多臺計算機上運行演示您的自定義配置,用它來測試您的自定義配置文件。

N.B.您可能需要調整一些網絡路由選項,例如許多系統沒有合理的多播IP默認值。

還要檢查數據包必須經過的網絡中的跳數。在JGroups的配置文件中,您會發現一個ip_ttl設置,如果它不夠高,您的數據包將在到達目的地之前被路由器丟棄。

+0

非常感謝。它正在工作。 – user1273969

+0

現在數據在系統之間進行同步。我看到,當多個人訪問系統時,索引正在被丟棄,這可能是問題所在。 – user1273969