Search code examples
solrsolrcloud

SolrCloud election leader


I would like to use SolrCloud (Solr4.10.3 ).. I follow this wiki(Example B: https://wiki.apache.org/solr/SolrCloud#Example_B:_Simple_two_shard_cluster_with_shard_replicas )

SolrCloud uses leaders and an overseer as an implementation detail. This means that some nodes/replicas will play special roles. You don't need to worry if the instance you kill is a leader or the cluster overseer - if you happen to kill one of these, automatic fail over will choose new leaders or a new overseer transparently to the user and they will seamlessly takeover their respective jobs. Any Solr instance can be promoted to one of these roles.

When I stop the first instance where i run the zookeeper, i can't get another leader.

I get this Info in the same node(Example2 log file) :

INFO  - 2015-03-03 11:35:39.508; org.apache.solr.cloud.OverseerElectionContext; I am going to be the leader 192.168.1.38:7574_solr
INFO  - 2015-03-03 11:35:39.548; org.apache.solr.common.cloud.SolrZkClient; makePath: /overseer_elect/leader
INFO  - 2015-03-03 11:35:39.576; org.apache.solr.cloud.Overseer; Overseer (id=93413623381032961-192.168.1.38:7574_solr-n_0000000001) starting
WARN  - 2015-03-03 11:35:39.957; org.apache.zookeeper.ClientCnxn$SendThread;    
Session 0x14bdf320ecf0001 for server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:9983,    
unexpected error, closing socket connection and attempting reconnect
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:68)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:366)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
INFO  - 2015-03-03 11:35:40.064; org.apache.solr.common.cloud.ConnectionManager; Watcher org.apache.solr.common.cloud.ConnectionManager@1537a92 name:ZooKeeperConnection Watcher:localhost:9983 got event WatchedEvent state:Disconnected type:None path:null path:null type:None
INFO  - 2015-03-03 11:35:40.064; org.apache.solr.common.cloud.ConnectionManager; zkClient has disconnected

In other Node (Example2B) i get that in the log file

INFO  - 2015-03-03 11:35:39.507; org.apache.solr.cloud.ShardLeaderElectionContext; Running the leader process for shard shard1
INFO  - 2015-03-03 11:35:39.553; org.apache.solr.cloud.ShardLeaderElectionContext; Checking if I (core=collection1,coreNodeName=core_node3) should try and be the leader.
INFO  - 2015-03-03 11:35:39.574; org.apache.solr.cloud.ShardLeaderElectionContext; My last published State was Active, it's okay to be the leader.
INFO  - 2015-03-03 11:35:39.578; org.apache.solr.cloud.ShardLeaderElectionContext; I may be the new leader - try and sync
WARN  - 2015-03-03 11:35:39.956; org.apache.zookeeper.ClientCnxn$SendThread; Session 0x14bdf320ecf0002 for server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:9983, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:68)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:366)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)

We can see in the the same instance, there is a call for election leader process but it failed.. i don't see the probleme.

How to get automatically another leader?

Is there a special config in my solr server?

How to force the election for another leader?

Thx!


Solution

  • config zookeeper(host : xxx.xxx.xxx.1):

    tickTime=2000
    initLimit=10
    syncLimit=5
    clientPort=2181
    server.1=127.0.0.1:2888:3888
    

    Start Solr1 (host : xxx.xxx.xxx.2)

    java -Dbootstrap_confdir=./solr/collection1/conf 
                     -Dcollection.configName=solr1 
                     -Dsolr.allow.unsafe.resourceloading=true 
                     -DzkHost=xxx.xxx.xxx.1:2181 
                     -DnumShards=2 
                     -jar start.jar
    

    Start Solr2 (host : xxx.xxx.xxx.3)

    java -Djetty.port=8900 -DzkHost=xxx.xxx.xxx.1:2181 -jar start.jar
    

    Close all firewall !