solr replication原理探究
Posted cuihongyu3503319
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了solr replication原理探究相关的知识,希望对你有一定的参考价值。
无论是垂直搜索,还是通用搜索引擎,对外提供搜索服务其压力都比较大,经常有垂直电商在做活动的时候服务器宕机。对面访问压力比较大的情况,一般的应对方法就是【集群】+【负载均衡】。Solr提供了两种解决方案来对应访问压力。其一是Replication,其一是SolrCloud。
1. Replication的配置
2. replication的工作原理
2.1 slave端的运行过程
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
private void startExecutorService() { Runnable task = new Runnable() { @Override public void run() { if (pollDisabled.get()) { LOG.info( "Poll disabled" ); return ; } try { executorStartTime = System.currentTimeMillis(); replicationHandler.doFetch( null , false ); } catch (Exception e) { LOG.error( "Exception in fetching index" , e); } } }; executorService = Executors.newSingleThreadScheduledExecutor( new DefaultSolrThreadFactory( "snapPuller" )); long initialDelay = pollInterval - (System.currentTimeMillis() % pollInterval); executorService.scheduleAtFixedRate(task, initialDelay, pollInterval, TimeUnit.MILLISECONDS); LOG.info( "Poll Scheduled at an interval of " + pollInterval + "ms" ); } |
2.2 master端的运行过程
以上是关于solr replication原理探究的主要内容,如果未能解决你的问题,请参考以下文章