Skip to content

Instantly share code, notes, and snippets.

@benmoss
Created April 19, 2011 14:38
Show Gist options
  • Select an option

  • Save benmoss/928090 to your computer and use it in GitHub Desktop.

Select an option

Save benmoss/928090 to your computer and use it in GitHub Desktop.
Configuring a remote sphinx server with Thinking Sphinx
# deploy.rb
namespace :ts_remote do
task :conf do
run <<-CMD
cd #{current_release}
&&
RAILS_ENV=#{rails_env} rake ts:conf
&&
rsync --progress #{current_release}/config/#{rails_env}.sphinx.conf sphinxsearch@db-server:/home/sphinxsearch/
&&
ssh sphinxsearch@db-server "searchd -c /home/sphinxsearch/#{rails_env}.sphinx.conf --stop
; searchd -c /home/sphinxsearch/#{rails_env}.sphinx.conf"
CMD
end
end
# sphinx.rake
namespace :ts_remote do
desc 'Update indexes on the remote sphinx server'
task :reindex do
system "ssh sphinxsearch@db-server indexer --config ./#{ENV['RAILS_ENV']}.sphinx.conf --all --rotate"
end
end
# sphinx.yml
development:
port: 9312
test:
port: 9312
staging:
port: 9312
address: db-server
sql_host: localhost
pid_file: /home/sphinxsearch/searchd.staging.pid
searchd_file_path: /home/sphinxsearch/searchd-staging
sql_sock: /var/run/mysqld/mysqld.sock
searchd_log_file: "/home/sphinxsearch/log/staging.searchd.log"
query_log_file: "/home/sphinxsearch/log/staging.query.log"
production:
port: 9313
address: db-server
pid_file: /home/sphinxsearch/searchd.production.pid
searchd_file_path: /home/sphinxsearch/searchd-production
sql_sock: /var/run/mysqld/mysqld.sock
searchd_log_file: "/home/sphinxsearch/log/production.searchd.log"
query_log_file: "/home/sphinxsearch/log/production.query.log"
@benmoss

benmoss commented Apr 19, 2011

Copy link
Copy Markdown
Author

db-server is the database server (obvs)

sphinxsearch is the user on the db-server that has access to the relevant files

All the sphinx files are stored in sphinxsearch's home directory. No Rails on the db server, but you do need Sphinx on the app server in order to generate the conf file.

@jhephs

jhephs commented Jul 8, 2011

Copy link
Copy Markdown

Hey. I'm actually trying to do this but I'm having some difficulty on implementing and I hope you can help me.

How do I send out the password for the rsync? What's happening right now to me is that I'm having 'Permission denied, please try again.' so I guess this must be because I'm not handing out the password. So how do I bypass this? Thanks!

@benmoss

benmoss commented Jul 8, 2011

Copy link
Copy Markdown
Author

I think you need to use an RSA key that will allow your Rails server to connect to the Sphinx server without needing a password

@roganartu

Copy link
Copy Markdown

See my fork for making the default RAILS_ENV=development

@thoughtpunch

Copy link
Copy Markdown

@benmoss @roganartu is this still relevant with ThinkingSphinx > v3.0 as far as you know?

@thoughtpunch

Copy link
Copy Markdown

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment