|
2c83525b
»
|
mbailey |
2008-06-20 |
initial import |
1 |
# Copyright 2006-2008 by Mike Bailey. All rights reserved. |
| |
2 |
Capistrano::Configuration.instance(:must_exist).load do |
| |
3 |
namespace :deprec do |
| |
4 |
namespace :mysql do |
| |
5 |
|
| |
6 |
# Installation |
| |
7 |
|
| |
8 |
desc "Install mysql" |
|
d103dda7
»
|
mbailey |
2008-09-04 |
Restricted tasks to roles. |
9 |
task :install, :roles => :db do |
|
2c83525b
»
|
mbailey |
2008-06-20 |
initial import |
10 |
install_deps |
|
b72b6e14
»
|
mbailey |
2008-08-26 |
removed redundant code |
11 |
# symlink_mysql_sockfile # XXX still needed? |
|
2c83525b
»
|
mbailey |
2008-06-20 |
initial import |
12 |
end |
| |
13 |
|
| |
14 |
# Install dependencies for Mysql |
|
d103dda7
»
|
mbailey |
2008-09-04 |
Restricted tasks to roles. |
15 |
task :install_deps, :roles => :db do |
|
2c83525b
»
|
mbailey |
2008-06-20 |
initial import |
16 |
apt.install( {:base => %w(mysql-server mysql-client)}, :stable ) |
| |
17 |
end |
| |
18 |
|
|
b72b6e14
»
|
mbailey |
2008-08-26 |
removed redundant code |
19 |
# task :symlink_mysql_sockfile, :roles => :db do |
| |
20 |
# # rails puts "socket: /tmp/mysql.sock" into config/database.yml |
| |
21 |
# # this is not the location for our ubuntu's mysql socket file |
| |
22 |
# # so we create this link to make deployment using rails defaults simpler |
| |
23 |
# sudo "ln -sf /var/run/mysqld/mysqld.sock /tmp/mysql.sock" |
| |
24 |
# end |
|
2c83525b
»
|
mbailey |
2008-06-20 |
initial import |
25 |
|
| |
26 |
# Configuration |
| |
27 |
|
| |
28 |
SYSTEM_CONFIG_FILES[:mysql] = [ |
| |
29 |
|
| |
30 |
{:template => "my.cnf.erb", |
| |
31 |
:path => '/etc/mysql/my.cnf', |
| |
32 |
:mode => 0644, |
| |
33 |
:owner => 'root:root'} |
| |
34 |
] |
| |
35 |
|
| |
36 |
desc "Generate configuration file(s) for mysql from template(s)" |
| |
37 |
task :config_gen do |
| |
38 |
SYSTEM_CONFIG_FILES[:mysql].each do |file| |
| |
39 |
deprec2.render_template(:mysql, file) |
| |
40 |
end |
| |
41 |
end |
| |
42 |
|
|
7011a5f8
»
|
mbailey |
2008-08-20 |
modified wording to task de... |
43 |
desc "Push mysql config files to server" |
|
2c83525b
»
|
mbailey |
2008-06-20 |
initial import |
44 |
task :config, :roles => :db do |
| |
45 |
deprec2.push_configs(:mysql, SYSTEM_CONFIG_FILES[:mysql]) |
| |
46 |
end |
| |
47 |
|
| |
48 |
task :activate, :roles => :db do |
| |
49 |
send(run_method, "update-rc.d mysql defaults") |
| |
50 |
end |
| |
51 |
|
| |
52 |
task :deactivate, :roles => :db do |
| |
53 |
send(run_method, "update-rc.d -f mysql remove") |
| |
54 |
end |
| |
55 |
|
| |
56 |
# Control |
| |
57 |
|
| |
58 |
desc "Start Mysql" |
| |
59 |
task :start, :roles => :db do |
| |
60 |
send(run_method, "/etc/init.d/mysql start") |
| |
61 |
end |
| |
62 |
|
| |
63 |
desc "Stop Mysql" |
| |
64 |
task :stop, :roles => :db do |
| |
65 |
send(run_method, "/etc/init.d/mysql stop") |
| |
66 |
end |
| |
67 |
|
| |
68 |
desc "Restart Mysql" |
| |
69 |
task :restart, :roles => :db do |
| |
70 |
send(run_method, "/etc/init.d/mysql restart") |
| |
71 |
end |
| |
72 |
|
| |
73 |
desc "Reload Mysql" |
| |
74 |
task :reload, :roles => :db do |
| |
75 |
send(run_method, "/etc/init.d/mysql reload") |
| |
76 |
end |
| |
77 |
|
| |
78 |
|
| |
79 |
task :backup, :roles => :db do |
| |
80 |
end |
| |
81 |
|
| |
82 |
task :restore, :roles => :db do |
| |
83 |
end |
| |
84 |
|
| |
85 |
end |
| |
86 |
end |
| |
87 |
end |
| |
88 |
|
| |
89 |
# |
| |
90 |
# Setup replication |
| |
91 |
# |
| |
92 |
|
| |
93 |
# setup user for repl |
| |
94 |
# GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.yourdomain.com' IDENTIFIED BY 'slavepass'; |
| |
95 |
|
| |
96 |
# get current position of binlog |
| |
97 |
# mysql> FLUSH TABLES WITH READ LOCK; |
| |
98 |
# Query OK, 0 rows affected (0.00 sec) |
| |
99 |
# |
| |
100 |
# mysql> SHOW MASTER STATUS; |
| |
101 |
# +------------------+----------+--------------+------------------+ |
| |
102 |
# | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | |
| |
103 |
# +------------------+----------+--------------+------------------+ |
| |
104 |
# | mysql-bin.000012 | 296 | | | |
| |
105 |
# +------------------+----------+--------------+------------------+ |
| |
106 |
# 1 row in set (0.00 sec) |
| |
107 |
# |
| |
108 |
# # get current data |
| |
109 |
# mysqldump --all-databases --master-data >dbdump.db |
| |
110 |
# |
| |
111 |
# UNLOCK TABLES; |
| |
112 |
|
| |
113 |
|
| |
114 |
# Replication Features and Issues |
|
e4d0b592
»
|
mbailey |
2008-08-17 |
don't restrict mysql recipe... |
115 |
# http://dev.mysql.com/doc/refman/5.0/en/replication-features.html |