【问题标题】:Ruby on Rails - Solr/Sunspot: Connection refused - connect(2)Ruby on Rails - Solr/Sunspot:连接被拒绝 - 连接 (2)
【发布时间】:2011-09-05 08:45:41
【问题描述】:

几乎我正在尝试部署一个使用 Sunspot 的 Rails 应用程序。我关注了https://github.com/outoftime/sunspot/wiki/Configure-Solr-on-Ubuntu,-the-quickest-way,但是在运行应用程序时,我得到以下信息:

连接被拒绝 - 连接(2)

这表明它无法正确访问服务器,我已经搜索并尝试了几个小时,但无济于事。

有什么想法吗?

【问题讨论】:

  • 此错误是因为 Sunspot 无法连接到它配置使用的服务器。你能分享你的sunspot.yml 文件吗?
  • 您可能还对提到我自己的服务WebsolrHosted full-text search solutions 感兴趣。
  • 生产环境的 sunspot.yml 中配置的端口是什么?

标签: ruby-on-rails solr tomcat6 passenger sunspot


【解决方案1】:

您可以尝试重新索引

$rake sunspot:solr:reindex RAILS_ENV=production

如果这不起作用,您可以...

$rm solr/pids/production/sunspot-solr-production.pid

...启动 solr

$rake sunspot:solr:start RAILS_ENV=production

...然后重新索引

$rake sunspot:solr:reindex RAILS_ENV=production

【讨论】:

    【解决方案2】:

    事实证明,在所有的故障排除之后,问题只是配置文件中的端口号(以某种抽出的方式)——即Sunspot.config.solr.url。 p>

    【讨论】:

    • Sunspot.config.solr.url = 'http://localhost:8983/solr' 添加到config/production.rb 也可以。
    【解决方案3】:

    谁能帮我搞定这个工作?

    $rake sunspot:solr:start RAILS_ENV=production$

    Setup sunspot solr with rails in production environment 表示确实如此简单。

    您能否具体说明您在尝试此操作时遇到的问题?或者是什么导致你不尝试?因为安装 solr/tomcat/etc 比键入那一行代码要多得多。

    如果您决定安装完整的 tomcat/solr,您还可以使用 http://internetmodulation.com/2011/01/10/sunspot-solr-tomcat-ubunut.html.html

    【讨论】:

      【解决方案4】:

      这个博客可能会解决你的问题:

      在 CentOS 中使用 Jetty 安装 Solr 4.4,并设置 Solr 服务器以使用 Sunspot Gem。 (http://blogs.pigrider.com/blogs/26)

      以下是博客的部分内容: ......

      8) 将此配置文件 schema.yml 从 Rails 应用程序复制到正在运行的 Solr 4.4 实例的主目录。它将覆盖那里的 Solr 示例配置文件,并将设置 Solr 4.4 服务器以与 Sunspot Gem 一起使用。 cp /RailsApplicationPath/Solr/conf/schema.yml /opt/solr/solr/collection1/conf/.

      正在运行的 Solr 4.4 实例的主目录是 /opt/solr/solr/collection1/。您可以从 Solr 管理页面 http://l o c a l h o s t :8983/solr/admin 找到此信息

      9) 将 version 字段添加到配置文件 schema.yml 以满足 Solr 4.4 初始化要求。实际上,需要在文件中添加两行代码。它们是:

      <field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
      
      <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
      

      配置文件 schema.yml 最终将如下所示:

      <schema name="sunspot" version="1.0">
        <types>
          <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
          <!-- *** Other Sunspot fieldType Definitions *** -->
        </types>
      
        <fields>
          <field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
          <!-- *** Other Sunspot field Definitions *** -->
        </fields>
      
        <!-- *** Other Sunspot Configurations *** -->
      </schema>
      

      ......

      【讨论】:

        猜你喜欢
        • 2014-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多