Skip to content

Commit

Permalink
Import mysql version 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
schisamo committed Jul 12, 2011
1 parent 5c1e7aa commit 97b11ac
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 56 deletions.
69 changes: 54 additions & 15 deletions cookbooks/mysql/README.md
Expand Up @@ -12,6 +12,12 @@ Platform
* Debian, Ubuntu
* CentOS, Red Hat, Fedora

Tested on:

* Debian 5.0
* Ubuntu 10.04
* CentOS 5.5

Cookbooks
---------

Expand All @@ -34,23 +40,26 @@ For example see the USAGE section below.
Attributes
==========

* `mysql[:server_root_password]` - Set the server's root password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
* `mysql[:server_repl_password]` - Set the replication user 'repl' password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
* `mysql[:server_debian_password]` - Set the debian-sys-maint user password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
* `mysql[:bind_address]` - Listen address for MySQLd, default is node's ipaddress.
* `mysql[:datadir]` - Location for mysql data directory, default is "/var/lib/mysql"
* `mysql[:ec2_path]` - location of mysql datadir on EC2 nodes, default "/mnt/mysql"
* `mysql['server_root_password']` - Set the server's root password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
* `mysql['server_repl_password']` - Set the replication user 'repl' password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
* `mysql['server_debian_password']` - Set the debian-sys-maint user password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
* `mysql['bind_address']` - Listen address for MySQLd, default is node's ipaddress.
* `mysql['data_dir']` - Location for mysql data directory, default is "/var/lib/mysql"
* `mysql['conf_dir']` - Location for mysql conf directory, default is "/etc/mysql"
* `mysql['ec2_path']` - location of mysql data_dir on EC2 nodes, default "/mnt/mysql"

Performance tuning attributes, each corresponds to the same-named parameter in my.cnf; default values listed

* `mysql[:tunable][:key_buffer]` = "250M"
* `mysql[:tunable][:max_connections]` = "800"
* `mysql[:tunable][:wait_timeout]` = "180"
* `mysql[:tunable][:net_write_timeout]` = "30"
* `mysql[:tunable][:net_write_timeout]` = "30"
* `mysql[:tunable][:back_log]` = "128"
* `mysql[:tunable][:table_cache]` = "128"
* `mysql[:tunable][:max_heap_table_size]` = "32M"
* `mysql['tunable']['key_buffer']` = "250M"
* `mysql['tunable']['max_connections']` = "800"
* `mysql['tunable']['wait_timeout']` = "180"
* `mysql['tunable']['net_write_timeout']` = "30"
* `mysql['tunable']['net_write_timeout']` = "30"
* `mysql['tunable']['back_log']` = "128"
* `mysql['tunable']['table_cache']` = "128"
* `mysql['tunable']['max_heap_table_size']` = "32M"
* `mysql['tunable']['expire_logs_days']` = "10"
* `mysql['tunable']['max_binlog_size']` = "100M"

Usage
=====
Expand Down Expand Up @@ -83,14 +92,44 @@ On EC2 nodes,

include_recipe "mysql::server_ec2"

When the `ec2_path` doesn't exist we look for a mounted filesystem (eg, EBS) and move the datadir there.
When the `ec2_path` doesn't exist we look for a mounted filesystem (eg, EBS) and move the data_dir there.

The client recipe is already included by server and 'default' recipes.

For more infromation on the compile vs execution phase of a Chef run:

* http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run

Changes/Roadmap
===============

### v1.0.8:

* [COOK-633] ensure "cloud" attribute is available

### v1.0.7:

* [COOK-614] expose all mysql tunable settings in config
* [COOK-617] bind to private IP if available

### v1.0.6:

* [COOK-605] install mysql-client package on ubuntu/debian

### v1.0.5:

* [COOK-465] allow optional remote root connections to mysql
* [COOK-455] improve platform version handling
* externalize conf_dir attribute for easier cross platform support
* change datadir attribute to data_dir for consistency

### v1.0.4:

* fix regressions on debian platform
* [COOK-578] wrap root password in quotes
* [COOK-562] expose all tunables in my.cnf


License and Author
==================

Expand Down
10 changes: 8 additions & 2 deletions cookbooks/mysql/attributes/server.rb
Expand Up @@ -17,15 +17,17 @@
# limitations under the License.
#

default['mysql']['bind_address'] = ipaddress
default['mysql']['datadir'] = "/var/lib/mysql"
default['mysql']['bind_address'] = attribute?('cloud') ? cloud['local_ipv4'] : ipaddress
default['mysql']['data_dir'] = "/var/lib/mysql"

case node["platform"]
when "centos", "redhat", "fedora", "suse"
set['mysql']['conf_dir'] = '/etc'
set['mysql']['socket'] = "/var/lib/mysql/mysql.sock"
set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid"
set['mysql']['old_passwords'] = 1
else
set['mysql']['conf_dir'] = '/etc/mysql'
set['mysql']['socket'] = "/var/run/mysqld/mysqld.sock"
set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid"
set['mysql']['old_passwords'] = 0
Expand All @@ -37,6 +39,7 @@
default['mysql']['ebs_vol_size'] = 50
end

default['mysql']['allow_remote_root'] = false
default['mysql']['tunable']['back_log'] = "128"
default['mysql']['tunable']['key_buffer'] = "256M"
default['mysql']['tunable']['max_allowed_packet'] = "16M"
Expand All @@ -59,4 +62,7 @@
default['mysql']['tunable']['log_slow_queries'] = "/var/log/mysql/slow.log"
default['mysql']['tunable']['long_query_time'] = 2

default['mysql']['tunable']['expire_logs_days'] = 10
default['mysql']['tunable']['max_binlog_size'] = "100M"

default['mysql']['tunable']['innodb_buffer_pool_size'] = "256M"
33 changes: 33 additions & 0 deletions cookbooks/mysql/libraries/helpers.rb
@@ -0,0 +1,33 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Copyright:: Copyright (c) 2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module Opscode
module Mysql
module Helpers

def debian_before_squeeze?
platform?("debian") && (node.platform_version.to_f < 6.0)
end

def ubuntu_before_lucid?
platform?("ubuntu") && (node.platform_version.to_f < 10.0)
end

end
end
end

0 comments on commit 97b11ac

Please sign in to comment.