Solr锁机制

Lucene索引,然后让solr能及时查询到lucene做的索引方案:

 

1、Lucene索引。(先删除锁)

while (IndexWriter.isLocked(directory) )

{

      IndexWriter.unlock(directory);

}

 

2、solr提交数据后有一个reopen索引操作,lucene虽然做了索引,但是solr并没有进行这个动作,所以要调用solr手动来实现。(这边无法调用删除锁的接口)

http://localhost:8081/solr/admin/cores?action=RELOAD&core=event

 

3、lucene调用indexWrite.close();包括解锁(删除write.lock)和释放。

 

 

 

 

1、 修改solrconfig.xml中的配置文件:

<unlockOnStartup>true</unlockOnStartup>

将solrcore启动时不设置锁。

 

<lockType>${solr.lock.type:simple} </lockType>

提供了四种索引锁机制,single,native,simple,Defaults,默认是native,如果是Lucene索引,想要solr来识别,则要改为simple。

 

 single = SingleInstanceLockFactory - suggested for a

                  read-only index or when thereis no possibility of

                 another process trying tomodify the index.

 native = NativeFSLockFactory - uses OS native file locking.

                  Do not use when multiple solrwebapps in the same

                  JVM are attempting to share asingle index.

 simple = SimpleFSLockFactory  -uses a plain file for locking

 

  Defaults: 'native' is default for Solr3.6 andlater, otherwise

                   'simple' is the default

 

然后lucene中一定要释放该锁,native的锁lucene释放不了。

 

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sg_0504

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值