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アドレスを入力すると、「WelcometoNginx」と表示されます。

ポートは開いていて、ホスティングサーバーを介して機能しているため、一部のサービスを再起動する必要があると言われました。私が遭遇した問題の1つは、thinking_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とユニコーンのrailsプロジェクト)またはスフィンクスを使用して薄い)任意の洞察をいただければ幸いです。

ありがとう、

アラン

4

3 に答える 3

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 appは引数を使用して呼び出しsearchd--config /home/potato/streetpotato/config/development.sphinx.conf別のconfファイルを指定します。

ログから、それが正常に実行されていることは明らかですthinkingsphinxthink_sphinxインデックスが定義されているモデルの1つにログインしてメソッドrails consoleを実行することで、さらに確認できます。search

例:アプリにArticle上記のリンクに示されているモデルがある場合、次のコマンドはそれらに含まれるすべての記事を表示National Parksします。

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

本当の問題は、サーバーを再起動した後にアプリケーションが表示されないことです。thinking sphinxそれはうまく動いていることとは何の関係もありません。

上記の定数ファイルに加えられたすべての変更をロールバックして、アプリケーションが正常に動作していることを確認してください。次に、変更を1つずつ行い、アプリケーションを破壊する1つの変更を分離します。

于 2012-11-16T21:21:39.487 に答える
0

そうですね、これはThinkingSphinx(IMHO)の穴ですsphinxd。さまざまなrakeタスク(必要に応じて構成を生成する)を使用してサーバーを起動できます...しかし、これは本番環境では機能しません。

昨年(Linuxサーバーで実行している)作業したプロジェクトで、/etc/init.d開始するスクリプトを作成しましたsphinxd。これには、構成ファイルへのパスなどのオプションが含まれます。capistranoを使用してデプロイを行い、生成されたコードをapp/sharedソースツリーの外部のディレクトリに配置しました。モデルが変更されたとき、またはSphinxの動作に影響を与えたときにRails固有の構成ファイルを再構築する事前定義されたcapistranoタスクがあると思います(あなたが言及したrakeタスクと同じです)。

これは、私たちが長い間サイト検索を延期していた私たちにとってのケースの1つであり、開発者の1人が午後にそれを「すべてセットアップ」しました。デプロイするには、さらに多くの作業が必要でした。

(@ 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 に答える