wakame 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +86 -0
- data/VERSION +1 -0
- data/app_generators/wakame/templates/README +0 -0
- data/app_generators/wakame/templates/Rakefile +18 -0
- data/app_generators/wakame/templates/bin/wakame-agent +9 -0
- data/app_generators/wakame/templates/bin/wakame-master +9 -0
- data/app_generators/wakame/templates/bin/wakameadm +9 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/apache_app.rb +54 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/apache2.conf +46 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/envvars-app +7 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/sites-app.conf +23 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/system-app.conf +67 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/init.d/apache2-app +192 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/apache_lb.rb +56 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/apache2.conf +46 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/envvars-lb +6 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/sites-lb.conf +54 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/system-lb.conf +75 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/init.d/apache2-lb +192 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/apache_www.rb +50 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/apache2.conf +47 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/envvars-www +7 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/sites-www.conf +23 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/system-www.conf +63 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/init.d/apache2-www +192 -0
- data/app_generators/wakame/templates/cluster/resources/ec2_elastic_ip/ec2_elastic_ip.rb +39 -0
- data/app_generators/wakame/templates/cluster/resources/mysql_master/conf/my.cnf +154 -0
- data/app_generators/wakame/templates/cluster/resources/mysql_master/init.d/mysql +185 -0
- data/app_generators/wakame/templates/cluster/resources/mysql_master/mysql_master.rb +174 -0
- data/app_generators/wakame/templates/config/boot.rb +85 -0
- data/app_generators/wakame/templates/config/cluster.rb +64 -0
- data/app_generators/wakame/templates/config/environments/common.rb +0 -0
- data/app_generators/wakame/templates/config/environments/ec2.rb +3 -0
- data/app_generators/wakame/templates/config/environments/stand_alone.rb +0 -0
- data/app_generators/wakame/templates/config/init.d/wakame-agent +72 -0
- data/app_generators/wakame/templates/config/init.d/wakame-master +73 -0
- data/app_generators/wakame/wakame_generator.rb +124 -0
- data/bin/wakame +18 -0
- data/contrib/imagesetup.sh +77 -0
- data/lib/ext/eventmachine.rb +86 -0
- data/lib/ext/shellwords.rb +172 -0
- data/lib/ext/uri.rb +15 -0
- data/lib/wakame/action.rb +156 -0
- data/lib/wakame/actions/destroy_instances.rb +39 -0
- data/lib/wakame/actions/launch_cluster.rb +31 -0
- data/lib/wakame/actions/migrate_service.rb +65 -0
- data/lib/wakame/actions/propagate_instances.rb +95 -0
- data/lib/wakame/actions/reload_service.rb +21 -0
- data/lib/wakame/actions/scaleout_when_high_load.rb +44 -0
- data/lib/wakame/actions/shutdown_cluster.rb +22 -0
- data/lib/wakame/actions/shutdown_vm.rb +19 -0
- data/lib/wakame/actions/start_service.rb +64 -0
- data/lib/wakame/actions/stop_service.rb +49 -0
- data/lib/wakame/actions/util.rb +71 -0
- data/lib/wakame/actor/daemon.rb +37 -0
- data/lib/wakame/actor/service_monitor.rb +21 -0
- data/lib/wakame/actor/system.rb +46 -0
- data/lib/wakame/actor.rb +33 -0
- data/lib/wakame/agent.rb +226 -0
- data/lib/wakame/amqp_client.rb +219 -0
- data/lib/wakame/command/action_status.rb +62 -0
- data/lib/wakame/command/actor.rb +23 -0
- data/lib/wakame/command/clone_service.rb +12 -0
- data/lib/wakame/command/launch_cluster.rb +15 -0
- data/lib/wakame/command/migrate_service.rb +21 -0
- data/lib/wakame/command/propagate_service.rb +24 -0
- data/lib/wakame/command/shutdown_cluster.rb +15 -0
- data/lib/wakame/command/status.rb +81 -0
- data/lib/wakame/command.rb +31 -0
- data/lib/wakame/command_queue.rb +44 -0
- data/lib/wakame/configuration.rb +93 -0
- data/lib/wakame/daemonize.rb +96 -0
- data/lib/wakame/event.rb +232 -0
- data/lib/wakame/event_dispatcher.rb +154 -0
- data/lib/wakame/graph.rb +79 -0
- data/lib/wakame/initializer.rb +162 -0
- data/lib/wakame/instance_counter.rb +78 -0
- data/lib/wakame/logger.rb +12 -0
- data/lib/wakame/manager/commands.rb +134 -0
- data/lib/wakame/master.rb +369 -0
- data/lib/wakame/monitor/agent.rb +50 -0
- data/lib/wakame/monitor/service.rb +183 -0
- data/lib/wakame/monitor.rb +69 -0
- data/lib/wakame/packets.rb +160 -0
- data/lib/wakame/queue_declare.rb +14 -0
- data/lib/wakame/rule.rb +116 -0
- data/lib/wakame/rule_engine.rb +202 -0
- data/lib/wakame/runner/administrator_command.rb +112 -0
- data/lib/wakame/runner/agent.rb +81 -0
- data/lib/wakame/runner/master.rb +93 -0
- data/lib/wakame/scheduler.rb +251 -0
- data/lib/wakame/service.rb +914 -0
- data/lib/wakame/template.rb +189 -0
- data/lib/wakame/trigger.rb +66 -0
- data/lib/wakame/triggers/instance_count_update.rb +45 -0
- data/lib/wakame/triggers/load_history.rb +107 -0
- data/lib/wakame/triggers/maintain_ssh_known_hosts.rb +43 -0
- data/lib/wakame/triggers/process_command.rb +34 -0
- data/lib/wakame/triggers/shutdown_unused_vm.rb +16 -0
- data/lib/wakame/util.rb +569 -0
- data/lib/wakame/vm_manipulator.rb +186 -0
- data/lib/wakame.rb +59 -0
- data/tasks/ec2.rake +127 -0
- data/tests/cluster.json +3 -0
- data/tests/conf/a +1 -0
- data/tests/conf/b +1 -0
- data/tests/conf/c +1 -0
- data/tests/setup_agent.rb +39 -0
- data/tests/setup_master.rb +28 -0
- data/tests/test_actor.rb +54 -0
- data/tests/test_agent.rb +218 -0
- data/tests/test_amqp_client.rb +94 -0
- data/tests/test_graph.rb +36 -0
- data/tests/test_master.rb +167 -0
- data/tests/test_monitor.rb +47 -0
- data/tests/test_rule_engine.rb +127 -0
- data/tests/test_scheduler.rb +123 -0
- data/tests/test_service.rb +60 -0
- data/tests/test_template.rb +67 -0
- data/tests/test_uri_amqp.rb +19 -0
- data/tests/test_util.rb +71 -0
- data/wakame_generators/resource/resource_generator.rb +54 -0
- data/wakame_generators/resource/templates/apache_app/apache_app.rb +60 -0
- data/wakame_generators/resource/templates/apache_app/conf/apache2.conf +46 -0
- data/wakame_generators/resource/templates/apache_app/conf/envvars-app +7 -0
- data/wakame_generators/resource/templates/apache_app/conf/sites-app.conf +23 -0
- data/wakame_generators/resource/templates/apache_app/conf/system-app.conf +67 -0
- data/wakame_generators/resource/templates/apache_app/init.d/apache2-app +192 -0
- data/wakame_generators/resource/templates/apache_lb/apache_lb.rb +67 -0
- data/wakame_generators/resource/templates/apache_lb/conf/apache2.conf +46 -0
- data/wakame_generators/resource/templates/apache_lb/conf/envvars-lb +6 -0
- data/wakame_generators/resource/templates/apache_lb/conf/sites-lb.conf +54 -0
- data/wakame_generators/resource/templates/apache_lb/conf/system-lb.conf +75 -0
- data/wakame_generators/resource/templates/apache_lb/init.d/apache2-lb +192 -0
- data/wakame_generators/resource/templates/apache_www/apache_www.rb +56 -0
- data/wakame_generators/resource/templates/apache_www/conf/apache2.conf +47 -0
- data/wakame_generators/resource/templates/apache_www/conf/envvars-www +7 -0
- data/wakame_generators/resource/templates/apache_www/conf/sites-www.conf +23 -0
- data/wakame_generators/resource/templates/apache_www/conf/system-www.conf +63 -0
- data/wakame_generators/resource/templates/apache_www/init.d/apache2-www +192 -0
- data/wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb +39 -0
- data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +154 -0
- data/wakame_generators/resource/templates/mysql_master/init.d/mysql +185 -0
- data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +119 -0
- metadata +289 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
#!/bin/sh -e
|
2
|
+
|
3
|
+
[ -n $WAKAME_ROOT ] || { echo "WAKAME_ROOT env was not set" >&2; exit 1; }
|
4
|
+
|
5
|
+
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
|
6
|
+
|
7
|
+
SERVER_ROOT="$WAKAME_ROOT/tmp/config/apache_www/conf"
|
8
|
+
INITSCRIPT=`basename $0`
|
9
|
+
DEF=`echo ${INITSCRIPT#apache2-} | tr '[:lower:]' '[:upper:]'`
|
10
|
+
APACHE_ENVVARS="$SERVER_ROOT/envvars-`echo $DEF | tr '[:upper:]' '[:lower:]'`"
|
11
|
+
APACHE_ARGS="-D$DEF -f $SERVER_ROOT/apache2.conf"
|
12
|
+
|
13
|
+
[ $DEF = "APACHE2" ] && { echo "Apache server type is undefined" >&2; exit 1; }
|
14
|
+
|
15
|
+
#[ `ls -1 /etc/apache2/sites-enabled/ | wc -l | sed -e 's/ *//;'` -eq 0 ] && \
|
16
|
+
#echo "You haven't enabled any sites yet, so I'm not starting apache2." && \
|
17
|
+
#echo "To add and enable a host, use addhost and enhost." && exit 0
|
18
|
+
|
19
|
+
#edit /etc/default/apache2 to change this.
|
20
|
+
HTCACHECLEAN_RUN=auto
|
21
|
+
HTCACHECLEAN_MODE=daemon
|
22
|
+
HTCACHECLEAN_SIZE=300M
|
23
|
+
HTCACHECLEAN_DAEMON_INTERVAL=120
|
24
|
+
HTCACHECLEAN_PATH=/var/cache/apache2/mod_disk_cache
|
25
|
+
HTCACHECLEAN_OPTIONS=""
|
26
|
+
|
27
|
+
set -e
|
28
|
+
if [ -x /usr/sbin/apache2 ] ; then
|
29
|
+
HAVE_APACHE2=1
|
30
|
+
else
|
31
|
+
echo "No apache MPM package installed"
|
32
|
+
exit 0
|
33
|
+
fi
|
34
|
+
|
35
|
+
. /lib/lsb/init-functions
|
36
|
+
|
37
|
+
test -f /etc/default/rcS && . /etc/default/rcS
|
38
|
+
#test -f /etc/default/apache2 && . /etc/default/apache2
|
39
|
+
|
40
|
+
APACHE2CTL="$ENV APACHE_ENVVARS=$APACHE_ENVVARS /usr/sbin/apache2ctl $APACHE_ARGS"
|
41
|
+
CONFIG_TEST="$APACHE2CTL -t"
|
42
|
+
HTCACHECLEAN="$ENV /usr/sbin/htcacheclean"
|
43
|
+
|
44
|
+
check_htcacheclean() {
|
45
|
+
[ "$HTCACHECLEAN_MODE" = "daemon" ] || return 1
|
46
|
+
|
47
|
+
[ "$HTCACHECLEAN_RUN" = "yes" ] && return 0
|
48
|
+
|
49
|
+
[ "$HTCACHECLEAN_RUN" = "auto" \
|
50
|
+
-a -e /etc/apache2/mods-enabled/disk_cache.load ] && return 0
|
51
|
+
|
52
|
+
return 1
|
53
|
+
}
|
54
|
+
|
55
|
+
start_htcacheclean() {
|
56
|
+
$HTCACHECLEAN $HTCACHECLEAN_OPTIONS -d$HTCACHECLEAN_DAEMON_INTERVAL \
|
57
|
+
-i -p$HTCACHECLEAN_PATH -l$HTCACHECLEAN_SIZE
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
stop_htcacheclean() {
|
62
|
+
killall htcacheclean 2> /dev/null || echo ...not running
|
63
|
+
}
|
64
|
+
|
65
|
+
pidof_apache() {
|
66
|
+
# if pidof is null for some reasons the script exits automagically
|
67
|
+
# classified as good/unknown feature
|
68
|
+
PIDS=`pidof apache2` || true
|
69
|
+
|
70
|
+
PFILE=`. $APACHE_ENVVARS ; echo $APACHE_PID_FILE`
|
71
|
+
if [ -z "$PFILE" ] ; then
|
72
|
+
echo ERROR: APACHE_PID_FILE needs to be defined in $APACHE_ENVVARS >&2
|
73
|
+
exit 2
|
74
|
+
fi
|
75
|
+
|
76
|
+
[ -e $PFILE ] && PIDS2=`cat $PFILE`
|
77
|
+
|
78
|
+
# if there is a pid we need to verify that belongs to apache2
|
79
|
+
# for real
|
80
|
+
for i in $PIDS; do
|
81
|
+
if [ "$i" = "$PIDS2" ]; then
|
82
|
+
# in this case the pid stored in the
|
83
|
+
# pidfile matches one of the pidof apache
|
84
|
+
# so a simple kill will make it
|
85
|
+
echo $i
|
86
|
+
return 0
|
87
|
+
fi
|
88
|
+
done
|
89
|
+
return 1
|
90
|
+
}
|
91
|
+
|
92
|
+
apache_stop() {
|
93
|
+
if `$APACHE2CTL -t > /dev/null 2>&1`; then
|
94
|
+
# if the config is ok than we just stop normaly
|
95
|
+
$APACHE2CTL -k graceful-stop
|
96
|
+
else
|
97
|
+
# if we are here something is broken and we need to try
|
98
|
+
# to exit as nice and clean as possible
|
99
|
+
PID=$(pidof_apache)
|
100
|
+
|
101
|
+
if [ "${PID}" ]; then
|
102
|
+
# in this case it is everything nice and dandy
|
103
|
+
# and we kill apache2
|
104
|
+
log_warning_msg "We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!"
|
105
|
+
kill $PID
|
106
|
+
elif [ "$(pidof apache2)" ]; then
|
107
|
+
if [ "$VERBOSE" != no ]; then
|
108
|
+
echo " ... failed!"
|
109
|
+
echo "You may still have some apache2 processes running. There are"
|
110
|
+
echo "processes named 'apache2' which do not match your pid file,"
|
111
|
+
echo "and in the name of safety, we've left them alone. Please review"
|
112
|
+
echo "the situation by hand."
|
113
|
+
fi
|
114
|
+
return 1
|
115
|
+
fi
|
116
|
+
fi
|
117
|
+
}
|
118
|
+
|
119
|
+
# Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
|
120
|
+
case $1 in
|
121
|
+
start)
|
122
|
+
log_daemon_msg "Starting web server" "apache2"
|
123
|
+
if $APACHE2CTL -k start; then
|
124
|
+
#if check_htcacheclean ; then
|
125
|
+
# log_progress_msg htcacheclean
|
126
|
+
# start_htcacheclean || log_end_msg 1
|
127
|
+
#fi
|
128
|
+
log_end_msg 0
|
129
|
+
else
|
130
|
+
log_end_msg 1
|
131
|
+
fi
|
132
|
+
;;
|
133
|
+
stop)
|
134
|
+
#if check_htcacheclean ; then
|
135
|
+
# log_daemon_msg "Stopping web server" "htcacheclean"
|
136
|
+
# stop_htcacheclean
|
137
|
+
# log_progress_msg "apache2"
|
138
|
+
#else
|
139
|
+
log_daemon_msg "Stopping web server" "apache2"
|
140
|
+
#fi
|
141
|
+
if apache_stop; then
|
142
|
+
log_end_msg 0
|
143
|
+
else
|
144
|
+
log_end_msg 1
|
145
|
+
fi
|
146
|
+
;;
|
147
|
+
reload | force-reload)
|
148
|
+
if ! $APACHE2CTL -t > /dev/null 2>&1; then
|
149
|
+
$APACHE2CTL -t || true
|
150
|
+
log_end_msg 1
|
151
|
+
exit 1
|
152
|
+
fi
|
153
|
+
log_daemon_msg "Reloading web server config" "apache2"
|
154
|
+
if pidof_apache > /dev/null ; then
|
155
|
+
if $APACHE2CTL -k graceful $2 ; then
|
156
|
+
log_end_msg 0
|
157
|
+
else
|
158
|
+
log_end_msg 1
|
159
|
+
fi
|
160
|
+
fi
|
161
|
+
;;
|
162
|
+
restart)
|
163
|
+
#if check_htcacheclean ; then
|
164
|
+
# log_daemon_msg "Restarting web server" "htcacheclean"
|
165
|
+
# stop_htcacheclean
|
166
|
+
# log_progress_msg apache2
|
167
|
+
#else
|
168
|
+
log_daemon_msg "Restarting web server" "apache2"
|
169
|
+
#fi
|
170
|
+
if ! apache_stop; then
|
171
|
+
log_end_msg 1 || true
|
172
|
+
fi
|
173
|
+
sleep 5
|
174
|
+
if $APACHE2CTL -k start; then
|
175
|
+
#if check_htcacheclean ; then
|
176
|
+
# start_htcacheclean || log_end_msg 1
|
177
|
+
#fi
|
178
|
+
log_end_msg 0
|
179
|
+
else
|
180
|
+
log_end_msg 1
|
181
|
+
fi
|
182
|
+
;;
|
183
|
+
configtest)
|
184
|
+
echo $APACHE2CTL -t -DDUMP_MODULES -DDUMP_VHOSTS
|
185
|
+
$APACHE2CTL -t -DDUMP_MODULES -DDUMP_VHOSTS
|
186
|
+
$APACHE2CTL -l
|
187
|
+
;;
|
188
|
+
*)
|
189
|
+
log_success_msg "Usage: /etc/init.d/$INITSCRIPT {start|stop|restart|reload|force-reload|configtest}"
|
190
|
+
exit 1
|
191
|
+
;;
|
192
|
+
esac
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Ec2ElasticIp < Wakame::Service::Resource
|
2
|
+
|
3
|
+
def_attribute :elastic_ip, ''
|
4
|
+
def_attribute :require_agent, false
|
5
|
+
|
6
|
+
def on_parent_changed(svc, action)
|
7
|
+
start(svc, action)
|
8
|
+
end
|
9
|
+
|
10
|
+
def start(svc, action)
|
11
|
+
require 'right_aws'
|
12
|
+
ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
|
13
|
+
|
14
|
+
puts svc.parent_instances.size.to_s
|
15
|
+
a = svc.parent_instances.first
|
16
|
+
|
17
|
+
puts "#{a.class}, a.agent=#{a.agent}"
|
18
|
+
Wakame.log.info("Associating the Elastic IP #{self.elastic_ip} to #{a.agent.attr[:instance_id]}")
|
19
|
+
ec2.associate_address(a.agent.attr[:instance_id], self.elastic_ip)
|
20
|
+
EM.barrier {
|
21
|
+
svc.update_status(Wakame::Service::STATUS_ONLINE)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def stop(svc, action)
|
26
|
+
require 'right_aws'
|
27
|
+
ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
|
28
|
+
|
29
|
+
a = svc.parent_instances.first
|
30
|
+
|
31
|
+
#Wakame.log.info("Disassociating the Elastic IP #{self.elastic_ip} from #{a.agent.attr[:instance_id]}")
|
32
|
+
#ec2.disassociate_address(self.elastic_ip)
|
33
|
+
EM.barrier {
|
34
|
+
svc.update_status(Wakame::Service::STATUS_OFFLINE)
|
35
|
+
}
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
#
|
2
|
+
# The MySQL database server configuration file.
|
3
|
+
#
|
4
|
+
# You can copy this to one of:
|
5
|
+
# - "/etc/mysql/my.cnf" to set global options,
|
6
|
+
# - "~/.my.cnf" to set user-specific options.
|
7
|
+
#
|
8
|
+
# One can use all long options that the program supports.
|
9
|
+
# Run program with --help to get a list of available options and with
|
10
|
+
# --print-defaults to see which it would actually understand and use.
|
11
|
+
#
|
12
|
+
# For explanations see
|
13
|
+
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
|
14
|
+
|
15
|
+
# This will be passed to all mysql clients
|
16
|
+
# It has been reported that passwords should be enclosed with ticks/quotes
|
17
|
+
# escpecially if they contain "#" chars...
|
18
|
+
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
|
19
|
+
[client]
|
20
|
+
port = <%= property.mysqld_port %>
|
21
|
+
socket = /var/run/mysqld/mysqld.sock
|
22
|
+
|
23
|
+
# Here is entries for some specific programs
|
24
|
+
# The following values assume you have at least 32M ram
|
25
|
+
|
26
|
+
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
|
27
|
+
[mysqld_safe]
|
28
|
+
socket = /var/run/mysqld/mysqld.sock
|
29
|
+
nice = 0
|
30
|
+
|
31
|
+
[mysqld]
|
32
|
+
#
|
33
|
+
# * Basic Settings
|
34
|
+
#
|
35
|
+
|
36
|
+
#
|
37
|
+
# * IMPORTANT
|
38
|
+
# If you make changes to these settings and your system uses apparmor, you may
|
39
|
+
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
|
40
|
+
#
|
41
|
+
|
42
|
+
user = mysql
|
43
|
+
pid-file = /var/run/mysqld/mysqld.pid
|
44
|
+
socket = /var/run/mysqld/mysqld.sock
|
45
|
+
port = <%= property.mysqld_port %>
|
46
|
+
basedir = /usr
|
47
|
+
datadir = <%= property.mysqld_datadir %>
|
48
|
+
tmpdir = /tmp
|
49
|
+
language = /usr/share/mysql/english
|
50
|
+
skip-external-locking
|
51
|
+
#
|
52
|
+
# Instead of skip-networking the default is now to listen only on
|
53
|
+
# localhost which is more compatible and is not less secure.
|
54
|
+
#bind-address = 127.0.0.1
|
55
|
+
#
|
56
|
+
# * Fine Tuning
|
57
|
+
#
|
58
|
+
key_buffer = 16M
|
59
|
+
max_allowed_packet = 16M
|
60
|
+
thread_stack = 128K
|
61
|
+
thread_cache_size = 8
|
62
|
+
#max_connections = 100
|
63
|
+
#table_cache = 64
|
64
|
+
#thread_concurrency = 10
|
65
|
+
#
|
66
|
+
# * Query Cache Configuration
|
67
|
+
#
|
68
|
+
query_cache_limit = 1M
|
69
|
+
query_cache_size = 16M
|
70
|
+
#
|
71
|
+
# * Logging and Replication
|
72
|
+
#
|
73
|
+
# Both location gets rotated by the cronjob.
|
74
|
+
# Be aware that this log type is a performance killer.
|
75
|
+
log = /var/log/mysql/mysql.log
|
76
|
+
log_error = /var/log/mysql/mysql-error.log
|
77
|
+
#
|
78
|
+
# Error logging goes to syslog. This is a Debian improvement :)
|
79
|
+
#
|
80
|
+
# Here you can see queries with especially long duration
|
81
|
+
log_slow_queries = /var/log/mysql/mysql-slow.log
|
82
|
+
long_query_time = 2
|
83
|
+
#log-queries-not-using-indexes
|
84
|
+
#
|
85
|
+
# The following can be used as easy to replay backup logs or for replication.
|
86
|
+
# note: if you are setting up a replication slave, see README.Debian about
|
87
|
+
# other settings you may need to change.
|
88
|
+
server-id = <%= property.mysqld_server_id %>
|
89
|
+
log_bin = <%= property.mysqld_log_bin %>
|
90
|
+
#expire_logs_days = 10
|
91
|
+
#max_binlog_size = 100M
|
92
|
+
#binlog_do_db = include_database_name
|
93
|
+
#binlog_ignore_db = include_database_name
|
94
|
+
#
|
95
|
+
# * BerkeleyDB
|
96
|
+
#
|
97
|
+
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
|
98
|
+
skip-bdb
|
99
|
+
#
|
100
|
+
# * InnoDB
|
101
|
+
#
|
102
|
+
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
|
103
|
+
# Read the manual for more InnoDB related options. There are many!
|
104
|
+
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
|
105
|
+
#skip-innodb
|
106
|
+
#
|
107
|
+
# * Security Features
|
108
|
+
#
|
109
|
+
# Read the manual, too, if you want chroot!
|
110
|
+
# chroot = /var/lib/mysql/
|
111
|
+
#
|
112
|
+
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
|
113
|
+
#
|
114
|
+
# ssl-ca=/etc/mysql/cacert.pem
|
115
|
+
# ssl-cert=/etc/mysql/server-cert.pem
|
116
|
+
# ssl-key=/etc/mysql/server-key.pem
|
117
|
+
|
118
|
+
innodb_flush_method=O_DIRECT
|
119
|
+
wait_timeout=60
|
120
|
+
skip-name-resolve
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
[mysqldump]
|
127
|
+
quick
|
128
|
+
quote-names
|
129
|
+
max_allowed_packet = 16M
|
130
|
+
|
131
|
+
[mysql]
|
132
|
+
#no-auto-rehash # faster start of mysql but no tab completition
|
133
|
+
|
134
|
+
[isamchk]
|
135
|
+
key_buffer = 16M
|
136
|
+
|
137
|
+
#
|
138
|
+
# * NDB Cluster
|
139
|
+
#
|
140
|
+
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
|
141
|
+
#
|
142
|
+
# The following configuration is read by the NDB Data Nodes (ndbd processes)
|
143
|
+
# not from the NDB Management Nodes (ndb_mgmd processes).
|
144
|
+
#
|
145
|
+
# [MYSQL_CLUSTER]
|
146
|
+
# ndb-connectstring=127.0.0.1
|
147
|
+
|
148
|
+
|
149
|
+
#
|
150
|
+
# * IMPORTANT: Additional settings that can override those from this file!
|
151
|
+
# The files must end with '.cnf', otherwise they'll be ignored.
|
152
|
+
#
|
153
|
+
#!includedir /etc/mysql/conf.d/
|
154
|
+
|
@@ -0,0 +1,185 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: mysql
|
5
|
+
# Required-Start: $remote_fs $syslog mysql-ndb
|
6
|
+
# Required-Stop: $remote_fs $syslog mysql-ndb
|
7
|
+
# Should-Start: $network $named $time
|
8
|
+
# Should-Stop: $network $named $time
|
9
|
+
# Default-Start: 2 3 4 5
|
10
|
+
# Default-Stop: 0 1 6
|
11
|
+
# Short-Description: Start and stop the mysql database server daemon
|
12
|
+
# Description: Controls the main MySQL database server daemon "mysqld"
|
13
|
+
# and its wrapper script "mysqld_safe".
|
14
|
+
### END INIT INFO
|
15
|
+
#
|
16
|
+
|
17
|
+
[ -n $WAKAME_ROOT ] || { echo "WAKAME_ROOT env was not set" >&2; exit 1; }
|
18
|
+
|
19
|
+
set -e
|
20
|
+
set -u
|
21
|
+
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
|
22
|
+
|
23
|
+
test -x /usr/sbin/mysqld || exit 0
|
24
|
+
|
25
|
+
. /lib/lsb/init-functions
|
26
|
+
|
27
|
+
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
|
28
|
+
CONF=$WAKAME_ROOT/tmp/config/mysql_master/conf/my.cnf
|
29
|
+
MYADMIN="/usr/bin/mysqladmin --defaults-file=$CONF"
|
30
|
+
|
31
|
+
# priority can be overriden and "-s" adds output to stderr
|
32
|
+
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
|
33
|
+
|
34
|
+
# Safeguard (relative paths, core dumps..)
|
35
|
+
cd /
|
36
|
+
umask 077
|
37
|
+
|
38
|
+
# mysqladmin likes to read /root/.my.cnf. This is usually not what I want
|
39
|
+
# as many admins e.g. only store a password without a username there and
|
40
|
+
# so break my scripts.
|
41
|
+
export HOME=/etc/mysql/
|
42
|
+
|
43
|
+
## Fetch a particular option from mysql's invocation.
|
44
|
+
#
|
45
|
+
# Usage: void mysqld_get_param option
|
46
|
+
mysqld_get_param() {
|
47
|
+
/usr/sbin/mysqld --print-defaults \
|
48
|
+
| tr " " "\n" \
|
49
|
+
| grep -- "--$1" \
|
50
|
+
| tail -n 1 \
|
51
|
+
| cut -d= -f2
|
52
|
+
}
|
53
|
+
|
54
|
+
## Do some sanity checks before even trying to start mysqld.
|
55
|
+
sanity_checks() {
|
56
|
+
# check for config file
|
57
|
+
if [ ! -r $CONF ]; then
|
58
|
+
echo "WARNING: $CONF cannot be read." | $ERR_LOGGER
|
59
|
+
fi
|
60
|
+
|
61
|
+
# check for diskspace shortage
|
62
|
+
datadir=`mysqld_get_param datadir`
|
63
|
+
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
|
64
|
+
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
|
65
|
+
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
|
66
|
+
exit 1
|
67
|
+
fi
|
68
|
+
}
|
69
|
+
|
70
|
+
## Checks if there is a server running and if so if it is accessible.
|
71
|
+
#
|
72
|
+
# check_alive insists on a pingable server
|
73
|
+
# check_dead also fails if there is a lost mysqld in the process list
|
74
|
+
#
|
75
|
+
# Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn]
|
76
|
+
mysqld_status () {
|
77
|
+
ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? ))
|
78
|
+
|
79
|
+
ps_alive=0
|
80
|
+
pidfile=`mysqld_get_param pid-file`
|
81
|
+
if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi
|
82
|
+
|
83
|
+
if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
|
84
|
+
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
|
85
|
+
return 0 # EXIT_SUCCESS
|
86
|
+
else
|
87
|
+
if [ "$2" = "warn" ]; then
|
88
|
+
echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug
|
89
|
+
fi
|
90
|
+
return 1 # EXIT_FAILURE
|
91
|
+
fi
|
92
|
+
}
|
93
|
+
|
94
|
+
#
|
95
|
+
# main()
|
96
|
+
#
|
97
|
+
|
98
|
+
case "${1:-''}" in
|
99
|
+
'start')
|
100
|
+
sanity_checks;
|
101
|
+
# Start daemon
|
102
|
+
log_daemon_msg "Starting MySQL database server" "mysqld"
|
103
|
+
if mysqld_status check_alive nowarn; then
|
104
|
+
log_progress_msg "already running"
|
105
|
+
log_end_msg 0
|
106
|
+
else
|
107
|
+
/usr/bin/mysqld_safe --defaults-file="$CONF" --skip-character-set-client-handshake > /dev/null 2>&1 &
|
108
|
+
# 6s was reported in #352070 to be too few when using ndbcluster
|
109
|
+
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
|
110
|
+
sleep 1
|
111
|
+
if mysqld_status check_alive nowarn ; then break; fi
|
112
|
+
log_progress_msg "."
|
113
|
+
done
|
114
|
+
if mysqld_status check_alive warn; then
|
115
|
+
log_end_msg 0
|
116
|
+
# Now start mysqlcheck or whatever the admin wants.
|
117
|
+
output=$(/etc/mysql/debian-start)
|
118
|
+
[ -n "$output" ] && log_action_msg "$output"
|
119
|
+
else
|
120
|
+
log_end_msg 1
|
121
|
+
log_failure_msg "Please take a look at the syslog"
|
122
|
+
fi
|
123
|
+
fi
|
124
|
+
|
125
|
+
;;
|
126
|
+
|
127
|
+
'stop')
|
128
|
+
# * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible
|
129
|
+
# at least for cron, we can rely on it here, too. (although we have
|
130
|
+
# to specify it explicit as e.g. sudo environments points to the normal
|
131
|
+
# users home and not /root)
|
132
|
+
log_daemon_msg "Stopping MySQL database server" "mysqld"
|
133
|
+
if ! mysqld_status check_dead nowarn; then
|
134
|
+
set +e
|
135
|
+
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
|
136
|
+
set -e
|
137
|
+
if [ "$r" -ne 0 ]; then
|
138
|
+
log_end_msg 1
|
139
|
+
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
|
140
|
+
log_daemon_msg "Killing MySQL database server by signal" "mysqld"
|
141
|
+
killall -15 mysqld
|
142
|
+
server_down=
|
143
|
+
for i in 1 2 3 4 5 6 7 8 9 10; do
|
144
|
+
sleep 1
|
145
|
+
if mysqld_status check_dead nowarn; then server_down=1; break; fi
|
146
|
+
done
|
147
|
+
if test -z "$server_down"; then killall -9 mysqld; fi
|
148
|
+
fi
|
149
|
+
fi
|
150
|
+
|
151
|
+
if ! mysqld_status check_dead warn; then
|
152
|
+
log_end_msg 1
|
153
|
+
log_failure_msg "Please stop MySQL manually and read /usr/share/doc/mysql-server-5.0/README.Debian.gz!"
|
154
|
+
exit -1
|
155
|
+
else
|
156
|
+
log_end_msg 0
|
157
|
+
fi
|
158
|
+
;;
|
159
|
+
|
160
|
+
'restart')
|
161
|
+
set +e; $SELF stop; set -e
|
162
|
+
$SELF start
|
163
|
+
;;
|
164
|
+
|
165
|
+
'reload'|'force-reload')
|
166
|
+
log_daemon_msg "Reloading MySQL database server" "mysqld"
|
167
|
+
$MYADMIN reload
|
168
|
+
log_end_msg 0
|
169
|
+
;;
|
170
|
+
|
171
|
+
'status')
|
172
|
+
if mysqld_status check_alive nowarn; then
|
173
|
+
log_action_msg "$($MYADMIN version)"
|
174
|
+
else
|
175
|
+
log_action_msg "MySQL is stopped."
|
176
|
+
exit 3
|
177
|
+
fi
|
178
|
+
;;
|
179
|
+
|
180
|
+
*)
|
181
|
+
echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
|
182
|
+
exit 1
|
183
|
+
;;
|
184
|
+
esac
|
185
|
+
|