1

I am running Solr-4.10.1 on Tomcat-7. I have placed the necessary schema.xml and solrconfig.xml in /usr/share/solr/data/test/conf, and created a new core using:

curl --request POST 'xx.xx.xx.xx:8080/solr/admin/cores' --data "action=CREATE&name=test&instanceDir=/usr/share/solr/data/test&config=solrconfig.xml&schema=schema.xml&dataDir=/usr/share/solr/data/test"

from the command line. I can then write to and read from the core, but when I restart Tomcat the core disappears.

I have read that putting persist=true into solr.xml fixes the issue, however I have also read that this is soon to be deprecated here and here:

The persistent attribute is no longer supported in solr.xml

Does anybody know how to persist cores for the newest versions of Solr?

Edit:

Here are the contents of my solr.xml located at /etc/tomcat7/Catalina/localhost/solr.xml.

<Context docBase="/usr/share/solr/example/multicore/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr/example/multicore" override="true" />
</Context>
4
  • What style solr.xml are you using? The one that does core auto-discovery or the old-style one that lists every core? Oct 22, 2014 at 20:13
  • I have added the contents of my solr.xml to the post. Note that these are the defaults as created during the installation steps followed from webikon.com/cases/…
    – peter-b
    Oct 23, 2014 at 9:38
  • 1
    That's not the right solr.xml. That's the tomcat definition to find solr's webapp. You should have another one in your solr home: /usr/share/solr/example/multicore in your case. Oct 23, 2014 at 18:31
  • Ah, I see. Thanks very much for the help. Based on your help I've posted what is now the answer should others come across this issue with the new-style config.
    – peter-b
    Oct 28, 2014 at 7:26

2 Answers 2

3

Solution:

The default solr.xml for Tomcat indicated that Solr was using /usr/share/solr/example/multicore as the data directory, not where I had put my new cores. I changed /etc/tomcat7/Catalina/localhost/solr.xml to point at my new data directory at /usr/share/solr/data:*

<Context docBase="/usr/share/solr/example/multicore/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr/data" override="true" />
</Context>

In my new data directory I created a new solr.xml with the following contents, which I copied from the example provided with the installation at /usr/share/solr/example/solr/solr.xml (comments trimmed here). It is all default boilerplate.

<?xml version="1.0" encoding="UTF-8" ?>
<solr>

  <solrcloud>
    <str name="host">${host:}</str>
    <int name="hostPort">${jetty.port:8983}</int>
    <str name="hostContext">${hostContext:solr}</str>
    <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
    <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
  </solrcloud>

  <shardHandlerFactory name="shardHandlerFactory"
    class="HttpShardHandlerFactory">
    <int name="socketTimeout">${socketTimeout:0}</int>
    <int name="connTimeout">${connTimeout:0}</int>
  </shardHandlerFactory>

</solr>

This is the new-style solr.xml, and so core discovery is on. See this link for more information.

Finally, I put an empty core.properties in the root of each core that I wanted to be discovered on reboot, e.g. at /usr/share/solr/data/mycore/core.properties. Cores now persist through Tomcat restarts.

Many thanks to @alexandre-rafalovitch for his help and pointing me in the right direction - see comments below the question.

*: A note for the observant: I have left solr.war in its original place as it is unrelated to the matter at hand.

0

My solr Application is running on jetty. I tried everything but nothing was working. Then I realized my application was created under "multicore" section. Tehn I tried 2 things: a. I modified my solr.xml (\example\multicore) as:

<solr persistent="true" sharedLib="lib">

b.I restarted my start.jar with

java -Dsolr.solr.home=multicore -jar start.jar

and it worked. Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.