18

I have setup a SolrCloud replication using standalone zookeeper. But now I wish to make some changes to my Schema.xml and reload the core. The problem is that when I run a single server Solr (no solrcloud) the new schema is loaded, but I do not know how to reload schema on all the replication server. I tried reloading the schema on one of the server with no desired impact. Is there a way in which I can reload my schema.xml in Solr in distributed replication setup which uses zookeeper.

freedev
  • 25,946
  • 8
  • 108
  • 125
Global Warrior
  • 5,050
  • 9
  • 45
  • 75

4 Answers4

27

Just found the solution we need to push the changed configuration to zookeeper ensemble.

Just use

sh zkcli.sh -cmd upconfig -zkhost  127.0.0.1:2181  -collection collection1 -confname myconf -solrhome ../solr -confdir ../solr/collection1/conf

zkcli.sh is present under example/cloud-scripts

freedev
  • 25,946
  • 8
  • 108
  • 125
Global Warrior
  • 5,050
  • 9
  • 45
  • 75
  • 1
    You have `-confdir ../solr/collection1/conf` twice. – zengr Jun 25 '13 at 06:33
  • Is that all? You don't need to reload the nodes or the collection? As soon as it's uploaded it's in use across the collection? – johnnyboy Mar 25 '14 at 21:42
  • 1
    If zkcli.sh or zkcli.bat gives the error "Error: Could not find or load main class org.apache.solr.cloud.ZkCLI" it might be because Solr hasn't been run on that machine yet; maybe you installed it but haven't run it and want to use it to talk to other SolrCloud nodes. Easy fix: cd solr-4.8.0/example, java -jar start.jar, (let it start up), Control-C. You'll now have files under solr-4.8.0-bin/example/solr-webapp/webapp including the missing jars in solr-4.8.0-bin/example/solr-webapp/webapp/WEB-INF/lib – Mark Bennett May 16 '14 at 19:10
  • @johnnyboy yes I believe you'll want to run http://localhost:8983/solr/admin/collections?action=RELOAD&name=mycollection either in a browser or with curl. – Mark Bennett May 16 '14 at 19:11
  • The -collection parameter is not used with the upconfig command. https://cwiki.apache.org/confluence/display/solr/Command+Line+Utilities – KoichiSenada Sep 03 '14 at 09:21
  • @GlobalWarrior Should we need to install any third-party tool to manage ZooKeeper? Because when I'm running this command, It gives error like `opening socket connection to server will not attempt to authenticate using sasl` or `could not connect to ZooKeeper 127.0.0.1:8983 within 30000 ms`. – immayankmodi Apr 06 '15 at 09:01
  • @MMTac Make sure that the machine can talk with each other on the port specified, I guess its 2181. According to your error its trying to connect zookeeper on 8983, is that correct? Is zookeeper running on 8983 on your local machine? – Global Warrior Apr 06 '15 at 12:20
  • @GlobalWarrior Actually I don't know anything. I have just install Solr5 and created new core in cloud mode. After that I changed config file, now I want to upload that change in cloud. I also think it's default to `2181`, but still not able to connect with same error. Should I need to allow that from firewall or anything else to run it? – immayankmodi Apr 06 '15 at 12:26
  • @MMTac you are trying to connect to zookeeper at 8983 please check your configuration and have you even started a zookeper cluster? – Global Warrior Apr 06 '15 at 15:28
  • @GlobalWarrior nope. I even don't know how to start and work with zookeeper cluster. Can you guide me or provide link how to do it? Thanks! – immayankmodi Apr 06 '15 at 18:03
  • I don't know but my zookeeper directory is /ranger_audits and everything is stored in there. Kindly can you let me know where I can mention zookeeper's Path? – Murtaza Kanchwala Jan 17 '17 at 07:30
9

The answer marked as correct is wrong. You have to use Solr Collection API

Once you have uploaded the new collection (index) configuration with the Solr zkcli.sh utility the configuration will not be reloaded automatically.

