Skip to content

Instantly share code, notes, and snippets.

@jeffgca
Created December 21, 2010 05:08
Show Gist options
  • Save jeffgca/749526 to your computer and use it in GitHub Desktop.
Save jeffgca/749526 to your computer and use it in GitHub Desktop.
desc "get Master"
task :get_master_info, :roles => :new do
run 'echo "SHOW MASTER STATUS" | mysql -u root --password=root_pass' do |ch, stream, data|
set :master_info, data.split("\n").pop().split("\t")
end
set_master
end
desc "Set Master on Slave"
task :set_master, :roles => :old do
set :sql, "CHANGE MASTER TO MASTER_HOST='some.host', MASTER_USER='user', MASTER_PASSWORD='some_pa55', MASTER_LOG_FILE='#{master_info[0]}', MASTER_LOG_POS=#{master_info[1]};"
# puts sql
put(sql, "/tmp/master.sql")
run "cat /tmp/master.sql | mysql -u root --password=root_pass"
end
@jeffgca
Copy link
Author

jeffgca commented Dec 21, 2010

Number 1 in a continuing series of things you probably shouldn't do with Capistrano.

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