gpt4 book ai didi

ruby-on-rails - 轮胎/ Elasticsearch 远程服务器连接错误

转载 作者:行者123 更新时间:2023-12-02 22:16:20 25 4
gpt4 key购买 nike

我已经安装了带有 elasticsearch 的 ubuntu 12.04 远程服务器。

我已经安装了 elasticsearch:

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"
}

我可以重新启动、启动和停止 elasticearhc 服务器。

sudo service elasticsearch restart
* Stopping ElasticSearch Server [ OK ]
* Starting ElasticSearch Server [ OK ]

我在 config/initializer/ 文件夹中有一个 tire.rb 文件,其中包含以下代码:

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]
#
#

我已经将 tire.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)

我做错了什么?如何修复 tire/rails 应用和我的 elasticsearch 服务器之间的连接?

最佳答案

我认为你的 config/initializers/tire.rb 中的语法有误,见下文

Tire.configure do
url "http://localhost:9200"
#you can uncomment the next line if you want to see the elasticsearch queries in their own seperate log
#logger "#{Rails.root}/log/es.log"
end

关于ruby-on-rails - 轮胎/ Elasticsearch 远程服务器连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15851113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com