diff options
author | Michael Widenius <monty@askmonty.org> | 2011-03-23 19:22:38 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-03-23 19:22:38 +0200 |
commit | eaed26053da306109d93cbce42b3d275c3e62471 (patch) | |
tree | 8055d6ee835d938d153d0b66caa2bfd55f120ca8 /scripts | |
parent | 3e46f488e5034da1557b2d6c18442dd9fdb40138 (diff) | |
parent | 7de98f2ffbb273b105321fc88bf536a1fd55114a (diff) | |
download | mariadb-git-eaed26053da306109d93cbce42b3d275c3e62471.tar.gz |
Merge with base 5.2
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sh | 2 | ||||
-rw-r--r-- | scripts/mysql_install_db.pl.in | 4 | ||||
-rw-r--r-- | scripts/mysql_install_db.sh | 36 | ||||
-rw-r--r-- | scripts/mysql_secure_installation.sh | 4 | ||||
-rw-r--r-- | scripts/mysqld_multi.sh | 2 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 26 | ||||
-rw-r--r-- | scripts/mysqldumpslow.sh | 59 |
7 files changed, 86 insertions, 47 deletions
diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index aaf0553151f..f0147b22878 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -103,7 +103,7 @@ do fi done -parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables` +parse_arguments `$print_defaults $defaults mysql_install_db client client-server client-mariadb mysql_fix_privilege_tables` parse_arguments PICK-ARGS-FROM-ARGV "$@" if test -z "$password" diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in index 0985c27f0ec..2119a1b650a 100644 --- a/scripts/mysql_install_db.pl.in +++ b/scripts/mysql_install_db.pl.in @@ -116,7 +116,7 @@ sub parse_arguments "basedir=s", "builddir=s", # FIXME not documented "srcdir=s", - "ldata|datadir=s", + "ldata|datadir|data=s", # Note that the user will be passed to mysqld so that it runs # as 'user' (crucial e.g. if log-bin=/some_other_path/ @@ -274,7 +274,7 @@ else my @default_options; my $cmd = quote_options($print_defaults,$opt->{'defaults-file'}, - "mysqld","mysql_install_db"); + "mysqld","mariadb","mysql_install_db","server","client-server"); open(PIPE, "$cmd |") or error($opt,"can't run $cmd: $!"); while ( <PIPE> ) { diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 2d3775afb3a..6b1b1e6f121 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -50,6 +50,8 @@ Usage: $0 [OPTIONS] use hostnames will use IP addresses. --ldata=path The path to the MariaDB data directory. Same as --datadir. + --no-defaults Don't read any configuration files (my.cnf). + --defaults-file=path Read only this configuration file. --rpm For internal use. This option is used by RPM files during the MariaDB installation process. --skip-name-resolve Use IP addresses rather than hostnames when creating @@ -79,6 +81,13 @@ s_echo() fi } +link_to_help() +{ + echo + echo "The latest information about mysql_install_db is available at" + echo "http://kb.askmonty.org/v/installing-system-tables-mysql_install_db." +} + parse_arg() { echo "$1" | sed -e 's/^[^=]*=//' @@ -103,7 +112,7 @@ parse_arguments() --basedir=*) basedir=`parse_arg "$arg"` ;; --builddir=*) builddir=`parse_arg "$arg"` ;; --srcdir=*) srcdir=`parse_arg "$arg"` ;; - --ldata=*|--datadir=*) ldata=`parse_arg "$arg"` ;; + --ldata=*|--datadir=*|--data=*) ldata=`parse_arg "$arg"` ;; --user=*) # Note that the user will be passed to mysqld so that it runs # as 'user' (crucial e.g. if log-bin=/some_other_path/ @@ -194,7 +203,7 @@ cannot_find_file() echo "If you are using a binary release, you must either be at the top" echo "level of the extracted archive, or pass the --basedir option" echo "pointing to that location." - echo + link_to_help } # Ok, let's go. We first need to parse arguments which are required by @@ -213,6 +222,7 @@ parse_arguments PICK-ARGS-FROM-ARGV "$@" if test -n "$srcdir" && test -n "$basedir" then echo "ERROR: Specify either --basedir or --srcdir, not both." + link_to_help exit 1 fi if test -n "$srcdir" @@ -242,7 +252,7 @@ fi # Now we can get arguments from the groups [mysqld] and [mysql_install_db] # in the my.cfg file, then re-run to merge with command line arguments. -parse_arguments `$print_defaults $defaults mysqld mysql_install_db` +parse_arguments `$print_defaults $defaults mysqld mariadb mysql_install_db client-server` parse_arguments PICK-ARGS-FROM-ARGV "$@" # Configure paths to support files @@ -335,6 +345,7 @@ then echo "hostname." echo "If you want to solve this at a later stage, restart this script" echo "with the --force option" + link_to_help exit 1 fi echo "WARNING: The host '$hostname' could not be looked up with resolveip." @@ -356,7 +367,12 @@ for dir in $ldata $ldata/mysql $ldata/test do if test ! -d $dir then - mkdir -p $dir + if ! `mkdir -p $dir` + then + echo "Fatal error Can't create database directory '$dir'" + link_to_help + exit 1 + fi chmod 700 $dir fi if test -w / -a ! -z "$user" @@ -384,12 +400,12 @@ fi mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}" mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \ --basedir=$basedir --datadir=$ldata --log-warnings=0 --loose-skip-innodb \ - --loose-skip-ndbcluster $args --max_allowed_packet=8M \ + --loose-skip-ndbcluster --loose-skip-pbxt $args --max_allowed_packet=8M \ --default-storage-engine=myisam \ --net_buffer_length=16K" # Create the system and help tables by passing them to "mysqld --bootstrap" -s_echo "Installing MariaDB/MySQL system tables..." +s_echo "Installing MariaDB/MySQL system tables in '$ldata' ..." if { echo "use mysql;"; cat $create_system_tables $fill_system_tables; } | eval "$filter_cmd_line" | $mysqld_install_cmd_line > /dev/null then s_echo "OK" @@ -410,9 +426,7 @@ else echo echo "Try 'mysqld --help' if you have problems with paths. Using" echo "--general-log gives you a log in $ldata that may be helpful." - echo - echo "The latest information about mysql_install_db is available at" - echo "http://kb.askmonty.org/v/installing-system-tables-mysql_install_db." + link_to_help echo "MariaDB is hosted on launchpad; You can find the latest source and" echo "email lists at http://launchpad.net/maria" echo @@ -454,13 +468,13 @@ then echo "databases and anonymous user created by default. This is" echo "strongly recommended for production servers." echo - echo "See the MySQL manual for more instructions." + echo "See the MariaDB knowledge or the MySQL manual for more instructions." if test "$in_rpm" -eq 0 then echo echo "You can start the MariaDB daemon with:" - echo "cd $basedir ; $bindir/mysqld_safe &" + echo "cd $basedir ; $bindir/mysqld_safe --datadir=$ldata" echo echo "You can test the MariaDB daemon with mysql-test-run.pl" echo "cd $basedir/mysql-test ; perl mysql-test-run.pl" diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index fe93522aa87..d59f1ac8565 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -165,9 +165,9 @@ then exit 1 fi -# Now we can get arguments from the group [client] +# Now we can get arguments from the group [client] and [client-server] # in the my.cfg file, then re-run to merge with command line arguments. -parse_arguments `$print_defaults $defaults client` +parse_arguments `$print_defaults $defaults client client-server client-mariadb` parse_arguments PICK-ARGS-FROM-ARGV "$@" # Configure paths to support files diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 3d3853bcb22..d420eb4c13c 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -200,7 +200,7 @@ sub defaults_for_group sub init_log { - foreach my $opt (defaults_for_group('mysqld')) + foreach my $opt (defaults_for_group('mysqld mariadb')) { if ($opt =~ m/^--datadir=(.*)/ && -d "$1" && -w "$1") { diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index e4e5f1a1510..cae63343cfc 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -159,9 +159,13 @@ parse_arguments() { case "$arg" in # these get passed explicitly to mysqld --basedir=*) MY_BASEDIR_VERSION="$val" ;; - --datadir=*) DATADIR="$val" ;; + --datadir=*|--data=*) DATADIR="$val" ;; --pid-file=*) pid_file="$val" ;; --user=*) user="$val"; SET_USER=1 ;; + --log-basename=*|--hostname=*|--loose-log-basename=*) + pid_file="$val.pid"; + err_log="$val.err"; + ;; # these might have been set in a [mysqld_safe] section of my.cnf # they are added to mysqld command line to override settings from my.cnf @@ -313,7 +317,7 @@ append_arg_to_args () { args= SET_USER=2 -parse_arguments `$print_defaults $defaults --loose-verbose mysqld server` +parse_arguments `$print_defaults $defaults --loose-verbose mysqld mariadb server client-server` if test $SET_USER -eq 2 then SET_USER=0 @@ -411,7 +415,11 @@ safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}} mysql_unix_port_dir=`dirname $safe_mysql_unix_port` if [ ! -d $mysql_unix_port_dir ] then - mkdir $mysql_unix_port_dir + if ! `mkdir -p $mysql_unix_port_dir` + then + echo "Fatal error Can't create database directory '$mysql_unix_port'" + exit 1 + fi chown $user $mysql_unix_port_dir chmod 755 $mysql_unix_port_dir fi @@ -434,14 +442,14 @@ fi if test -z "$pid_file" then - pid_file="$DATADIR/`@HOSTNAME@`.pid" -else - case "$pid_file" in - /* ) ;; - * ) pid_file="$DATADIR/$pid_file" ;; - esac + pid_file="`@HOSTNAME@`.pid" fi +# MariaDB wants pid file without datadir append_arg_to_args "--pid-file=$pid_file" +case "$pid_file" in + /* ) ;; + * ) pid_file="$DATADIR/$pid_file" ;; +esac if test -n "$mysql_unix_port" then diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh index 8580b8e6203..de565678f9b 100644 --- a/scripts/mysqldumpslow.sh +++ b/scripts/mysqldumpslow.sh @@ -20,13 +20,13 @@ GetOptions(\%opt, 'v|verbose+',# verbose 'help+', # write usage info 'd|debug+', # debug - 's=s', # what to sort by (al, at, ar, c, t, l, r) + 's=s', # what to sort by (al, at, ar, ae, c, t, l, r, e) 'r!', # reverse the sort order (largest last instead of first) 't=i', # just show the top n queries 'a!', # don't abstract all numbers to N and strings to 'S' 'n=i', # abstract numbers with at least n digits within names 'g=s', # grep: only consider stmts that include this string - 'h=s', # hostname of db server for *-slow.log filename (can be wildcard) + 'h=s', # hostname/basename of db server for *-slow.log filename (can be wildcard) 'i=s', # name of server instance (if using mysql.server startup script) 'l!', # don't subtract lock time from total time ) or usage("bad option"); @@ -34,34 +34,42 @@ GetOptions(\%opt, $opt{'help'} and usage(); unless (@ARGV) { - my $defaults = `my_print_defaults mysqld`; - my $basedir = ($defaults =~ m/--basedir=(.*)/)[0] - or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults"; - warn "basedir=$basedir\n" if $opt{v}; + my $defaults = `my_print_defaults mysqld mariadb`; - my $datadir = ($defaults =~ m/--datadir=(.*)/)[0]; - my $slowlog = ($defaults =~ m/--log-slow-queries=(.*)/)[0]; + my $datadir = ($defaults =~ m/--datadir=(.*)/g)[-1]; if (!$datadir or $opt{i}) { # determine the datadir from the instances section of /etc/my.cnf, if any my $instances = `my_print_defaults instances`; - die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults" + die "Can't determine datadir from 'my_print_defaults instances' output: $defaults" unless $instances; my @instances = ($instances =~ m/^--(\w+)-/mg); die "No -i 'instance_name' specified to select among known instances: @instances.\n" unless $opt{i}; die "Instance '$opt{i}' is unknown (known instances: @instances)\n" unless grep { $_ eq $opt{i} } @instances; - $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0] + $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/g)[-1] or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances"; warn "datadir=$datadir\n" if $opt{v}; } - if ( -f $slowlog ) { + my $slowlog = ($defaults =~ m/--log[-_]slow[-_]queries=(.*)/g)[-1]; + if (!$slowlog) + { + $slowlog = ($defaults =~ m/--slow[-_]query[-_]log[-_]file=(.*)/g)[-1]; + } + if ( $slowlog ) + { @ARGV = ($slowlog); die "Can't find '$slowlog'\n" unless @ARGV; - } else { - @ARGV = <$datadir/$opt{h}-slow.log>; - die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV; + } + else + { + if (!$opt{h}) + { + $opt{h}= ($defaults =~ m/--log[-_]basename=(.*)/g)[-1]; + } + @ARGV = <$datadir/$opt{h}-slow.log>; + die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV; } } @@ -83,8 +91,10 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) { s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//; my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('',''); - s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+).*\n//; - my ($t, $l, $r) = ($1, $2, $3); + s/^# Thread_id: [0-9]+\s+Schema: [^\n]+\n//; + s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+)\s+Rows_examined: ([0-9.]+).*\n//; + my ($t, $l, $r, $e) = ($1, $2, $3, $4); + $t -= $l unless $opt{l}; # remove fluff that mysqld writes to log when it (re)starts: @@ -92,6 +102,11 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) { s!^Tcp port: \d+ Unix socket: \S+\n!!mg; s!^Time.*Id.*Command.*Argument.*\n!!mg; + # Remove optimizer info + s!^# QC_Hit: \S+\s+Full_scan: \S+\s+Full_join: \S+\s+Tmp_table: \S+\s+Tmp_table_on_disk: \S+[^\n]+\n!!mg; + s!^# Filesort: \S+\s+Filesort_on_disk: \S+[^\n]+\n!!mg; + s!^# Full_scan: \S+\s+Full_join: \S+[^\n]+\n!!mg; + s/^use \w+;\n//; # not consistently added s/^SET timestamp=\d+;\n//; @@ -121,6 +136,7 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) { $s->{t} += $t; $s->{l} += $l; $s->{r} += $r; + $s->{e} += $e; $s->{users}->{$user}++ if $user; $s->{hosts}->{$host}++ if $host; @@ -129,10 +145,11 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) { foreach (keys %stmt) { my $v = $stmt{$_} || die; - my ($c, $t, $l, $r) = @{ $v }{qw(c t l r)}; + my ($c, $t, $l, $r, $e) = @{ $v }{qw(c t l r e)}; $v->{at} = $t / $c; $v->{al} = $l / $c; $v->{ar} = $r / $c; + $v->{ae} = $e / $c; } my @sorted = sort { $stmt{$b}->{$opt{s}} <=> $stmt{$a}->{$opt{s}} } keys %stmt; @@ -141,13 +158,13 @@ my @sorted = sort { $stmt{$b}->{$opt{s}} <=> $stmt{$a}->{$opt{s}} } keys %stmt; foreach (@sorted) { my $v = $stmt{$_} || die; - my ($c, $t,$at, $l,$al, $r,$ar) = @{ $v }{qw(c t at l al r ar)}; + my ($c, $t,$at, $l,$al, $r,$ar,$e, $ae) = @{ $v }{qw(c t at l al r ar e ae)}; my @users = keys %{$v->{users}}; my $user = (@users==1) ? $users[0] : sprintf "%dusers",scalar @users; my @hosts = keys %{$v->{hosts}}; my $host = (@hosts==1) ? $hosts[0] : sprintf "%dhosts",scalar @hosts; - printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows=%.1f (%d), $user\@$host\n%s\n\n", - $c, $at,$t, $al,$l, $ar,$r, $_; + printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows_sent=%.1f (%d), Rows_examined=%.1f (%d), $user\@$host\n%s\n\n", + $c, $at,$t, $al,$l, $ar,$r, $ae, $e, $_; } sub usage { @@ -163,7 +180,7 @@ Parse and summarize the MySQL slow query log. Options are -v verbose -d debug - -s ORDER what to sort by (al, at, ar, c, l, r, t), 'at' is default + -s ORDER what to sort by (al, at, ar, ae, c, l, r, e, t), 'at' is default al: average lock time ar: average rows sent at: average query time |