Вопрос

I'm trying to get Solr 4.8 running under Tomcat 7 on a Ubuntu 12.04 server, that will be accessed from a Rails 4 app using the sunspot_rails gem.

For now I'm just testing with the multicore example from Solr 4.8 to verify that it's working with the default configuration.

Tomcat is running fine (curl localhost:8080 returns the "It's working"-page), and I can't see any errors in the Tomcat or Solr logs. But curl localhost:8080/solr doesn't return anything, and curl localhost:8080/solr/update returns The requested resource (/solr/update) is not available.. (I'm using curl on localhost since I'm unable to access the Tomcat 7 admin or Solr Admin remotely).

I've copied the solr.war file from the example over to multicore and also all the jar files and log4j.properties into tomcat7/lib (basically just followed the instructions here but for 4.8 of course http://gagannaidu.blogspot.no/2014/02/apache-solr-461-tomcat7-setup-on-ubuntu.html):

sudo cp /usr/share/solr/example/webapps/solr.war /usr/share/solr/example/multicore/solr.war

sudo cp -r solr/example/lib/ext/* /usr/share/tomcat7/lib

sudo cp -r solr/example/resources/log4j.properties /usr/share/tomcat7/lib

I've also set the owner of the multicore folder to tomcat7:

sudo chown -R tomcat7 /usr/share/solr/example/multicore

Here are my config files:

solr.xml in /var/lib/tomcat7/conf/Catalina/localhost:

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

solr.xml in /usr/share/solr/example/multicore:

<solr persistent="false">
  <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
    <core name="core0" instanceDir="core0" />
    <core name="core1" instanceDir="core1" />

    <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
      <str name="urlScheme">${urlScheme:}</str>
    </shardHandlerFactory>
  </cores>
</solr>

I've tried changing the hostPort to "${jetty.port:8080}" or just "8080" but that doesn't seem to help.

Anyone know what I can do to get this working?

Это было полезно?

Решение

Ok, finally got it working here.

Here's what I did:

1) I downloaded Solr 4.8 again, untar'ed and moved to /usr/share/solr.

2) I copied solr.war into the solr example instead of the multicore example:

sudo cp /usr/share/solr/example/webapps/solr.war /usr/share/solr/example/solr/solr.war

3) I then copied the jar and log files:

sudo cp -r solr/example/lib/ext/* /usr/share/tomcat7/lib
sudo cp -r solr/example/resources/log4j.properties /usr/share/tomcat7/lib

4) I set the log path in /usr/share/tomcat7/lib/log4j.properties to (and then created the file):

solr.log=/usr/share/solr

touch solr.log

(inside /usr/share/solr/)

5) I put the following in solr.xml in /var/lib/tomcat7/conf/Catalina/localhost:

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/usr/share/solr/example/solr/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr/example/solr" override="true" />
</Context>

6) I changed the hostPort to 8080 in /usr/share/solr/example/solr/solr.xml:

<int name="hostPort">8080</int>

7) Finally I set the user **tomcat7 as the owner of the /usr/share/solr folder:

sudo chown -R tomcat7 /usr/share/solr

This can probably be cleaned up a bit, removing unneccessary files and examples from the Solr distribution, but at least it got me up and running.

For those wanting to use it with the sunspot_rails gem then you need to replace the schema.xml file inside /usr/share/solr/example/solr/collection1/conf with the one from your Rails-project, and do something like this for your sunspot.yml file:

production:
  solr:
    hostname: localhost
    port: 8080
    log_level: WARNING
    path: /solr

UPDATE:

Adding my complete solr.xml file for reference:

<solr>

  <solrcloud>
    <str name="host">${host:}</str>
    <int name="hostPort">8080</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>

Другие советы

I am also using the same thing and with same website reference, even I also have the same problem because solr.xml should not be in "/var/lib/tomcat7/conf/Catalina/localhost:"

copy solr.xml to "/usr/share/tomcat7/conf/Catalina/localhost" and restart apache tomcate and try again

hope this will work for you

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top