This page assumes you need to maintain a production server with sphinx search daemon. For how to actually use sphinx in an application, search elsewhere.
Installing sphinx¶
wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8-svn-r1112.tar.gz
tar xzvf sphinx-0.9.8-svn-r1112.tar.gz
cd sphinx-0.9.8-svn-r1112
sudo apt-get install libmysqlclient15-dev
./configure
make
sudo make install
Starting sphinx¶
From the command line:
cd /usr/app/myproject
rake ts:start RAILS_ENV=production
From capistrano recipe:
set :rake_cmd, (ENV['RAKE_CMD'] || nil)
desc "run rake remotely"
task :rake_exec do
if rake_cmd
run "cd #{current_path} && rake #{rake_cmd} RAILS_ENV=production"
end
end
namespace :ts do
desc "start sphinx searchd"
task :start do
set :rake_cmd, "ts:start"
rake_exec
end
desc "stop sphinx searchd"
task :stop do
set :rake_cmd, "ts:stop"
rake_exec
end
end
Running multiple search daemons¶
If you are running multiple web applications that need sphinx, you need to run the search daemons on different ports.
For rails, here is how you would do so:
codetitle. config/sphinx.yml
production:
port: 3314
address: localhost
Then, you need to rebuild the production.sphinx.conf file:
rake ts:config RAILS_ENV=production
This should update the port in the config for production mode:
codetitle. config/production.sphinx.conf
...
searchd
{
address = localhost
port = 3314
log = /usr/apps/crabgrass/log/searchd.log
query_log = /usr/apps/crabgrass/log/searchd.query.log
read_timeout = 5
max_children = 30
pid_file = /usr/apps/crabgrass/log/searchd.production.pid
max_matches = 1000
}
...
All the sphinx rake commands¶
rake ts:config
Generate the Sphinx configuration file using Thinking Sphinx’s settings
rake ts:in
Index data for Sphinx using Thinking Sphinx’s settings
rake ts:index
Index data for Sphinx using Thinking Sphinx’s settings
rake ts:restart
Restart Sphinx
rake ts:start
Start a Sphinx searchd daemon using Thinking Sphinx’s settings
rake ts:stop
Stop Sphinx using Thinking Sphinx’s settings
This is really informative thanks for this 지투지 The most attractive and thrilling platform. Choose your favorite slot game! |
|