From b45f7e7c23d3c68ffd8e5d2a0cc8054107d46f6f Mon Sep 17 00:00:00 2001 From: "jani@prima.mysql.com" <> Date: Thu, 7 Dec 2000 15:57:58 +0200 Subject: Changed name mysql_multi_mysqld to mysqld_multi. --- scripts/Makefile.am | 7 +- scripts/mysql_multi_mysqld | 606 --------------------------------------------- scripts/mysqld_multi.sh | 606 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 611 insertions(+), 608 deletions(-) delete mode 100755 scripts/mysql_multi_mysqld create mode 100755 scripts/mysqld_multi.sh (limited to 'scripts') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index ec1b33fb42b..cced1944d9e 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -27,7 +27,8 @@ bin_SCRIPTS = @server_scripts@ \ mysql_convert_table_format \ mysql_find_rows \ mysqlhotcopy \ - mysqldumpslow + mysqldumpslow \ + mysqld_multi EXTRA_SCRIPTS = make_binary_distribution.sh \ msql2mysql.sh \ @@ -42,6 +43,7 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ mysql_find_rows.sh \ mysqlhotcopy.sh \ mysqldumpslow.sh \ + mysqld_multi \ safe_mysqld.sh EXTRA_DIST = $(EXTRA_SCRIPTS) \ @@ -63,7 +65,8 @@ CLEANFILES = @server_scripts@ \ mysql_convert_table_format \ mysql_find_rows \ mysqlhotcopy \ - mysqldumpslow + mysqldumpslow \ + mysqld_multi SUPERCLEANFILES = mysqlbug diff --git a/scripts/mysql_multi_mysqld b/scripts/mysql_multi_mysqld deleted file mode 100755 index 48e72a00aa5..00000000000 --- a/scripts/mysql_multi_mysqld +++ /dev/null @@ -1,606 +0,0 @@ -#!/usr/bin/perl - -use Getopt::Long; -use POSIX qw(strftime); - -$|=1; -$VER="2.1"; - -$opt_config_file = undef(); -$opt_example = 0; -$opt_help = 0; -$opt_log = "/tmp/mysql_multi_mysqld.log"; -$opt_mysqladmin = "mysqladmin"; -$opt_mysqld = "mysqld"; -$opt_no_log = 0; -$opt_password = undef(); -$opt_tcp_ip = 0; -$opt_user = "root"; -$opt_version = 0; - -my ($mysqld, $mysqladmin, $groupids, $homedir, $my_progname); - -$homedir = $ENV{HOME}; -$my_progname = $0; -$my_progname =~ s/.*[\/]//; - -main(); - -#### -#### main sub routine -#### - -sub main -{ - my ($flag_exit); - - if (!defined(my_which(my_print_defaults))) - { - # We can't throw out yet, since --version, --help, or --example may - # have been given - print "WARNING! my_print_defaults command not found!\n"; - print "Please make sure you have this command available and\n"; - print "in your path. The command is available from the latest\n"; - print "MySQL distribution.\n"; - } - my @defops = `my_print_defaults mysql_multi_mysqld`; - chop @defops; - splice @ARGV, 0, 0, @defops; - GetOptions("help","example","version","mysqld=s","mysqladmin=s", - "config-file=s","user=s","password=s","log=s","no-log","tcp-ip") - || die "Wrong option! See $my_progname --help for detailed information!\n"; - - $groupids = $ARGV[1]; - - if ($opt_version) - { - print "$my_progname version $VER by Jani Tolonen\n"; - exit(0); - } - example() if ($opt_example); - if (!defined(($mysqld = my_which($opt_mysqld)))) - { - print "Couldn't find the mysqld binary! Tried: $opt_mysqld\n"; - $flag_exit=1; - } - if (!defined(($mysqladmin = my_which($opt_mysqladmin)))) - { - print "Couldn't find the mysqladmin binary! Tried: $opt_mysqladmin\n"; - $flag_exit=1; - } - usage() if ($opt_help); - if ($flag_exit) - { - print "Error with an option, see $my_progname --help for more info!\n"; - exit(1); - } - if (!defined(my_which(my_print_defaults))) - { - print "ABORT: Can't find command 'my_print_defaults'!\n"; - print "This command is available from the latest MySQL\n"; - print "distribution. Please make sure you have the command\n"; - print "in your PATH.\n"; - exit(1); - } - usage() if (!defined($ARGV[0]) || - ($ARGV[0] ne 'start' && $ARGV[0] ne 'START' && - $ARGV[0] ne 'stop' && $ARGV[0] ne 'STOP' && - $ARGV[0] ne 'report' && $ARGV[0] ne 'REPORT')); - - if (!$opt_no_log) - { - w2log("$my_progname log file version $VER; run: ", - "$opt_log", 1, 0); - } - else - { - print "$my_progname log file version $VER; run: "; - print strftime "%a %b %e %H:%M:%S %Y", localtime; - print "\n"; - } - if ($ARGV[0] eq 'report' || $ARGV[0] eq 'REPORT') - { - report_mysqlds(); - } - elsif ($ARGV[0] eq 'start' || $ARGV[0] eq 'START') - { - start_mysqlds(); - } - else - { - stop_mysqlds(); - } -} - -#### -#### Report living and not running MySQL servers -#### - -sub report_mysqlds -{ - my (@groups, $com, $i, @options, $j, $pec); - - print "Reporting MySQL servers\n"; - if (!$opt_no_log) - { - w2log("\nReporting MySQL servers","$opt_log",0,0); - } - @groups = &find_groups($groupids); - for ($i = 0; defined($groups[$i]); $i++) - { - $com = "my_print_defaults"; - $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : ""; - $com.= " $groups[$i]"; - @options = `$com`; - chop @options; - - $com = "$mysqladmin -u $opt_user -p$opt_password"; - $com.= $opt_tcp_ip ? " -h 127.0.0.1" : ""; - for ($j = 0; defined($options[$j]); $j++) - { - if ((($options[$j] =~ m/^(\-\-socket)(.*)$/) && !$opt_tcp_ip) || - ($options[$j] =~ m/^(\-\-port)(.*)$/)) - { - $com.= " $options[$j]"; - } - } - $com.= " ping >> /dev/null 2>&1"; - system($com); - $pec = $? >> 8; - if ($pec) - { - print "MySQL server from group: $groups[$i] is not running\n"; - if (!$opt_no_log) - { - w2log("MySQL server from group: $groups[$i] is not running", - "$opt_log", 0, 0); - } - } - else - { - print "MySQL server from group: $groups[$i] is running\n"; - if (!$opt_no_log) - { - w2log("MySQL server from group: $groups[$i] is running", - "$opt_log", 0, 0); - } - } - } - if (!$i) - { - print "No groups to be reported (check your GNRs)\n"; - if (!$opt_no_log) - { - w2log("No groups to be reported (check your GNRs)", "$opt_log", 0, 0); - } - } -} - -#### -#### start multiple servers -#### - -sub start_mysqlds() -{ - my (@groups, $com, $i, @options, $j); - - if (!$opt_no_log) - { - w2log("\nStarting MySQL servers\n","$opt_log",0,0); - } - else - { - print "\nStarting MySQL servers\n"; - } - @groups = &find_groups($groupids); - for ($i = 0; defined($groups[$i]); $i++) - { - $com = "my_print_defaults"; - $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : ""; - $com.= " $groups[$i]"; - @options = `$com`; - chop @options; - - $com = "$mysqld"; - for ($j = 0; defined($options[$j]); $j++) - { - $com.= " $options[$j]"; - } - $com.= " >> $opt_log 2>&1" if (!$opt_no_log); - $com.= " &"; - system($com); - } - if (!$i && !$opt_no_log) - { - w2log("No MySQL servers to be started (check your GNRs)", - "$opt_log", 0, 0); - } -} - -#### -#### stop multiple servers -#### - -sub stop_mysqlds() -{ - my (@groups, $com, $i, @options, $j); - - if (!$opt_no_log) - { - w2log("\nStopping MySQL servers\n","$opt_log",0,0); - } - else - { - print "\nStopping MySQL servers\n"; - } - @groups = &find_groups($groupids); - for ($i = 0; defined($groups[$i]); $i++) - { - $com = "my_print_defaults"; - $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : ""; - $com.= " $groups[$i]"; - @options = `$com`; - chop @options; - - $com = "$mysqladmin -u $opt_user -p$opt_password"; - $com.= $opt_tcp_ip ? " -h 127.0.0.1" : ""; - for ($j = 0; defined($options[$j]); $j++) - { - if ((($options[$j] =~ m/^(\-\-socket)(.*)$/) && !$opt_tcp_ip) || - ($options[$j] =~ m/^(\-\-port)(.*)$/)) - { - $com.= " $options[$j]"; - } - } - $com.= " shutdown"; - $com.= " >> $opt_log 2>&1" if (!$opt_no_log); - $com.= " &"; - system($com); - } - if (!$i && !$opt_no_log) - { - w2log("No MySQL servers to be stopped (check your GNRs)", - "$opt_log", 0, 0); - } -} - -#### -#### Find groups. Takes the valid group numbers as an argument, parses -#### them, puts them in the ascending order, removes duplicates and -#### returns the wanted groups accordingly. -#### - -sub find_groups -{ - my ($raw_gids) = @_; - my (@groups, @data, @tmp, $line, $i, $k, @pre_gids, @gids, @tmp2, - $prev_value); - - # Read the lines from the config file to variable 'data' - if (defined($opt_config_file)) - { - open(MY_CNF, "<$opt_config_file") && (@data=) && close(MY_CNF); - } - else - { - if (-f "/etc/my.cnf" && -r "/etc/my.cnf") - { - open(MY_CNF, ") && close(MY_CNF); - } - for ($i = 0; ($line = shift @tmp); $i++) - { - $data[$i] = $line; - } - if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf") - { - open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=) && close(MY_CNF); - } - for (; ($line = shift @tmp); $i++) - { - $data[$i] = $line; - } - } - chop @data; - # Make a list of the wanted group ids - if (defined($raw_gids)) - { - @pre_gids = split(',', $raw_gids); - } - if (defined($raw_gids)) - { - for ($i = 0, $j = 0; defined($pre_gids[$i]); $i++) - { - if ($pre_gids[$i] =~ m/^(\d+)$/) - { - $gids[$j] = $1; - $j++; - } - elsif ($pre_gids[$i] =~ m/^(\d+)(\-)(\d+)$/) - { - for ($k = $1; $k <= $3; $k++) - { - $gids[$j] = $k; - $j++; - } - } - else - { - print "ABORT: Bad GNR: $pre_gids[$i] See $my_progname --help\n"; - exit(1); - } - } - } - # Sort the list of gids numerically in ascending order - @gids = sort {$a <=> $b} @gids; - # Remove non-positive integers and duplicates - for ($i = 0, $j = 0; defined($gids[$i]); $i++) - { - next if ($gids[$i] <= 0); - if (!$i || $prev_value != $gids[$i]) - { - $tmp2[$j] = $gids[$i]; - $j++; - } - $prev_value = $gids[$i]; - } - @gids = @tmp2; - # Find and return the wanted groups - for ($i = 0, $j = 0; defined($data[$i]); $i++) - { - if ($data[$i] =~ m/^(\s*\[\s*)(mysqld)(\d+)(\s*\]\s*)$/) - { - if (defined($raw_gids)) - { - for ($k = 0; defined($gids[$k]); $k++) - { - if ($gids[$k] == $3) - { - $groups[$j] = $2 . $3; - $j++; - } - } - } - else - { - $groups[$j] = $2 . $3; - $j++; - } - } - } - return @groups; -} - -#### -#### w2log: Write to a logfile. -#### 1.arg: append to the log file (given string, or from a file. if a file, -#### file will be read from $opt_logdir) -#### 2.arg: logfile -name (w2log assumes that the logfile is in $opt_logdir). -#### 3.arg. 0 | 1, if true, print current date to the logfile. 3. arg will -#### be ignored, if 1. arg is a file. -#### 4.arg. 0 | 1, if true, first argument is a file, else a string -#### - -sub w2log -{ - my ($msg, $file, $date_flag, $is_file)= @_; - my (@data); - - open (LOGFILE, ">>$opt_log") - or die "FATAL: w2log: Couldn't open log file: $opt_log\n"; - - if ($is_file) - { - open (FROMFILE, "<$msg") && (@data=) && - close(FROMFILE) - or die "FATAL: w2log: Couldn't open file: $msg\n"; - foreach my $line (@data) - { - print LOGFILE "$line"; - } - } - else - { - print LOGFILE "$msg"; - print LOGFILE strftime "%a %b %e %H:%M:%S %Y", localtime if ($date_flag); - print LOGFILE "\n"; - } - close (LOGFILE); - return; -} - -#### -#### my_which is used, because we can't assume that every system has the -#### which -command. my_which can take only one argument at a time. -#### Return values: requested system command with the first found path, -#### or undefined, if not found. -#### - -sub my_which -{ - my ($command) = @_; - my (@paths, $path); - - return $command if (-f $command && -x $command); - @paths = split(':', $ENV{'PATH'}); - foreach $path (@paths) - { - $path .= "/$command"; - return $path if (-f $path && -x $path); - } - return undef(); -} - - -#### -#### example -#### - -sub example -{ - print < mysql -u root -S /tmp/mysql.sock -proot_password -e -# "GRANT SHUTDOWN ON *.* TO multi_admin\@localhost IDENTIFIED BY 'multipass'" -# You will have to do the above for each mysqld running in each data -# directory, that you have (just change the socket, -S=...) -# See more detailed information from chapter: -# '6 The MySQL Access Privilege System' from the MySQL manual. -# 2.pid-file is very important, if you are using safe_mysqld to start mysqld -# (e.g. --mysqld=safe_mysqld) Every mysqld should have it's own pid-file. -# The advantage using safe_mysqld instead of mysqld directly here is, that -# safe_mysqld 'guards' every mysqld process and will restart it, if mysqld -# process fails due to signal kill -9, or similar. (Like segmentation fault, -# which MySQL should never do, of course ;) Please note that safe_mysqld -# script may require that you start it from a certain place. If you have -# problems starting, please see the script. Check especially the lines: -# -------------------------------------------------------------------------- -# MY_PWD=`pwd` -# Check if we are starting this relative (for the binary release) -# if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \ -# -x ./bin/mysqld -# -------------------------------------------------------------------------- -# The above test should be successful, or you may encounter problems. -# 3.Beware of the dangers starting multiple mysqlds in the same data directory. -# Use separate data directories, unless you *KNOW* what you are doing! -# 4.The socket file and the TCP/IP port must be different for every mysqld. -# 5.The first and fifth mysqld was intentionally left out from the example. -# You may have 'gaps' in the config file. This gives you more flexibility. -# The order in which the mysqlds are started or stopped depends on the order -# in which they appear in the config file. -# 6.When you want to refer to a certain group with GNR with this program, -# just use the number in the end of the group name ( [mysqld# <== ) -# 7.You may want to use option '--user' for mysqld, but in order to do this -# you need to be root when you start this script. Having the option -# in the config file doesn't matter; you will just get a warning, if you are -# no the superuser and the mysqld's are started under *your* unix account. -# IMPORTANT: Make sure that the pid-file and the data directory is -# read+write(+execute for the latter one) accessible for *THAT* UNIX user, -# who the specific mysqld process is started as. *DON'T* use the UNIX root -# account for this, unless you *KNOW* what you are doing! -# 8.MOST IMPORTANT: Make sure that you understand the meanings of the options -# that are passed to the mysqlds and why *WOULD YOU WANT* to have separate -# mysqld processes. Starting multiple mysqlds in one data directory *WON'T* -# give you extra performance in a threaded system! It takes too much space -# to describe everything here, please consult the MySQL manual. -# -[mysql_multi_mysqld] -mysqld = /usr/local/bin/safe_mysqld -mysqladmin = /usr/local/bin/mysqladmin -user = multi_admin -password = multipass - -[mysqld2] -socket = /tmp/mysql.sock2 -port = 3307 -pid-file = /usr/local/mysql/var2/hostname.pid2 -datadir = /usr/local/mysql/var2 -language = /usr/local/share/mysql/english -user = john - -[mysqld3] -socket = /tmp/mysql.sock3 -port = 3308 -pid-file = /usr/local/mysql/var3/hostname.pid3 -datadir = /usr/local/mysql/var3 -language = /usr/local/share/mysql/swedish -user = monty - -[mysqld4] -socket = /tmp/mysql.sock4 -port = 3309 -pid-file = /usr/local/mysql/var4/hostname.pid4 -datadir = /usr/local/mysql/var4 -language = /usr/local/share/mysql/estonia -user = tonu - -[mysqld6] -socket = /tmp/mysql.sock6 -port = 3311 -pid-file = /usr/local/mysql/var6/hostname.pid6 -datadir = /usr/local/mysql/var6 -language = /usr/local/share/mysql/japanese -user = jani -EOF - exit(0); -} - -#### -#### usage -#### - -sub usage -{ - print <> 8; + if ($pec) + { + print "MySQL server from group: $groups[$i] is not running\n"; + if (!$opt_no_log) + { + w2log("MySQL server from group: $groups[$i] is not running", + "$opt_log", 0, 0); + } + } + else + { + print "MySQL server from group: $groups[$i] is running\n"; + if (!$opt_no_log) + { + w2log("MySQL server from group: $groups[$i] is running", + "$opt_log", 0, 0); + } + } + } + if (!$i) + { + print "No groups to be reported (check your GNRs)\n"; + if (!$opt_no_log) + { + w2log("No groups to be reported (check your GNRs)", "$opt_log", 0, 0); + } + } +} + +#### +#### start multiple servers +#### + +sub start_mysqlds() +{ + my (@groups, $com, $i, @options, $j); + + if (!$opt_no_log) + { + w2log("\nStarting MySQL servers\n","$opt_log",0,0); + } + else + { + print "\nStarting MySQL servers\n"; + } + @groups = &find_groups($groupids); + for ($i = 0; defined($groups[$i]); $i++) + { + $com = "my_print_defaults"; + $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : ""; + $com.= " $groups[$i]"; + @options = `$com`; + chop @options; + + $com = "$mysqld"; + for ($j = 0; defined($options[$j]); $j++) + { + $com.= " $options[$j]"; + } + $com.= " >> $opt_log 2>&1" if (!$opt_no_log); + $com.= " &"; + system($com); + } + if (!$i && !$opt_no_log) + { + w2log("No MySQL servers to be started (check your GNRs)", + "$opt_log", 0, 0); + } +} + +#### +#### stop multiple servers +#### + +sub stop_mysqlds() +{ + my (@groups, $com, $i, @options, $j); + + if (!$opt_no_log) + { + w2log("\nStopping MySQL servers\n","$opt_log",0,0); + } + else + { + print "\nStopping MySQL servers\n"; + } + @groups = &find_groups($groupids); + for ($i = 0; defined($groups[$i]); $i++) + { + $com = "my_print_defaults"; + $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : ""; + $com.= " $groups[$i]"; + @options = `$com`; + chop @options; + + $com = "$mysqladmin -u $opt_user -p$opt_password"; + $com.= $opt_tcp_ip ? " -h 127.0.0.1" : ""; + for ($j = 0; defined($options[$j]); $j++) + { + if ((($options[$j] =~ m/^(\-\-socket)(.*)$/) && !$opt_tcp_ip) || + ($options[$j] =~ m/^(\-\-port)(.*)$/)) + { + $com.= " $options[$j]"; + } + } + $com.= " shutdown"; + $com.= " >> $opt_log 2>&1" if (!$opt_no_log); + $com.= " &"; + system($com); + } + if (!$i && !$opt_no_log) + { + w2log("No MySQL servers to be stopped (check your GNRs)", + "$opt_log", 0, 0); + } +} + +#### +#### Find groups. Takes the valid group numbers as an argument, parses +#### them, puts them in the ascending order, removes duplicates and +#### returns the wanted groups accordingly. +#### + +sub find_groups +{ + my ($raw_gids) = @_; + my (@groups, @data, @tmp, $line, $i, $k, @pre_gids, @gids, @tmp2, + $prev_value); + + # Read the lines from the config file to variable 'data' + if (defined($opt_config_file)) + { + open(MY_CNF, "<$opt_config_file") && (@data=) && close(MY_CNF); + } + else + { + if (-f "/etc/my.cnf" && -r "/etc/my.cnf") + { + open(MY_CNF, ") && close(MY_CNF); + } + for ($i = 0; ($line = shift @tmp); $i++) + { + $data[$i] = $line; + } + if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf") + { + open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=) && close(MY_CNF); + } + for (; ($line = shift @tmp); $i++) + { + $data[$i] = $line; + } + } + chop @data; + # Make a list of the wanted group ids + if (defined($raw_gids)) + { + @pre_gids = split(',', $raw_gids); + } + if (defined($raw_gids)) + { + for ($i = 0, $j = 0; defined($pre_gids[$i]); $i++) + { + if ($pre_gids[$i] =~ m/^(\d+)$/) + { + $gids[$j] = $1; + $j++; + } + elsif ($pre_gids[$i] =~ m/^(\d+)(\-)(\d+)$/) + { + for ($k = $1; $k <= $3; $k++) + { + $gids[$j] = $k; + $j++; + } + } + else + { + print "ABORT: Bad GNR: $pre_gids[$i] See $my_progname --help\n"; + exit(1); + } + } + } + # Sort the list of gids numerically in ascending order + @gids = sort {$a <=> $b} @gids; + # Remove non-positive integers and duplicates + for ($i = 0, $j = 0; defined($gids[$i]); $i++) + { + next if ($gids[$i] <= 0); + if (!$i || $prev_value != $gids[$i]) + { + $tmp2[$j] = $gids[$i]; + $j++; + } + $prev_value = $gids[$i]; + } + @gids = @tmp2; + # Find and return the wanted groups + for ($i = 0, $j = 0; defined($data[$i]); $i++) + { + if ($data[$i] =~ m/^(\s*\[\s*)(mysqld)(\d+)(\s*\]\s*)$/) + { + if (defined($raw_gids)) + { + for ($k = 0; defined($gids[$k]); $k++) + { + if ($gids[$k] == $3) + { + $groups[$j] = $2 . $3; + $j++; + } + } + } + else + { + $groups[$j] = $2 . $3; + $j++; + } + } + } + return @groups; +} + +#### +#### w2log: Write to a logfile. +#### 1.arg: append to the log file (given string, or from a file. if a file, +#### file will be read from $opt_logdir) +#### 2.arg: logfile -name (w2log assumes that the logfile is in $opt_logdir). +#### 3.arg. 0 | 1, if true, print current date to the logfile. 3. arg will +#### be ignored, if 1. arg is a file. +#### 4.arg. 0 | 1, if true, first argument is a file, else a string +#### + +sub w2log +{ + my ($msg, $file, $date_flag, $is_file)= @_; + my (@data); + + open (LOGFILE, ">>$opt_log") + or die "FATAL: w2log: Couldn't open log file: $opt_log\n"; + + if ($is_file) + { + open (FROMFILE, "<$msg") && (@data=) && + close(FROMFILE) + or die "FATAL: w2log: Couldn't open file: $msg\n"; + foreach my $line (@data) + { + print LOGFILE "$line"; + } + } + else + { + print LOGFILE "$msg"; + print LOGFILE strftime "%a %b %e %H:%M:%S %Y", localtime if ($date_flag); + print LOGFILE "\n"; + } + close (LOGFILE); + return; +} + +#### +#### my_which is used, because we can't assume that every system has the +#### which -command. my_which can take only one argument at a time. +#### Return values: requested system command with the first found path, +#### or undefined, if not found. +#### + +sub my_which +{ + my ($command) = @_; + my (@paths, $path); + + return $command if (-f $command && -x $command); + @paths = split(':', $ENV{'PATH'}); + foreach $path (@paths) + { + $path .= "/$command"; + return $path if (-f $path && -x $path); + } + return undef(); +} + + +#### +#### example +#### + +sub example +{ + print < mysql -u root -S /tmp/mysql.sock -proot_password -e +# "GRANT SHUTDOWN ON *.* TO multi_admin\@localhost IDENTIFIED BY 'multipass'" +# You will have to do the above for each mysqld running in each data +# directory, that you have (just change the socket, -S=...) +# See more detailed information from chapter: +# '6 The MySQL Access Privilege System' from the MySQL manual. +# 2.pid-file is very important, if you are using safe_mysqld to start mysqld +# (e.g. --mysqld=safe_mysqld) Every mysqld should have it's own pid-file. +# The advantage using safe_mysqld instead of mysqld directly here is, that +# safe_mysqld 'guards' every mysqld process and will restart it, if mysqld +# process fails due to signal kill -9, or similar. (Like segmentation fault, +# which MySQL should never do, of course ;) Please note that safe_mysqld +# script may require that you start it from a certain place. If you have +# problems starting, please see the script. Check especially the lines: +# -------------------------------------------------------------------------- +# MY_PWD=`pwd` +# Check if we are starting this relative (for the binary release) +# if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \ +# -x ./bin/mysqld +# -------------------------------------------------------------------------- +# The above test should be successful, or you may encounter problems. +# 3.Beware of the dangers starting multiple mysqlds in the same data directory. +# Use separate data directories, unless you *KNOW* what you are doing! +# 4.The socket file and the TCP/IP port must be different for every mysqld. +# 5.The first and fifth mysqld was intentionally left out from the example. +# You may have 'gaps' in the config file. This gives you more flexibility. +# The order in which the mysqlds are started or stopped depends on the order +# in which they appear in the config file. +# 6.When you want to refer to a certain group with GNR with this program, +# just use the number in the end of the group name ( [mysqld# <== ) +# 7.You may want to use option '--user' for mysqld, but in order to do this +# you need to be root when you start this script. Having the option +# in the config file doesn't matter; you will just get a warning, if you are +# no the superuser and the mysqld's are started under *your* unix account. +# IMPORTANT: Make sure that the pid-file and the data directory is +# read+write(+execute for the latter one) accessible for *THAT* UNIX user, +# who the specific mysqld process is started as. *DON'T* use the UNIX root +# account for this, unless you *KNOW* what you are doing! +# 8.MOST IMPORTANT: Make sure that you understand the meanings of the options +# that are passed to the mysqlds and why *WOULD YOU WANT* to have separate +# mysqld processes. Starting multiple mysqlds in one data directory *WON'T* +# give you extra performance in a threaded system! It takes too much space +# to describe everything here, please consult the MySQL manual. +# +[mysqld_multi] +mysqld = /usr/local/bin/safe_mysqld +mysqladmin = /usr/local/bin/mysqladmin +user = multi_admin +password = multipass + +[mysqld2] +socket = /tmp/mysql.sock2 +port = 3307 +pid-file = /usr/local/mysql/var2/hostname.pid2 +datadir = /usr/local/mysql/var2 +language = /usr/local/share/mysql/english +user = john + +[mysqld3] +socket = /tmp/mysql.sock3 +port = 3308 +pid-file = /usr/local/mysql/var3/hostname.pid3 +datadir = /usr/local/mysql/var3 +language = /usr/local/share/mysql/swedish +user = monty + +[mysqld4] +socket = /tmp/mysql.sock4 +port = 3309 +pid-file = /usr/local/mysql/var4/hostname.pid4 +datadir = /usr/local/mysql/var4 +language = /usr/local/share/mysql/estonia +user = tonu + +[mysqld6] +socket = /tmp/mysql.sock6 +port = 3311 +pid-file = /usr/local/mysql/var6/hostname.pid6 +datadir = /usr/local/mysql/var6 +language = /usr/local/share/mysql/japanese +user = jani +EOF + exit(0); +} + +#### +#### usage +#### + +sub usage +{ + print <