How to setup solr on production on ubuntu server with rails

时间:2017-06-15 10:31:43

标签: solr ruby-on-rails-5

I'm going to setup solr on ubuntu server on production mode. I'm using rails 5.1.1, solr 6.5.1.

I've been running into an error below:

$RAILS_ENV=production bundle exec rake sunspot:solr:reindex
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 404 Not Found
Error:     Not Found

URI: http://localhost:8983/solr/production/update?wt=json
Request Headers: {"Content-Type"=>"application/json"}
Request Data: "{\"delete\":{\"query\":\"type:Address\"}}"

Backtrace: /home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/rsolr-2.0.2/lib/rsolr/client.rb:195:in `rescue in execute'
/home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/rsolr-2.0.2/lib/rsolr/client.rb:185:in `execute'
/home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/rsolr-2.0.2/lib/rsolr/client.rb:180:in `send_and_receive'
/home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/sunspot_rails-2.2.7/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/activesupport-5.1.1/lib/active_support/notifications.rb:166:in `block in instrument'
/home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/activesupport-5.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/activesupport-5.1.1/lib/active_support/notifications.rb:166:in `instrument'
/home/deployer/apps/fpp/shared/bundle/ruby/2.4.0/gems/sunspot_rails-2.2.7/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'

And my sunspot.yml:

production:
  solr:
    hostname: localhost
    port: 8983
    log_level: WARNING
    path: /solr/production
    #solr_home: solr
    # read_timeout: 2
    # open_timeout: 0.5

development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr/development

test:
  solr:
    hostname: localhost
    port: 8981
    log_level: WARNING
    path: /solr/test

I've tried numerous other suggestions on SO but nothing seems to be fixing to my issue. I have no experience with sunspot so indepth answers are most welcome.

1 个答案:

答案 0 :(得分:0)

sunspot-solr 404错误通常是文件丢失的问题。

检查文件solr /#{ENV} /core.properties是否已正确复制。 每个环境的文件内容应为:

name=YOUR_ENV
configSet=sunspot
dataDir=./data

数据文件夹也应该存在于您的solr /#{ENV} /文件夹中。