File mariadb-10.1.1-mysqld_multi-features.patch of Package mariadb
180
1
PATCH-P0-FEATURE-UPSTREAM: Add more functionality to mysqld_multi script
2
3
Adds reload funcionality to mysqld_multi.sh perl script and adds --datadir
4
support.
5
6
Maintainer: Michal Hrusecky <Michal.Hrusecky@opensuse.org>
7
8
Index: scripts/mysqld_multi.sh
9
===================================================================
10
--- scripts/mysqld_multi.sh.orig
11
+++ scripts/mysqld_multi.sh
12
13
14
use Getopt::Long;
15
use POSIX qw(strftime getcwd);
16
+use File::Path qw(mkpath);
17
18
$|=1;
19
$VER="2.20";
20
21
usage() if (!defined($ARGV[0]) ||
22
(!($ARGV[0] =~ m/^start$/i) &&
23
!($ARGV[0] =~ m/^stop$/i) &&
24
+ !($ARGV[0] =~ m/^reload$/i) &&
25
!($ARGV[0] =~ m/^report$/i)));
26
27
if (!$opt_no_log)
28
29
print strftime "%a %b %e %H:%M:%S %Y", localtime;
30
print "\n";
31
}
32
- if ($ARGV[0] =~ m/^start$/i)
33
+ if (($ARGV[0] =~ m/^start$/i) || ($ARGV[0] =~ m/^reload$/i))
34
{
35
if (!defined(($mysqld= my_which($opt_mysqld))) && $opt_verbose)
36
{
37
38
print "This is OK, if you are using option \"mysqld=...\" in ";
39
print "groups [mysqldN] separately for each.\n\n";
40
}
41
- start_mysqlds();
42
+ if ($ARGV[0] =~ m/^start$/i) {
43
+ start_mysqlds();
44
+ } elsif ($ARGV[0] =~ m/^reload$/i) {
45
+ reload_mysqlds();
46
+ }
47
}
48
else
49
{
50
51
$com= "$mysqld";
52
for ($j = 0, $tmp= ""; defined($options[$j]); $j++)
53
{
54
+ if ("--datadir=" eq substr($options[$j], 0, 10)) {
55
+ $datadir = $options[$j];
56
+ $datadir =~ s/\-\-datadir\=//;
57
+ eval { mkpath($datadir) };
58
+ if ($@) {
59
+ print "FATAL ERROR: Cannot create data directory $datadir: $!\n";
60
+ exit(1);
61
+ }
62
+ if (! -d $datadir."/mysql") {
63
+ if (-w $datadir) {
64
+ print "\n\nInstalling new database in $datadir\n\n";
65
+ $install_cmd="@bindir@/mysql_install_db ";
66
+ $install_cmd.="--user=mysql ";
67
+ $install_cmd.="--datadir=$datadir";
68
+ system($install_cmd);
69
+ } else {
70
+ print "\n";
71
+ print "FATAL ERROR: Tried to create mysqld under group [$groups[$i]],\n";
72
+ print "but the data directory is not writable.\n";
73
+ print "data directory used: $datadir\n";
74
+ exit(1);
75
+ }
76
+ }
77
+
78
+ if (! -d $datadir."/mysql") {
79
+ print "\n";
80
+ print "FATAL ERROR: Tried to start mysqld under group [$groups[$i]],\n";
81
+ print "but no data directory was found or could be created.\n";
82
+ print "data directory used: $datadir\n";
83
+ exit(1);
84
+ }
85
+ }
86
+
87
if ("--mysqladmin=" eq substr($options[$j], 0, 13))
88
{
89
# catch this and ignore
90
91
}
92
93
####
94
+#### reload multiple servers
95
+####
96
+
97
+sub reload_mysqlds()
98
+{
99
+ my (@groups, $com, $tmp, $i, @options, $j);
100
+
101
+ if (!$opt_no_log)
102
+ {
103
+ w2log("\nReloading MySQL servers\n","$opt_log",0,0);
104
+ }
105
+ else
106
+ {
107
+ print "\nReloading MySQL servers\n";
108
+ }
109
+ @groups = &find_groups($groupids);
110
+ for ($i = 0; defined($groups[$i]); $i++)
111
+ {
112
+ $mysqld_server = $mysqld;
113
+ @options = defaults_for_group($groups[$i]);
114
+
115
+ for ($j = 0, $tmp= ""; defined($options[$j]); $j++)
116
+ {
117
+ if ("--mysqladmin=" eq substr($options[$j], 0, 13))
118
+ {
119
+ # catch this and ignore
120
+ }
121
+ elsif ("--mysqld=" eq substr($options[$j], 0, 9))
122
+ {
123
+ $options[$j] =~ s/\-\-mysqld\=//;
124
+ $mysqld_server = $options[$j];
125
+ }
126
+ elsif ("--pid-file=" eq substr($options[$j], 0, 11))
127
+ {
128
+ $options[$j] =~ s/\-\-pid-file\=//;
129
+ $pid_file = $options[$j];
130
+ }
131
+ }
132
+ $com = "killproc -p $pid_file -HUP $mysqld_server";
133
+ system($com);
134
+
135
+ $com = "touch $pid_file";
136
+ system($com);
137
+ }
138
+ if (!$i && !$opt_no_log)
139
+ {
140
+ w2log("No MySQL servers to be reloaded (check your GNRs)",
141
+ "$opt_log", 0, 0);
142
+ }
143
+}
144
+
145
+###
146
#### stop multiple servers
147
####
148
149
150
$my_progname version $VER by Jani Tolonen
151
152
Description:
153
-$my_progname can be used to start, or stop any number of separate
154
+$my_progname can be used to start, reload, or stop any number of separate
155
mysqld processes running in different TCP/IP ports and UNIX sockets.
156
157
$my_progname can read group [mysqld_multi] from my.cnf file. You may
158
159
[mysqld] group, but with those port, socket and any other options
160
that are to be used with each separate mysqld process. The number
161
in the group name has another function; it can be used for starting,
162
-stopping, or reporting any specific mysqld server.
163
+reloading, stopping, or reporting any specific mysqld server.
164
165
-Usage: $my_progname [OPTIONS] {start|stop|report} [GNR,GNR,GNR...]
166
-or $my_progname [OPTIONS] {start|stop|report} [GNR-GNR,GNR,GNR-GNR,...]
167
+Usage: $my_progname [OPTIONS] {start|reload|stop|report} [GNR,GNR,GNR...]
168
+or $my_progname [OPTIONS] {start|reload|stop|report} [GNR-GNR,GNR,GNR-GNR,...]
169
170
-The GNR means the group number. You can start, stop or report any GNR,
171
+The GNR means the group number. You can start, reload, stop or report any GNR,
172
or several of them at the same time. (See --example) The GNRs list can
173
be comma separated or a dash combined. The latter means that all the
174
GNRs between GNR1-GNR2 will be affected. Without GNR argument all the
175
-groups found will either be started, stopped, or reported. Note that
176
+groups found will either be started, reloaded, stopped, or reported. Note that
177
syntax for specifying GNRs must appear without spaces.
178
179
Options:
180