2012-12-13 26 views
1

我最近在我的亞馬遜EC2的機器上安裝SOLR,當我嘗試使用RAILS_ENV=production bundle exec rake sunspot:solr:start --trace啓動SOLR,我得到以下信息:不能EC2計算機上啓動SOLR - 沒有檢測寶石

** Invoke sunspot:solr:run (first_time) 
** Invoke sunspot:solr:moved_to_sunspot_solr (first_time) 
** Execute sunspot:solr:moved_to_sunspot_solr 

Note: This task has been moved to the sunspot_solr gem. 
To install, start and stop a local Solr instance, please add sunspot_solr to your Gemfile: 

group :development do 
    gem 'sunspot_solr' 
end 

不過,我已經已經包含在我的Gemfile sunspot_solr和我RAILS_ENV是生產(我也嘗試export RAILS_ENV=production任何提示,爲什麼SOLR將不會啓動,並一直嘗試發展運行我跟着這個鏈接進行安裝 - ?http://tanin.nanakorn.com/b/96/tomcat_and_solr_on_ec2

這是我的Gemf的一部分ILE:

group :development, :test do 
    gem 'factory_girl_rails' 
    gem "rspec-rails" 
    gem 'faker' 
    gem 'fuubar' 
    gem 'pry' 
    gem 'foreman' 
    gem 'guard-spork' 
    gem 'sunspot_solr' 
end 

我跑bundle install已經看到正在使用的寶石:

Using rsolr (1.0.8) 
Using sunspot (1.3.0) 
Using sunspot_rails (1.3.0) 
+0

您是否生成了太陽黑子配置文件?使用命令'rails generate sunspot_rails:install'運行安裝程序。如果問題仍然存在,請嘗試卸載並重新安裝太陽黑子。也只是爲了確認你的GemFile中的其他地方包含gem'sunspot_rails',對嗎? – Noz

+0

@CyleHunter我自己生成了xml配置文件。我試着運行'bundle exec rails generate sunspot_rails:install',但它引發了一些其他的mysql錯誤。 – Huy

回答

3

sunspot_solr寶石在你的Gemfile的:development組,當您指定RAILS_ENV=production Rails會忽略。寶石的主要目的是爲了便於開發和測試,並且不特別針對生產進行調整,因此文檔建議將其包含在:development組中。

如果您已按照鏈接的博客文章中描述的步驟操作,則實際上不需要使用Sunspot的捆綁Solr實例。在那篇文章的最後,你應該在你的服務器上運行一個Solr服務器。 (你必須仔細檢查Tomcat的配置,看看它運行在哪個端口上。)

如果我可能這麼大膽,你也可以考慮一個雲託管的Solr搜索,比如我自己的websolr.com。你應該能夠在幾分鐘內建立並運行索引。