首页 \ 问答 \ SocketError(getaddrinfo:名称或服务未知) - Sunspot / Solr Rails开发(SocketError (getaddrinfo: Name or service not known) - Sunspot/Solr Rails development)

SocketError(getaddrinfo:名称或服务未知) - Sunspot / Solr Rails开发(SocketError (getaddrinfo: Name or service not known) - Sunspot/Solr Rails development)

我将Rails 3.0.10应用部署到Passenger,Capistrano,nginx和MySQL的Ubuntu 10.04服务器(以及更多的apache2问题)方面遇到了很多麻烦。 将rake降级到0.8.7后,终于可以正常工作了,但现在Sunspot / Solr在我的开发环境中不起作用。 sunspot_solr服务器正在运行,我可以获取服务器的url,并通过浏览器连接到它。 该网址与sunspot.yml中的相同。 我不知道我所做的事情是否会导致问题。 我之前在太阳黑子上遇到了同样的问题(在降级耙子之前)。 然后突然又开始工作了。 我不知道为什么...我尝试过两个版本的太阳黑子(1.2.1和1.3.0)。 两者都在早期工作,但现在不再了。

这是我收到的错误消息:

SocketError (getaddrinfo: Name or service not known):
app/models/resource.rb:128:in `text_search'
app/controllers/search_controller.rb:21:in `index'

Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.0ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (161.6ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (168.9ms)

控制器有点麻烦,所以我只包含相关部分:

@criterion = params[:criterion]
@sort_direction = params[:sort_direction]
if @criterion && @sort_direction
  session["sort_search"] = @criterion + "|" + @sort_direction 
elsif session["sort_search"]
  @criterion = session["sort_search"].split("|")[0]
  @sort_direction = session["sort_search"].split("|")[1]
else
  @criterion = "updated_at"
  @sort_direction = "desc"
 end
@search = Resource.text_search(session[:search_params] || "", current_user, @criterion, @sort_direction) 
@resources = @search.results

自从它工作以来,我没有改变控制器中的任何东西。

我的gemfile:

source 'http://rubygems.org'
gem 'rake'
gem 'rails', '3.0.10'
gem 'jquery-rails', '>= 1.0.12'
gem 'sqlite3'
gem 'ancestry'
gem 'carrierwave'
gem 'sunspot_rails', '>= 1.3' #'~> 1.2.1' #
gem 'authlogic'
gem 'will_paginate'
gem 'declarative_authorization'
group :production do
  gem 'mysql'
end
group :development do
  gem 'sunspot_solr'
end
gem 'capistrano'

我的rakefile:

require File.expand_path('../config/application', __FILE__)
require 'rake'

Skolearkivet::Application.load_tasks

I have had lots of trouble with deploying my rails 3.0.10 application to Ubuntu 10.04 server with Passenger, Capistrano, nginx and MySQL (and even more trouble with apache2). After downgrading rake to 0.8.7 it's finally working, but now Sunspot/Solr doesn't work in my development environment. The sunspot_solr server is running, and I am able to get the server's url, and connect to it via the browser. The url is the same as in sunspot.yml. I have no idea what I have done that can have caused the problem. I had the same problem with sunspot earlier (before I downgraded rake). Then it suddenly started working again. I don't know why... I have tried two versions of Sunspot (1.2.1 and 1.3.0). Both have been working earlier, but not anymore.

This is the error message I'm getting:

SocketError (getaddrinfo: Name or service not known):
app/models/resource.rb:128:in `text_search'
app/controllers/search_controller.rb:21:in `index'

Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.0ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (161.6ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (168.9ms)

The controller is a bit messy so I just include the relevant part:

@criterion = params[:criterion]
@sort_direction = params[:sort_direction]
if @criterion && @sort_direction
  session["sort_search"] = @criterion + "|" + @sort_direction 
elsif session["sort_search"]
  @criterion = session["sort_search"].split("|")[0]
  @sort_direction = session["sort_search"].split("|")[1]
else
  @criterion = "updated_at"
  @sort_direction = "desc"
 end
@search = Resource.text_search(session[:search_params] || "", current_user, @criterion, @sort_direction) 
@resources = @search.results

I have not changed anything in the controller since it was working.

My gemfile:

source 'http://rubygems.org'
gem 'rake'
gem 'rails', '3.0.10'
gem 'jquery-rails', '>= 1.0.12'
gem 'sqlite3'
gem 'ancestry'
gem 'carrierwave'
gem 'sunspot_rails', '>= 1.3' #'~> 1.2.1' #
gem 'authlogic'
gem 'will_paginate'
gem 'declarative_authorization'
group :production do
  gem 'mysql'
end
group :development do
  gem 'sunspot_solr'
end
gem 'capistrano'

My rakefile:

require File.expand_path('../config/application', __FILE__)
require 'rake'

Skolearkivet::Application.load_tasks

原文:https://stackoverflow.com/questions/9654350
更新时间:2022-04-26 16:04

最满意答案

我也遇到了这个问题。 诀窍是在puppet配置器运行之前使用vagrant shell命令下载模块。

config.vm.provision :shell do |shell|
  shell.inline = "mkdir -p /etc/puppet/modules;
                  puppet module install puppetlabs/nodejs;
                  puppet module install puppetlabs/apache"
end

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "puppet/manifests"
  puppet.manifest_file = "site.pp"
end

顺序在这里很重要,而且由于puppet provisioner没有运行该文件夹/ etc / puppet /模块还不存在。

我决定像alonisser一样使用puppet模块工具来安装模块,而不是使用流浪者puppet provisioner的模块文件夹,这是因为我不想下载所有将要使用的模块的依赖关系使用并将所有这些模块存储在我的源代码管理中。 运行这两个命令会产生5个依赖关系,否则这些依赖关系会占用我的git存储库占用的空间。


I ran into this problem as well. The trick is to download the modules using a vagrant shell command before the puppet provisioner runs.

config.vm.provision :shell do |shell|
  shell.inline = "mkdir -p /etc/puppet/modules;
                  puppet module install puppetlabs/nodejs;
                  puppet module install puppetlabs/apache"
end

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "puppet/manifests"
  puppet.manifest_file = "site.pp"
end

Order is important here, and since the puppet provisioner hasn't run the folder /etc/puppet/modules does not exist yet.

The reason I decided, like alonisser, to install the modules using the puppet module tool instead of using a module folder with the vagrant puppet provisioner was because I didn't want to have to download all of the dependencies of the modules I was going to use and store all of those modules in my source control. Running these two commands results in 5 dependencies that would otherwise sit in my git repository taking up space.

相关问答

更多
  • 我也遇到了这个问题。 诀窍是在puppet配置器运行之前使用vagrant shell命令下载模块。 config.vm.provision :shell do |shell| shell.inline = "mkdir -p /etc/puppet/modules; puppet module install puppetlabs/nodejs; puppet module install puppetlabs/apache" e ...
  • 对于我来说,检测升级是否会发生(并且如果是的话会停止实例)的理想方式是让我的木偶清单能够以某种方式调用存在方法。 这可能吗? 不,这是不可能的,至少不是以任何有用的方式。 您的清单描述如何构建描述机器目标状态的资源目录 。 在主/代理设置中,这发生在主设备上。 该目录然后被用作一个单独步骤的输入,在该步骤中将其转移到目标机器并在那里应用 。 正是在这第二步中,提供者才会参与其中。 如果希望目录的内容受目标机器当前状态的影响,则Puppet机制将以事实形式将所需的状态详细信息传递给目录生成器。 添加自己的事实 ...
  • 检查您是否正确配置了Vagrant: 必须启用Puppet配置 您可以尝试显式设置module_path 尝试将目录puppet-nginx重命名为nginx (或创建符号链接) Check that you configured Vagrant properly: provisioning with Puppet must be enabled you can try to set module_path explicitly try to rename directory puppet-nginx to ...
  • 它确实可以在Windows上使用! 您可以使用puppetlabs-vcsrepo模块 在Virtualbox中使用Windows 2012R2机器的屏幕截图,左侧命令行,右侧GUI。 示例中使用的代码: vcsrepo { 'C:\foo': ensure => present, provider => git, source => 'https://github.com/puppetlabs/puppetlabs-vcsrepo', } 为了使存储库保持最新版本,请将确保设置为“最 ...
  • 所以你想要的是在puppet apply的编译阶段打印的消息(还有一个目录应用程序阶段,但由于编译失败,这里没有达到)。 有一些解析器函数允许: 注意 警告 呃 暴击 EMERG 您可以在mymodule类主体的顶部添加: notice "evaluating mymodule ..." 等每个单独的模块。 The consensus seems to be: there isn't a way to easily do this! Oh well.
  • sudo cp -r ./finaldigi /etc/puppet/modules 这将创建/etc/puppet/modules/finaldigi和/etc/puppet/modules/finaldigi/manifests/init.pp ,但如果这是您正在使用的类名称,则该目录应该称为packagemodule 。 将其更改为: sudo cp -r ./finaldigi /etc/puppet/modules/packagemodule (如果这不起作用,请提供find /etc/pu ...
  • 更好的是指定您的依赖项: class pythontest { file { '/etc/puppetlabs/code/environments/production/modules/pythontest/': ensure => directory, mode => '0755', } file { '/etc/puppetlabs/code/environments/production/modules/pythontest/print.py': mode => ' ...
  • 在Ask PuppetLabs论坛上看起来有一个非常好的例子: 在清单中的hiera中迭代嵌套哈希 。 该解决方案使用运行您的exec的已定义类型 。 然后使用create_resources()自动迭代哈希, create_resources()将哈希转换为一组资源并将它们添加到目录中。 此功能可以轻松地立即从Hiera数据源创建许多资源,而不必编写自己的循环函数。 它最好与定义的类型一起使用,因为它们可以在很多不同的时间实现。 我已根据您的目的调整了他们的示例: define run_my_exec($ ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)