0

问题: 我试图在服务器重启后让 sphinx 再次运行。当我尝试启动它时似乎没有 sphinx.conf 文件:

>searchd

Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)

FATAL: no readable config file (looked in /etc/sphinxsearch/sphinx.conf, ./sphinx.conf).

我跑了:

rake thinking_sphinx:configure
rake thinking_sphinx:index
rake thinking_sphinx:start

问题是由于某种原因没有创建 etc/sphinxsearch/ sphinx.conf文件...我是 thinking_sphinx 的新手,这可能不是唯一的问题(与网站有关),但似乎没有设置完全。有关输出和更多信息,请阅读以下内容:

背景信息: 我正在做一个我最初没有设置的项目。我们重新启动服务器以查看我们在常量文件中所做的一些更改。但是在重新启动后,当您导航到该站点时,该项目不再显示。当您输入直接的 IP 地址时,它只会显示“欢迎使用 Nginx”。

该端口是开放的并且通过我们的托管服务器工作,所以我被告知我必须重新启动一些服务。我遇到的问题之一是thinking_sphinx。这是我引用的 sphinx 站点的 rake 任务。以及sphinx 的常见配置问题

我设置了 sphinx.yml 开发路径(我们没有使用生产)。然后我跑了

>rake thinking_sphinx:index

即使它输出一些警告,这似乎也有效:

Generating Configuration to /home/potato/streetpotato/config/development.sphinx.conf
   (0.2ms)  SELECT @@global.sql_mode, @@session.sql_mode;
Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/home/potato/streetpotato/config/development.sphinx.conf'...
indexing index 'bar_core'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 14080 kb
collected 249 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 249 docs, 32394 bytes
total 0.254 sec, 127298 bytes/sec, 978.49 docs/sec
indexing index 'bar_delta'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 14080 kb
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.003 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index 'bar'...
indexing index 'synonym_core'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 13568 kb
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 3 docs, 103 bytes
total 0.003 sec, 30356 bytes/sec, 884.17 docs/sec
indexing index 'synonym_delta'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 13568 kb
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.002 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index 'synonym'...
indexing index 'user_core'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 13568 kb
collected 100 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 100 docs, 3146 bytes
total 0.013 sec, 239348 bytes/sec, 7608.03 docs/sec
skipping non-plain index 'user'...
total 11 reads, 0.000 sec, 3.8 kb/call avg, 0.0 msec/call avg
total 37 writes, 0.000 sec, 2.5 kb/call avg, 0.0 msec/call avg

然后我跑了

>rake thinking_sphinx:configure

Generating Configuration to /home/potato/streetpotato/config/development.sphinx.conf
(0.2ms)  SELECT @@global.sql_mode, @@session.sql_mode;

最后运行:

>rake thinking_sphinx:start

Started successfully (pid 29623).

现在即使我的日志说:

[Fri Nov 16 19:34:29.820 2012] [29623] accepting connections

仍然没有生成 sphinx.conf 文件,当我尝试使用 searchd 命令时,它仍然给我错误...

>searchd --stop

Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)

FATAL: no readable config file (looked in /etc/sphinxsearch/sphinx.conf, ./sphinx.conf).

我很茫然,我知道这是超长的,但这只是因为我很迷茫并试图提供尽可能多的信息。我比昨天更进一步,但它似乎仍然没有完全工作。我可能还需要在独角兽或瘦身方面做更多的设置。我只是想弄清楚如何让网站重新启动并再次运行......如果有人遇到类似的问题,他们的网站在重新启动后关闭并重新启动(特别是 Nginx 和 unicorn 上的 Rails 项目)或瘦使用狮身人面像)任何见解将不胜感激。

谢谢,

艾伦

4

3 回答 3

0

所以,是的,这是 ThinkingSphinx(恕我直言)中的一个漏洞——您可以sphinxd使用各种 rake 任务(根据需要生成配置)启动服务器……但这在生产中不起作用。

在我去年工作的一个项目中(在 Linux 服务器上运行),我们创建了一个/etc/init.d脚本来启动sphinxd——它接受包括配置文件路径在内的选项。我们使用 capistrano 进行部署,并将生成的代码放在app/shared源代码树之外的目录中。我相信有一些预定义的 capistrano 任务将在模型更改或以其他方式影响 Sphinx 的功能时重建特定于 Rails 的配置文件(与您提到的 rake 任务相同)。

对于我们来说,这是我们长期以来一直推迟站点搜索的案例之一,而我们的一位开发人员在一个下午就将其“全部设置”好了。部署它需要更多的工作。

(刚刚看到@prakash-murthy 的回答——他提供了一些有关在初始化 sphinxd 时如何指定配置路径的详细信息)。但诀窍是让它在系统启动时启动并指向 ThinkingSphinx 生成的配置。)

于 2012-11-16T21:28:54.903 回答
0

好的,所以在一天半之后,我终于把它全部设置好并让它运行(它不仅仅是狮身人面像)。我还必须让 nginx 和 unicorn 在后台启动并运行,因为我们没有设置脚本来在服务器重新启动时重新启动它们......

