生产服务器上的 Sunspot / Solr

Sunspot / Solr on production server

刚刚从 Sphinx 转移到 Solr / Sunspot Gem Rails, 在生产服务器上使用 gem 'sunspot_solr' 和 RAILS_ENV=production rake sunspot:solr:start to 运行 Solr。

创建索引一整天后,早上所有索引都消失了,没有错误,也没有任何关于发生的事情的日志。第二天也一样。

经过一番研究,我注意到了这一点:

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

我怀疑 "rake sunspot:solr:start" 仅用于开发,数据不持久。但是有很多教程使用这种方式在没有 Tomcat.

的生产服务器上启动 Solr

在生产环境中设置 Solr 的正确方法是什么,我必须使用 Tomcat,还是 "rake sunspot:solr:start" 是启动 Solr 的正确方法。

我很困惑,感谢任何帮助。

有一个 whole page on the community wiki dedicated to taking Solr to production,其中包含初始化脚本等示例,如果您的发行版没有提供它们(或者 运行 在 Windows 下)。

最简单的方法是使用bin/install_solr_service.sh脚本:

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.

这使用受支持的 Jetty 与 Solr 捆绑版本,并将其正确设置为服务器上的服务。

在Windows下目前推荐的方式是使用NSSM