diff options
author | Michael Widenius <monty@askmonty.org> | 2011-03-18 17:03:43 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-03-18 17:03:43 +0200 |
commit | 0fae0335d46c5f1757b59926be60a41eb0224837 (patch) | |
tree | 600e29476bf817514a5b303b3f4f5988d964bf38 /scripts | |
parent | ce675406ca8dbc1532a908803a1371de8432d466 (diff) | |
download | mariadb-git-0fae0335d46c5f1757b59926be60a41eb0224837.tar.gz |
Ensure that all clients reads the appropriate 'client', client-mariadb and 'mariadb' sections from my.cnf
The mysqld server and all clients now reads the new client-server section
Fixed that mysqldumpslow supports new slow log formats and new mysqld --slow- options
client/mysql.cc:
Read also client-server and client-mariadb sections.
client/mysql_upgrade.c:
Read also client-server and client-mariadb sections.
client/mysqladmin.cc:
Read also client-server and client-mariadb sections.
client/mysqlbinlog.cc:
Read also client-server and client-mariadb sections.
client/mysqlcheck.c:
Read also client-server and client-mariadb sections.
client/mysqldump.c:
Read also client-server and client-mariadb sections.
client/mysqlimport.c:
Read also client-server and client-mariadb sections.
client/mysqlshow.c:
Read also client-server and client-mariadb sections.
client/mysqltest.cc:
Read also client-server and client-mariadb sections.
extra/my_print_defaults.c:
Updated help text
scripts/mysql_fix_privilege_tables.sh:
Read also sections client client-server client-mariadb
scripts/mysql_install_db.pl.in:
Also allow --data=* option
Read also groups mariadb, server and client-server.
scripts/mysql_install_db.sh:
Also allow --data=* option
Read also groups mariadb, server and client-server.
Added --lose-skip-pbxt to bootstrap
scripts/mysql_secure_installation.sh:
Read also groups client-server and client-mariadb
scripts/mysqld_multi.sh:
Read also group mariadb
scripts/mysqld_safe.sh:
Read also groups mariadb server and client-server
scripts/mysqldumpslow.sh:
Fixed to support new slow log formats
Added sorting on -ae (aggregated number of retreived rows) and e (retrieved rows)
Read also group 'mariadb'
If there is many instances of same option, use last one.
Get slow log file from options log-slow-queries=filename or query-log-file=filename
Added support for future --log-basename option
sql-common/client.c:
Read also groups 'client-server' and 'client-mariadb'
tests/mysql_client_test.c:
Read also groups 'client-server' and 'client-mariadb'
tests/thread_test.c:
Read also groups 'client-server' and 'client-mariadb'
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 | 6 | ||||
-rw-r--r-- | scripts/mysql_secure_installation.sh | 4 | ||||
-rw-r--r-- | scripts/mysqld_multi.sh | 2 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 2 | ||||
-rw-r--r-- | scripts/mysqldumpslow.sh | 59 |
7 files changed, 48 insertions, 31 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 18bd713c041..606ff8c1978 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..dc27dbb0f49 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -103,7 +103,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/ @@ -242,7 +242,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 @@ -384,7 +384,7 @@ 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" 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..40db034d29b 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -313,7 +313,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 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 |