重新启动服务器时,您必须重新启动一些服务才能访问应用程序:

1) thinking_sphinx
参考网站
http://pat.github.com/ts/en/rake_tasks.html
http://www.claytonlz.com/2010/09/thinkingsphinx-conf-problems/

a)create/modify  app/config/sphinx.yml

    development:
      morphology: stem_en
      port: 9312
      bin_path: "/usr/bin"             # set up the path to binary for searchd
      searchd_binary_name: searchd
      indexer_binary_name: indexer
      #mem_limit: 128M
    test:
      morphology: stem_en
      port: 9312
      mem_limit: 128M
    production:
      morphology: stem_en
      port: 9312
      mem_limit: 512M
    # the searchd ip, in case it's not on localhost
    # address: 10.10.0.0
    # this is by default included in db/sphinx
    # searchd_file_path: "/path/to/shared/folder/sphinx"

b)rake thinking_sphinx:index
c)rake thinking_sphinx:configure       # creates config/development.sphinx.conf which helps define sphinx's indexing

d)# then you have to start sphinx, there are 2 ways to do this

    rake thinking_sphinx:start
    rake thinking_sphinx:stop

    OR

    searchd
    searchd --stop

    # only the rake commands worked for me, when I tried to run searchd
    # I got an error FATAL: no readable config file (looked in /etc/sphinxsearch/sphinx.conf, ./sphinx.conf).
    # for some reason we dont have a sphinx.conf file, but the rake commands work without it

e)# once you start thinking_sphinx check log/searchd.log file for the line
    [Fri Nov 16 19:34:29.820 2012] [29623] accepting connections

2)nginx
参考站点:
http ://wiki.nginx.org/CommandLine

a) check that nginx is up and running
    i) start server 
        # to check where nginx resides type in this into server console
        which nginx
        # whatever path it gives you is how you start the server this is my path
        /usr/sbin/nginx 
    ii) stop server
        /usr/sbin/nginx -s stop # use the path given by which command

3)独角兽(启动应用服务器)
参考站点:
http ://codelevy.com/2010/02/09/getting-started-with-unicorn.html

a) test if unicorn will run after previous changes
    unicorn_rails -p 3000
    # the site should now be up and running, check that it is
    # console should now log the different actions you do on the site 

b) create unicorn.rb in config folder (if none is there)
    # only start this step if the step above got the site running
    # close the console or exit the process you started above
    # contents of unicorn.rb 
    worker_processes 2      #(starts 2 child processes, not completely neccissary)
    preload_app true
    timeout 30
    listen 3000

    after_fork do |server, worker|
      ActiveRecord::Base.establish_connection
    end

c) run unicorn in the background
    # make sure you exited the process above before running this
    unicorn_rails -c config/unicorn.rb -D

    # this was giving me an error that it said was logged by stderr
    # I got the command to run by adding a command to the front
    http://stackoverflow.com/questions/2325152/check-for-stdout-or-stderr

    exec 2> /dev/null unicorn_rails -c config/unicorn.rb -D


d) (optional) check stats from starting unicorn

    i) pgrep -lf unicorn_rails
        #sample output
        5374 unicorn_rails master -c config/unicorn.rb -D             
        5388 unicorn_rails worker[0] -c config/unicorn.rb -D    # not needed currently  
        5391 unicorn_rails worker[1] -c config/unicorn.rb -D    # not needed currently

    ii) cat tmp/pids/unicorn.pid # from inside the streetpotato folder
        #sample output
        5374
于 2012-11-20T00:38:08.423 回答
0

冷静下来!!:-)

首先,您不需要/etc/sphinxsearch/sphinx.conf文件;这只是searchd在您未指定任何配置文件时尝试使用的默认文件。

正如您的日志输出所示,您的 rails 应用程序/home/potato/streetpotato/config/development.sphinx.conf在启动searchd进程时正在使用文件。

ps -fe | grep searchd在您的开发机器上运行;你应该看到类似这样的输出:

501 14128     1   0   0:00.00 ttys004    0:00.00 searchd --pidfile --config /home/potato/streetpotato/config/development.sphinx.conf
501 14130 13546   0   0:00.00 ttys004    0:00.01 grep searchd

所以 rails appsearchd使用--config /home/potato/streetpotato/config/development.sphinx.conf参数调用,以指定不同的 conf 文件。

从您的日志中,很明显thinkingsphinx运行良好。您可以通过登录并在其中定义了thinking_sphinx索引的模型之一上rails console运行方法来进一步确认。search

例如:如果您的应用具有Article上述链接中所示的模型,则以下命令将显示National Parks其中包含的所有文章:

$ rails console
> Article.search( "National Parks" )
=> [#<Article id: 15,... >, #<Article id: 22,...>,...]

真正的问题是重新启动服务器后应用程序未显示。thinking sphinx这与运行良好无关。

尝试回滚您在上面提到的常量文件中所做的所有更改,并确保应用程序工作正常。然后开始一项一项地进行更改,并隔离破坏您的应用程序的一项更改。

于 2012-11-16T21:21:39.487 回答