Sunspot的坑爹配置引起了围观

sunspot的Gem用的是

Gemfile
1
2
gem 'sunspot_rails', '2.1.1'
gem 'sunspot_solr', '2.1.1'
shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
user@xxxx:~/xxxxx/current$ RAILS_ENV=production bundle exec rake sunspot:reindex --trace

** Invoke sunspot:reindex (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute sunspot:reindex
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 404 Not Found
Error:     Not Found

Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:HaoSite</query></delete>"

Backtrace: /home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:283:in `adapt_response'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:190:in `execute'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:176:in `send_and_receive'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `block in instrument'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/activesupport-4.1.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `instrument'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:82:in `update'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:146:in `delete_by_query'/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:283:in `adapt_response'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:190:in `execute'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:176:in `send_and_receive'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `block in instrument'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/activesupport-4.1.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `instrument'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:82:in `update'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rsolr-1.0.10/lib/rsolr/client.rb:146:in `delete_by_query'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/indexer.rb:58:in `remove_all'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/session.rb:181:in `block in remove_all'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/session.rb:181:in `each'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/session.rb:181:in `remove_all'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/session_proxy/retry_5xx_session_proxy.rb:17:in `method_missing'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot.rb:464:in `remove_all'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:549:in `block in remove_all_with_trace_SolrClient_Sunspot_delete'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:281:in `trace_execution_scoped'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:544:in `remove_all_with_trace_SolrClient_Sunspot_delete'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/searchable.rb:183:in `solr_remove_all_from_index'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/searchable.rb:202:in `solr_reindex'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:57:in `block (4 levels) in <top (required)>'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/class_set.rb:16:in `each'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot-2.1.1/lib/sunspot/class_set.rb:16:in `each'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:56:in `block (3 levels) in <top (required)>'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:68:in `with_session'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:19:in `block (2 levels) in <top (required)>'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/task.rb:240:in `call'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/task.rb:240:in `block in execute'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/task.rb:235:in `each'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/task.rb:235:in `execute'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/xxxxxx/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/task.rb:165:in `invoke'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:150:in `invoke_task'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:106:in `each'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:106:in `block in top_level'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:115:in `run_with_threads'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:100:in `top_level'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:78:in `block in run'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:176:in `standard_exception_handling'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/lib/rake/application.rb:75:in `run'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/gems/rake-10.3.1/bin/rake:33:in `<top (required)>'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/bin/rake:23:in `load'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/bin/rake:23:in `<main>'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/bin/ruby_executable_hooks:15:in `eval'
/home/xxxxxx/.rvm/gems/ruby-2.1.0@xxxx/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => sunspot:reindex

production死活都报这个错!

解决方法:

vi config/sunspot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
production:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
    #Changing /solr/production to /solr/default fixes the problem for me.
    path: /solr/default #就是这一行,坑啊!
    # read_timeout: 2
    # open_timeout: 0.5  
development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr/development
vi config/sunspot.yml
1
2
3
4
5
6
7
8
ps aux | grep solr
kill -9 id   #solr杀死服务的进程
rm -r ./solr #删除rails下的目录

RAILS_ENV=production bundle exec rake sunspot:solr:start

#过几秒以后reindex
RAILS_ENV=production bundle exec rake sunspot:solr:reindex

ref:

原文地址:http://dlj.bz/h9VdTv

Comments