我已经安装了一个带有 elasticsearch 的 ubuntu 12.04 远程服务器。
我已经安装了弹性搜索:
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.6.deb
sudo dpkg -i elasticsearch-0.20.6.deb
sudo service elasticsearch start
我得到sudo elasticsearch status
:
* ElasticSearch Server is running with pid 2483
我的 elasticsearch 远程服务器工作正常:
ubuntu12@juan:~/Escritorio/myapp$ curl http:/111.111.111.111:9200
{
"ok" : true,
"status" : 200,
"name" : "Hogan, Harold \"Happy\"",
"version" : {
"number" : "0.20.6",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
或使用我的子域:
ubuntu12@juan:~/Escritorio/myapp$ curl http://elasticsearchserver.mydomain.com:9200
{
"ok" : true,
"status" : 200,
"name" : "Hogan, Harold \"Happy\"",
"version" : {
"number" : "0.20.6",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
我可以重新启动、启动和停止 elasticsearhc 服务器。
sudo service elasticsearch restart
* Stopping ElasticSearch Server [ OK ]
* Starting ElasticSearch Server [ OK ]
我tire.rb
在文件夹中有一个文件,config/initializer/
其中包含下一个代码:
if Rails.env == 'production'
Tire.configure do
url "http://elasticsearchserver.mydomain.com:9200"
end
end
这是我重新索引的 capistrano 任务:
after "deploy:finalize_update", "deploy:elasticsearch:index_classes"
namespace :deploy do
namespace :elasticsearch do
desc 'run elasticsearch indexing via tire'
task :index_classes do
run "cd #{deploy_to}/current && bundle exec rake environment tire:import CLASS=Object FORCE=true "
end
end
end
我使用 mongodb 作为数据库,所以在重新索引之前我没有进行迁移。
这是 capistrano 错误:
2013-04-06 14:25:50 executing `deploy:elasticsearch:index_classes'
#
#
** [out :: 111.111.111.111] Skipping index creation, cannot connect to Elasticsearch
** [out :: 111.111.111.111]
** [out :: 111.111.111.111] (The original exception was: #<Errno::ECONNREFUSED: Connection refused - connect(2)>)
** [out :: 111.111.111.111]
** [out :: 111.111.111.111] [IMPORT] Deleting index 'cvs'
** [out :: 111.111.111.111]
** [out :: 111.111.111.111] rake aborted!
** [out :: 111.111.111.111] Connection refused - connect(2)
** [out :: 111.111.111.111]
#
#
我已将轮胎.rb 文件上传到生产服务器,我尝试过:
bundle exec rake environment tire:import CLASS=Object FORCE=true
我得到相同的结果:
Skipping index creation, cannot connect to Elasticsearch
(The original exception was: #<Errno::ECONNREFUSED: Connection refused - connect(2)>)
[IMPORT] Deleting index objects'
rake aborted!
Connection refused - connect(2)
我究竟做错了什么?如何修复轮胎/导轨应用程序和我的弹性搜索服务器之间的连接?