当一个leader挂掉后,其中的几个replica 要重新选一个leader出来,但默认的是要等待3分钟,这个时间也太长了。对于开始在测试solrCloud功能来说,等待这么长时间,有可能觉得重新选举失败的挫败感。
这里4.1之后已解决了这个bug:https://issues.apache.org/jira/browse/SOLR-3940
默认情况下可以看到,当某个leader挂彩了时候,日志打印如下:
INFO: Waiting until we see more replicas up: total=3 found=1 timeoutin=171467 Dec 19, 2012 10:14:40 AM org.apache.solr.cloud.ShardLeaderElectionContext waitForReplicasToComeUp INFO: Waiting until we see more replicas up: total=3 found=1 timeoutin=170965 Dec 19, 2012 10:14:41 AM org.apache.solr.cloud.ShardLeaderElectionContext waitForReplicasToComeUp INFO: Waiting until we see more replicas up: total=3 found=1 timeoutin=170463 Dec 19, 2012 10:14:41 AM org.apache.solr.cloud.ShardLeaderElectionContext waitForReplicasToComeUp INFO: Waiting until we see more replicas up: total=3 found=1 timeoutin=169961
你可以只接受3分钟的等待,您也可以降低等待3分钟(如10秒或0秒)
配置选举等待时间:
在solr.xml上配置:
leaderVoteWait="${leaderVoteWait:20000}"
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
<cores defaultCoreName="video_shard1" adminPath="/admin/cores" zkClientTimeout="${zkClientTimeout:1500}" hostPort="${jetty.port:}" hostContext="solr" leaderVoteWait="${leaderVoteWait:20000}">
</cores>
</solr>