diff options
-rw-r--r-- | files/config/my.cnf.Debian | 34 | ||||
-rw-r--r-- | files/munin/mysql_connections | 40 | ||||
-rw-r--r-- | files/scripts/CentOS/setmysqlpass.sh | 9 | ||||
-rw-r--r-- | files/scripts/Debian/setmysqlpass.sh | 9 | ||||
-rw-r--r-- | manifests/server/base.pp | 4 | ||||
-rw-r--r-- | manifests/server/munin/default.pp | 18 |
6 files changed, 69 insertions, 45 deletions
diff --git a/files/config/my.cnf.Debian b/files/config/my.cnf.Debian index 1935cfb..21daf6a 100644 --- a/files/config/my.cnf.Debian +++ b/files/config/my.cnf.Debian @@ -50,27 +50,29 @@ bind-address = 127.0.0.1 # key_buffer = 16M max_allowed_packet = 16M -thread_stack = 128K -thread_cache_size = 8 +thread_stack = 192K +thread_cache_size = 8 # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched -myisam-recover = BACKUP +myisam-recover = BACKUP #max_connections = 100 #table_cache = 64 #thread_concurrency = 10 # # * Query Cache Configuration # -query_cache_limit = 1M +query_cache_limit = 1M query_cache_size = 16M # # * Logging and Replication # # Both location gets rotated by the cronjob. # Be aware that this log type is a performance killer. -#log = /var/log/mysql/mysql.log +# As of 5.1 you can enable the log at runtime! +#general_log_file = /var/log/mysql/mysql.log +#general_log = 1 # -# Error logging goes to syslog. This is a Debian improvement :) +# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf. # # Here you can see queries with especially long duration #log_slow_queries = /var/log/mysql/mysql-slow.log @@ -87,17 +89,10 @@ max_binlog_size = 100M #binlog_do_db = include_database_name #binlog_ignore_db = include_database_name # -# * BerkeleyDB -# -# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. -skip-bdb -# # * InnoDB # # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. # Read the manual for more InnoDB related options. There are many! -# You might want to disable InnoDB to shrink the mysqld process by circa 100MB. -#skip-innodb # # * Security Features # @@ -124,20 +119,7 @@ max_allowed_packet = 16M key_buffer = 16M # -# * NDB Cluster -# -# See /usr/share/doc/mysql-server-*/README.Debian for more information. -# -# The following configuration is read by the NDB Data Nodes (ndbd processes) -# not from the NDB Management Nodes (ndb_mgmd processes). -# -# [MYSQL_CLUSTER] -# ndb-connectstring=127.0.0.1 - - -# # * IMPORTANT: Additional settings that can override those from this file! # The files must end with '.cnf', otherwise they'll be ignored. # !includedir /etc/mysql/conf.d/ - diff --git a/files/munin/mysql_connections b/files/munin/mysql_connections index 658b401..8ba9ee2 100644 --- a/files/munin/mysql_connections +++ b/files/munin/mysql_connections @@ -1,5 +1,21 @@ #!/usr/bin/perl # +# Copyright (C) 2008 Rackspace US, Inc. <http://www.rackspace.com> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; version 2 dated June, +# 1991. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see http://www.gnu.org/licenses/gpl.txt +# +# # This plugin is based off of the Connection Usage # section of the MySQL Connection Health Page # @@ -83,7 +99,7 @@ sub poll_variables { sub print_graph_information { print <<EOM; graph_title MySQL Connections -graph_args --base 1000 -l 0 +graph_args --base 1000 --lower-limit 0 graph_vlabel Connections graph_info The number of current connections with respect to the max_connections setting. graph_category mysql @@ -106,20 +122,20 @@ sub test_service { system ("$MYSQLADMIN --version >/dev/null 2>/dev/null"); if ($? == 0) { - system ("$TEST_COMMAND >/dev/null 2>/dev/null"); - if ($? == 0) - { - print "yes\n"; - $return = 0; - } - else - { - print "no (could not connect to mysql)\n"; - } + system ("$TEST_COMMAND >/dev/null 2>/dev/null"); + if ($? == 0) + { + print "yes\n"; + $return = 0; + } + else + { + print "no (could not connect to mysql)\n"; + } } else { - print "no (mysqladmin not found)\n"; + print "no (mysqladmin not found)\n"; } exit $return; } diff --git a/files/scripts/CentOS/setmysqlpass.sh b/files/scripts/CentOS/setmysqlpass.sh index d762a20..01d8fbf 100644 --- a/files/scripts/CentOS/setmysqlpass.sh +++ b/files/scripts/CentOS/setmysqlpass.sh @@ -1,12 +1,17 @@ #!/bin/sh -test $# -gt 0 || exit 1 +test -f /root/.my.cnf || exit 1 + +rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') /sbin/service mysqld stop /usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin & sleep 5 -echo "USE mysql; UPDATE user SET Password=PASSWORD('$1') WHERE User='root' AND Host='localhost';" | mysql -u root +mysql -u root mysql <<EOF +UPDATE mysql.user SET Password=PASSWORD('$rootpw') WHERE User='root' AND Host='localhost'; +FLUSH PRIVILEGES; +EOF killall mysqld # chown to be on the safe side chown mysql.mysql /var/lib/mysql/mysql-bin.* diff --git a/files/scripts/Debian/setmysqlpass.sh b/files/scripts/Debian/setmysqlpass.sh index 427daf0..f7d5357 100644 --- a/files/scripts/Debian/setmysqlpass.sh +++ b/files/scripts/Debian/setmysqlpass.sh @@ -1,12 +1,17 @@ #!/bin/sh -test $# -gt 0 || exit 1 +test -f /root/.my.cnf || exit 1 + +rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') /etc/init.d/mysql stop /usr/sbin/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql --log-bin=/var/lib/mysql/mysql-bin & sleep 5 -echo "USE mysql; UPDATE user SET Password=PASSWORD('$1') WHERE User='root' AND Host='localhost';" | mysql -u root +mysql -u root mysql <<EOF +UPDATE mysql.user SET Password=PASSWORD('$rootpw') WHERE User='root' AND Host='localhost'; +FLUSH PRIVILEGES; +EOF killall mysqld sleep 15 # chown to be on the safe side diff --git a/manifests/server/base.pp b/manifests/server/base.pp index 7ddff38..07b26b8 100644 --- a/manifests/server/base.pp +++ b/manifests/server/base.pp @@ -55,8 +55,8 @@ class mysql::server::base { } exec { 'mysql_set_rootpw': - command => "/usr/local/sbin/setmysqlpass.sh ${mysql_rootpw}", - unless => "/usr/bin/mysqladmin -uroot status > /dev/null", + command => '/usr/local/sbin/setmysqlpass.sh', + unless => '/usr/bin/mysqladmin -uroot status > /dev/null', require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ], refreshonly => true, } diff --git a/manifests/server/munin/default.pp b/manifests/server/munin/default.pp index 2660ea0..d64c831 100644 --- a/manifests/server/munin/default.pp +++ b/manifests/server/munin/default.pp @@ -20,9 +20,25 @@ class mysql::server::munin::default inherits mysql::server::munin::base { config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost", require => [ Mysql_grant['munin@localhost'], Mysql_user['munin@localhost'], Package['mysql'] ]; - [ mysql_connections, mysql_qcache, mysql_cache_mem, mysql_size_all ]: + [ mysql_connections, mysql_qcache, mysql_qcache_mem, mysql_size_all ]: script_path_in => "/usr/local/share/munin-plugins", config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost", require => [ Mysql_grant['munin@localhost'], Mysql_user['munin@localhost'], Package['mysql'] ]; } + + Munin::Plugin::Deploy { + config => "env.mysqlopts --user=munin --password=$munin_mysql_password -h localhost", + require => + [ Mysql_grant['munin@localhost'], + Mysql_user['munin@localhost'], + Package['mysql'] ] + } + munin::plugin::deploy{ + 'mysql_connections': + source => 'mysql/munin/mysql_connections'; + 'mysql_qcache': + source => 'mysql/munin/mysql_qcache'; + 'mysql_qcache_mem': + source => 'mysql/munin/mysql_qcache_mem'; + } } |