跨多个服务器共享休眠搜索索引

share hibernate-search indexes across multiple servers

目前我们的目标是对 2 个活动服务器进行负载平衡 50/50。

Java 应用程序在本地使用 hibernate 搜索,我已经集中了这个目录,所以两个服务器都使用相同的目录。

我想与多个服务器共享休眠索引 我已设置以下内容,因此 read/writefrom 服务器之间没有锁定 属性 名称="hibernate.search.default.locking_strategy" 值="none" 有谁知道这是否会成为问题?

我真的无法回答你的问题,但我想分享一些注意事项。

我们在多年的生产中使用了这种配置(没有自定义锁定策略)并且我们试验了很多问题(陈旧的 nfs 文件句柄、死锁和索引损坏)。

我们尝试使用 JMS 将所有索引更新操作推迟到单个服务器,但即使在这种模式下,我们也遇到了一些问题(但是比在许多服务器上进行更新操作的模式要少得多)

另请注意,将索引文件放在 NFS 上是 strongly discouraged

我们终于放弃了hibernate search,对于分布式索引我个人建议使用elastic search。

然而,这在理论上是可行的,如那里所述:https://docs.jboss.org/hibernate/search/5.1/reference/en-US/html/search-architecture.html#_lucene

This mode targets non clustered applications, or clustered applications where the Directory is taking care of the locking strategy.

我真的不知道 "Directory" 应该如何处理锁定策略

之前使用的关于休眠搜索的数据源配置:

<!-- hibernate search configuration -->
            <!-- index root folder location -->
            <prop key="hibernate.search.default.indexBase">${env.ftindex.location.root}/${datasource.database}/${ftindex.folder}</prop>
            <!-- global analyzer -->
            <prop key="hibernate.search.analyzer">custom_analyzer</prop>
            <!-- asynchronous indexing for performance considerations -->
            <prop key="org.hibernate.worker.execution">async</prop>
            <!-- max number of indexing operation to be processed asynchronously (before session flush) to avoid OutOfMemoryException -->
            <prop key="hibernate.search.worker.buffer_queue.max">100</prop>