Solr Collection API are indicated for SolrCloud and the configuration reload will be spread in the whole cluster. As far as I know Solr Collection API are available at least from Solr 4.8.

The procedure is slightly different and with these API you can reload the configuration on the entire Cluster with only one API call.

Just upload your updated configuration with the Solr zkcli.sh utility. Pay attention to do not confuse Solr zkcli.sh with Zookeeper zkCli.sh they have quite the same name but completely different purpose.

So as said use Solr zkcli.sh (At time of writing is in the directory server/scripts/cloud-scripts):

./zkcli.sh -cmd upconfig -zkhost 127.0.0.1:2181 -collection collection1 -confname myconf -confdir path/to/solr/collection1/conf

Then you can reload the configuration of collection1 with:

http://server1:8983/solr/admin/collections?action=RELOAD&name=collection1

The entire cluster will be updated.

freedev
  • 25,946
  • 8
  • 108
  • 125
  • And what is the difference to the accepted answer by Global Warrior? – Jack Miller Jan 19 '18 at 16:01
  • 1
    @JackMiller The question is related to SolrCloud (probably a cluster). Given that the term `core` is used to refer to a single index on a Solr instance and, on the other hand, a `collection` is a complete logical index in a SolrCloud cluster. Using the [Solr Collection API](https://cwiki.apache.org/confluence/display/solr/Collections+API) the configuration reload will be spread through the entire cluster and not only in current instance. So always use the collections API, no matter how big is your Solr architecture (for example with multiple shards and/or replicas). – freedev Jan 19 '18 at 16:12
  • Okay, finally found it: It must be *collections* in the URL instead of *cores*. Yes, that is an important difference but you could make it clearer where the actual difference in your answer is. The first part *zkcli ... upconfig* is completely identical. – Jack Miller Jan 21 '18 at 14:13
2

This worked for me :

    bin/solr zk -upconfig -n collectionName -d pathto/Conf_directory -z localhost:2181/solr
Tarun Reddy
  • 89
  • 1
  • 3
  • With ´solr zk upconfig´ reloading the cores seems to become unnecessary. Can't find any documentation about it though. – Jack Miller Jan 19 '18 at 16:02
1

Below is the Command for Windows,

IT will be almost same in Unix we just need to change the path of Solr lib and class-path separator ; & : Because its java command so should run in Unix also.

java  -Dlog4j.configuration="file:E:/solr-5.5.1/server/scripts/cloud-scripts/log4j.properties" -classpath .;E:/solr-5.5.1/server/solr-webapp/webapp/WEB-INF/lib/*;E:/solr-5.5.1/server/lib/ext/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 192.168.42.13:2787 -confdir E:/New_Solor_Conf -confname Solor_conf

Brief details about command as follows:

Configuration of log4j for logging.

  • -Dlog4j.configuration="file:E:/solr-5.5.1/server/scripts/cloud-scripts/log4j.properties

Class path to run "org.apache.solr.cloud.ZkCLI". class.

make sure UNIX and Windows will have different : (Unix seperator) ;(Windows Separator)

  • -classpath .;E:/solr-5.5.1/server/solr-webapp/webapp/WEB-INF/lib/;E:/solr-5.5.1/server/lib/ext/
  • -zkhost 192.168.42.13:2787 (Remote Host and port where Solr Zookeeper is running)
  • -confdir E:/New_Solor_Conf (Local directory what we need to upload.)
  • -confname Solor_conf Remote instance name.

If you will not use correct class path you will get error like :

  Error: Could not find or load main class org.apache.solr.cloud.ZkCLI

or

 Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFacto
    ry
            at org.apache.solr.common.cloud.SolrZkClient.<clinit>(SolrZkClient.java:
    71)
            at org.apache.solr.cloud.ZkCLI.main(ZkCLI.java:183)
    Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
            at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

I am able to upload my local configuration changes without physically login to remote Solr box. Hope it will work for other also.

Gautam
  • 3,707
  • 5
  • 36
  • 57