Search code examples
ruby-on-railsrubytomcatsolrsunspot

Sunspot / Solr on production server


Just moved from Sphinx to Solr / Sunspot Gem for Rails, was using gem 'sunspot_solr' with RAILS_ENV=production rake sunspot:solr:start to run Solr on production server.

After whole day of indexing, in the morning all indexes disappear was lost, without error or any log about what happened. Same happened next day.

After some research i noticed this:

Sunspot comes with a prepackaged instance of Solr, which makes it easy to get started in development mode. This will store the index data in your operating system’s temporary directory

I suspect that "rake sunspot:solr:start" is used for development only and that data is not persistent. But there a lots of tutorials that use this way to start Solr on production server without Tomcat.

What is the correct way of setting up Solr on production, do i have to use Tomcat, or "rake sunspot:solr:start" is a proper way of starting Solr.

Im confused , any help is appreciated.


Solution

  • There's a whole page on the community wiki dedicated to taking Solr to production with examples of init scripts etc. if your distribution doesn't provide them (or running under Windows).

    The easiest way is to use the bin/install_solr_service.sh script:

    Solr includes a service installation script (bin/install_solr_service.sh) to help you install Solr as a service on Linux. Currently, the script only supports CentOS, Debian, Red Hat, SUSE and Ubuntu Linux distributions. Before running the script, you need to determine a few parameters about your setup. Specifically, you need to decide where to install Solr and which system user should be the owner of the Solr files and process.

    This uses the supported, bundled version of Jetty with Solr and sets it up properly as a service on your server.

    Under Windows the current recommended way is to use NSSM.