Permalink
Browse files

updated mysql cookbook

  • Loading branch information...
1 parent 8736591 commit 689167251d084f50ed75b387bbc96c0b05a71b82 @sandfish8 sandfish8 committed Sep 14, 2012
View
53 mysql/CHANGELOG.md
@@ -0,0 +1,53 @@
+## v1.2.6:
+
+* [COOK-1113] - Use an attribute to determine if upstart is used
+* [COOK-1121] - Add support for Windows
+* [COOK-1140] - Fix conf.d on Debian
+* [COOK-1151] - Fix server_ec2 handling /var/lib/mysql bind mount
+* [COOK-1321] - Document setting password attributes for solo
+
+## v1.2.4
+
+* [COOK-992] - fix FATAL nameerror
+* [COOK-827] - `mysql:server_ec2` recipe can't mount `data_dir`
+* [COOK-945] - FreeBSD support
+
+## v1.2.2
+
+* [COOK-826] mysql::server recipe doesn't quote password string
+* [COOK-834] Add 'scientific' and 'amazon' platforms to mysql cookbook
+
+## v1.2.1
+
+* [COOK-644] Mysql client cookbook 'package missing' error message is confusing
+* [COOK-645] RHEL6/CentOS6 - mysql cookbook contains 'skip-federated' directive which is unsupported on MySQL 5.1
+
+## v1.2.0
+
+* [COOK-684] remove mysql_database LWRP
+
+## 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
View
29 mysql/CONTRIBUTING
@@ -0,0 +1,29 @@
+If you would like to contribute, please open a ticket in JIRA:
+
+* http://tickets.opscode.com
+
+Create the ticket in the COOK project and use the cookbook name as the
+component.
+
+For all code contributions, we ask that contributors sign a
+contributor license agreement (CLA). Instructions may be found here:
+
+* http://wiki.opscode.com/display/chef/How+to+Contribute
+
+When contributing changes to individual cookbooks, please do not
+modify the version number in the metadata.rb. Also please do not
+update the CHANGELOG.md for a new version. Not all changes to a
+cookbook may be merged and released in the same versions. Opscode will
+handle the version updates during the release process. You are welcome
+to correct typos or otherwise make updates to documentation in the
+README.
+
+If a contribution adds new platforms or platform versions, indicate
+such in the body of the commit message(s), and update the relevant
+COOK ticket. When writing commit messages, it is helpful for others if
+you indicate the COOK ticket. For example:
+
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
+
+In the ticket itself, it is also helpful if you include log output of
+a successful Chef run, but this is not absolutely required.
View
201 mysql/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+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.
View
119 mysql/README.md
@@ -0,0 +1,119 @@
+Description
+===========
+
+Installs and configures MySQL client or server.
+
+Requirements
+============
+
+Platform
+--------
+
+* Debian, Ubuntu
+* CentOS, Red Hat, Fedora
+
+Tested on:
+
+* Debian 5.0
+* Ubuntu 10.04
+* CentOS 5.5
+
+Cookbooks
+---------
+
+Requires Opscode's openssl cookbook for secure password generation. See _Attributes_ and _Usage_ for more information.
+
+Requires a C compiler and Ruby development package in order to build mysql gem with native extensions. On Debian and Ubuntu systems this is satisfied by installing the "build-essential" and "ruby-dev" packages before running Chef. See USAGE below for information on how to handle this during a Chef run.
+
+Resources and Providers
+=======================
+
+The LWRP that used to ship as part of this cookbook has been refactored into the [database](https://github.com/opscode/cookbooks/tree/master/database) cookbook. Please see the README for details on updated usage.
+
+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['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']['expire_logs_days']` = "10"
+* `mysql['tunable']['max_binlog_size']` = "100M"
+
+Usage
+=====
+
+On client nodes, use the client (or default) recipe:
+
+ include_recipe "mysql::client"
+
+This will install the MySQL client libraries and development headers on the system. It will also install the Ruby Gem `mysql`, so that the cookbook's LWRP (above) can be used. This is done during the compile-phase of the Chef run. On platforms that are known to have a native package (currently Debian, Ubuntu, Red hat, Centos, Fedora and SUSE), the package will be installed. Other platforms will use the RubyGem.
+
+This creates a resource object for the package and does the installation before other recipes are parsed. You'll need to have the C compiler and such (ie, build-essential on Ubuntu) before running the recipes, but we already do that when installing Chef :-).
+
+On server nodes, use the server recipe:
+
+ include_recipe "mysql::server"
+
+On Debian and Ubuntu, this will preseed the mysql-server package with the randomly generated root password in the recipe file. On other platforms, it simply installs the required packages. It will also create an SQL file, /etc/mysql/grants.sql, that will be used to set up grants for the root, repl and debian-sys-maint users.
+
+The recipe will perform a `node.save` unless it is run under `chef-solo` after the password attributes are used to ensure that in the event of a failed run, the saved attributes would be used.
+
+**Chef Solo Note**: These node attributes are stored on the Chef server when using `chef-client`. Because `chef-solo` does not connect to a server or save the node object at all, to have the same passwords persist across `chef-solo` runs, you must specify them in the `json_attribs` file used. For example:
+
+ {
+ "mysql": {
+ "server_root_password": "iloverandompasswordsbutthiswilldo",
+ "server_repl_password": "iloverandompasswordsbutthiswilldo",
+ "server_debian_password": "iloverandompasswordsbutthiswilldo"
+ },
+ "run_list":["recipe[mysql::server]"]
+ }
+
+On EC2 nodes, use the `server_ec2` recipe and the mysql data dir will be set up in the ephmeral storage.
+
+ include_recipe "mysql::server_ec2"
+
+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
+
+License and Author
+==================
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+Author:: AJ Christensen (<aj@opscode.com>)
+Author:: Seth Chisamore (<schisamo@opscode.com>)
+Author:: Brian Bianco (<brian.bianco@gmail.com>)
+
+Copyright:: 2009-2011 Opscode, Inc
+
+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.
View
32 mysql/attributes/client.rb
@@ -0,0 +1,32 @@
+#
+# Cookbook Name:: mysql
+# Attributes:: server
+#
+# Copyright 2008-2009, Opscode, Inc.
+#
+# 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.
+#
+
+case node["platform"]
+when "windows"
+ default['mysql']['client']['version'] = "6.0.2"
+ default['mysql']['client']['arch'] = "win32" # force 32 bit to work with mysql gem
+ default['mysql']['client']['package_file'] = "mysql-connector-c-#{mysql['client']['version']}-#{mysql['client']['arch']}.msi"
+ default['mysql']['client']['url'] = "http://www.mysql.com/get/Downloads/Connector-C/#{mysql['client']['package_file']}/from/http://mysql.mirrors.pair.com/"
+ default['mysql']['client']['package_name'] = "MySQL Connector C #{mysql['client']['version']}"
+
+ default['mysql']['client']['basedir'] = "#{ENV['SYSTEMDRIVE']}\\Program Files (x86)\\MySQL\\#{mysql['client']['package_name']}"
+ default['mysql']['client']['lib_dir'] = "#{mysql['client']['basedir']}\\lib/opt"
+ default['mysql']['client']['bin_dir'] = "#{mysql['client']['basedir']}\\bin"
+ default['mysql']['client']['ruby_dir'] = RbConfig::CONFIG['bindir']
+end
View
121 mysql/attributes/server.rb
@@ -0,0 +1,121 @@
+#
+# Cookbook Name:: mysql
+# Attributes:: server
+#
+# Copyright 2008-2009, Opscode, Inc.
+#
+# 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.
+#
+
+default['mysql']['bind_address'] = attribute?('cloud') ? cloud['local_ipv4'] : ipaddress
+
+case node["platform"]
+when "centos", "redhat", "fedora", "suse", "scientific", "amazon"
+ default['mysql']['package_name'] = "mysql-server"
+ default['mysql']['service_name'] = "mysqld"
+ default['mysql']['basedir'] = "/usr"
+ default['mysql']['data_dir'] = "/var/lib/mysql"
+ default['mysql']['root_group'] = "root"
+ default['mysql']['mysqladmin_bin'] = "/usr/bin/mysqladmin"
+ default['mysql']['mysql_bin'] = "/usr/bin/mysql"
+
+ set['mysql']['conf_dir'] = '/etc'
+ set['mysql']['confd_dir'] = '/etc/mysql/conf.d'
+ set['mysql']['socket'] = "/var/lib/mysql/mysql.sock"
+ set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid"
+ set['mysql']['old_passwords'] = 1
+ set['mysql']['grants_path'] = "/etc/mysql_grants.sql"
+when "freebsd"
+ default['mysql']['package_name'] = "mysql55-server"
+ default['mysql']['service_name'] = "mysql-server"
+ default['mysql']['basedir'] = "/usr/local"
+ default['mysql']['data_dir'] = "/var/db/mysql"
+ default['mysql']['root_group'] = "wheel"
+ default['mysql']['mysqladmin_bin'] = "/usr/local/bin/mysqladmin"
+ default['mysql']['mysql_bin'] = "/usr/local/bin/mysql"
+
+ set['mysql']['conf_dir'] = '/usr/local/etc'
+ set['mysql']['confd_dir'] = '/usr/local/etc/mysql/conf.d'
+ set['mysql']['socket'] = "/tmp/mysqld.sock"
+ set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid"
+ set['mysql']['old_passwords'] = 0
+ set['mysql']['grants_path'] = "/var/db/mysql/grants.sql"
+when "windows"
+ default['mysql']['package_name'] = "MySQL Server 5.5"
+ default['mysql']['version'] = '5.5.21'
+ default['mysql']['arch'] = 'win32'
+ default['mysql']['package_file'] = "mysql-#{mysql['version']}-#{mysql['arch']}.msi"
+ default['mysql']['url'] = "http://www.mysql.com/get/Downloads/MySQL-5.5/#{mysql['package_file']}/from/http://mysql.mirrors.pair.com/"
+
+ default['mysql']['service_name'] = "mysql"
+ default['mysql']['basedir'] = "#{ENV['SYSTEMDRIVE']}\\Program Files (x86)\\MySQL\\#{mysql['package_name']}"
+ default['mysql']['data_dir'] = "#{mysql['basedir']}\\Data"
+ default['mysql']['bin_dir'] = "#{mysql['basedir']}\\bin"
+ default['mysql']['mysqladmin_bin'] = "#{mysql['bin_dir']}\\mysqladmin"
+ default['mysql']['mysql_bin'] = "#{mysql['bin_dir']}\\mysql"
+
+ default['mysql']['conf_dir'] = "#{mysql['basedir']}"
+ default['mysql']['old_passwords'] = 0
+ default['mysql']['grants_path'] = "#{mysql['conf_dir']}\\grants.sql"
+else
+ default['mysql']['package_name'] = "mysql-server"
+ default['mysql']['service_name'] = "mysql"
+ default['mysql']['basedir'] = "/usr"
+ default['mysql']['data_dir'] = "/var/lib/mysql"
+ default['mysql']['root_group'] = "root"
+ default['mysql']['mysqladmin_bin'] = "/usr/bin/mysqladmin"
+ default['mysql']['mysql_bin'] = "/usr/bin/mysql"
+
+ set['mysql']['conf_dir'] = '/etc/mysql'
+ set['mysql']['confd_dir'] = '/etc/mysql/conf.d'
+ set['mysql']['socket'] = "/var/run/mysqld/mysqld.sock"
+ set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid"
+ set['mysql']['old_passwords'] = 0
+ set['mysql']['grants_path'] = "/etc/mysql/grants.sql"
+end
+
+if attribute?('ec2')
+ default['mysql']['ec2_path'] = "/mnt/mysql"
+ default['mysql']['ebs_vol_dev'] = "/dev/sdi"
+ default['mysql']['ebs_vol_size'] = 50
+end
+
+default['mysql']['use_upstart'] = platform?("ubuntu") && node.platform_version.to_f >= 10.04
+
+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"
+default['mysql']['tunable']['max_connections'] = "800"
+default['mysql']['tunable']['max_heap_table_size'] = "32M"
+default['mysql']['tunable']['myisam_recover'] = "BACKUP"
+default['mysql']['tunable']['net_read_timeout'] = "30"
+default['mysql']['tunable']['net_write_timeout'] = "30"
+default['mysql']['tunable']['table_cache'] = "128"
+default['mysql']['tunable']['table_open_cache'] = "128"
+default['mysql']['tunable']['thread_cache'] = "128"
+default['mysql']['tunable']['thread_cache_size'] = 8
+default['mysql']['tunable']['thread_concurrency'] = 10
+default['mysql']['tunable']['thread_stack'] = "256K"
+default['mysql']['tunable']['wait_timeout'] = "180"
+
+default['mysql']['tunable']['query_cache_limit'] = "1M"
+default['mysql']['tunable']['query_cache_size'] = "16M"
+
+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"
View
19 mysql/libraries/database.rb
@@ -0,0 +1,19 @@
+begin
+ require 'mysql'
+rescue LoadError
+ Chef::Log.info("Missing gem 'mysql'")
+end
+
+module Opscode
+ module Mysql
+ module Database
+ def db
+ @db ||= ::Mysql.new new_resource.host, new_resource.username, new_resource.password
+ end
+ def close
+ @db.close rescue nil
+ @db = nil
+ end
+ end
+ end
+end
View
33 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
View
401 mysql/metadata.json
@@ -0,0 +1,401 @@
+{
+ "name": "mysql",
+ "description": "Installs and configures mysql for client or server",
+ "long_description": "Description\n===========\n\nInstalls and configures MySQL client or server.\n\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu\n* CentOS, Red Hat, Fedora\n\nTested on:\n\n* Debian 5.0\n* Ubuntu 10.04\n* CentOS 5.5\n\nCookbooks\n---------\n\nRequires Opscode's openssl cookbook for secure password generation. See _Attributes_ and _Usage_ for more information.\n\nRequires a C compiler and Ruby development package in order to build mysql gem with native extensions. On Debian and Ubuntu systems this is satisfied by installing the \"build-essential\" and \"ruby-dev\" packages before running Chef. See USAGE below for information on how to handle this during a Chef run.\n\nResources and Providers\n=======================\n\nThe LWRP that used to ship as part of this cookbook has been refactored into the [database](https://github.com/opscode/cookbooks/tree/master/database) cookbook. Please see the README for details on updated usage.\n\nAttributes\n==========\n\n* `mysql['server_root_password']` - Set the server's root password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.\n* `mysql['server_repl_password']` - Set the replication user 'repl' password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.\n* `mysql['server_debian_password']` - Set the debian-sys-maint user password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.\n* `mysql['bind_address']` - Listen address for MySQLd, default is node's ipaddress.\n* `mysql['data_dir']` - Location for mysql data directory, default is \"/var/lib/mysql\"\n* `mysql['conf_dir']` - Location for mysql conf directory, default is \"/etc/mysql\"\n* `mysql['ec2_path']` - location of mysql data_dir on EC2 nodes, default \"/mnt/mysql\"\n\nPerformance tuning attributes, each corresponds to the same-named parameter in my.cnf; default values listed\n\n* `mysql['tunable']['key_buffer']` = \"250M\"\n* `mysql['tunable']['max_connections']` = \"800\"\n* `mysql['tunable']['wait_timeout']` = \"180\"\n* `mysql['tunable']['net_write_timeout']` = \"30\"\n* `mysql['tunable']['net_write_timeout']` = \"30\"\n* `mysql['tunable']['back_log']` = \"128\"\n* `mysql['tunable']['table_cache']` = \"128\"\n* `mysql['tunable']['max_heap_table_size']` = \"32M\"\n* `mysql['tunable']['expire_logs_days']` = \"10\"\n* `mysql['tunable']['max_binlog_size']` = \"100M\"\n\nUsage\n=====\n\nOn client nodes, use the client (or default) recipe:\n\n include_recipe \"mysql::client\"\n\nThis will install the MySQL client libraries and development headers on the system. It will also install the Ruby Gem `mysql`, so that the cookbook's LWRP (above) can be used. This is done during the compile-phase of the Chef run. On platforms that are known to have a native package (currently Debian, Ubuntu, Red hat, Centos, Fedora and SUSE), the package will be installed. Other platforms will use the RubyGem.\n\nThis creates a resource object for the package and does the installation before other recipes are parsed. You'll need to have the C compiler and such (ie, build-essential on Ubuntu) before running the recipes, but we already do that when installing Chef :-).\n\nOn server nodes, use the server recipe:\n\n include_recipe \"mysql::server\"\n\nOn Debian and Ubuntu, this will preseed the mysql-server package with the randomly generated root password in the recipe file. On other platforms, it simply installs the required packages. It will also create an SQL file, /etc/mysql/grants.sql, that will be used to set up grants for the root, repl and debian-sys-maint users.\n\nThe recipe will perform a `node.save` unless it is run under `chef-solo` after the password attributes are used to ensure that in the event of a failed run, the saved attributes would be used.\n\n**Chef Solo Note**: These node attributes are stored on the Chef server when using `chef-client`. Because `chef-solo` does not connect to a server or save the node object at all, to have the same passwords persist across `chef-solo` runs, you must specify them in the `json_attribs` file used. For example:\n\n {\n \"mysql\": {\n \"server_root_password\": \"iloverandompasswordsbutthiswilldo\",\n \"server_repl_password\": \"iloverandompasswordsbutthiswilldo\",\n \"server_debian_password\": \"iloverandompasswordsbutthiswilldo\"\n },\n \"run_list\":[\"recipe[mysql::server]\"]\n }\n\nOn EC2 nodes, use the `server_ec2` recipe and the mysql data dir will be set up in the ephmeral storage.\n\n include_recipe \"mysql::server_ec2\"\n\nWhen the `ec2_path` doesn't exist we look for a mounted filesystem (eg, EBS) and move the data_dir there.\n\nThe client recipe is already included by server and 'default' recipes.\n\nFor more infromation on the compile vs execution phase of a Chef run:\n\n* http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: AJ Christensen (<aj@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\nAuthor:: Brian Bianco (<brian.bianco@gmail.com>)\n\nCopyright:: 2009-2011 Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "debian": ">= 0.0.0",
+ "ubuntu": ">= 0.0.0",
+ "centos": ">= 0.0.0",
+ "suse": ">= 0.0.0",
+ "fedora": ">= 0.0.0",
+ "redhat": ">= 0.0.0",
+ "scientific": ">= 0.0.0",
+ "amazon": ">= 0.0.0",
+ "freebsd": ">= 0.0.0",
+ "windows": ">= 0.0.0"
+ },
+ "dependencies": {
+ "openssl": ">= 0.0.0",
+ "windows": ">= 0.0.0"
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ "mysql/server_root_password": {
+ "display_name": "MySQL Server Root Password",
+ "description": "Randomly generated password for the mysqld root user",
+ "default": "randomly generated",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/bind_address": {
+ "display_name": "MySQL Bind Address",
+ "description": "Address that mysqld should listen on",
+ "default": "ipaddress",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/data_dir": {
+ "display_name": "MySQL Data Directory",
+ "description": "Location of mysql databases",
+ "default": "/var/lib/mysql",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/conf_dir": {
+ "display_name": "MySQL Conf Directory",
+ "description": "Location of mysql conf files",
+ "default": "/etc/mysql",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/ec2_path": {
+ "display_name": "MySQL EC2 Path",
+ "description": "Location of mysql directory on EC2 instance EBS volumes",
+ "default": "/mnt/mysql",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable": {
+ "display_name": "MySQL Tunables",
+ "description": "Hash of MySQL tunable attributes",
+ "type": "hash",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/key_buffer": {
+ "display_name": "MySQL Tuntable Key Buffer",
+ "default": "250M",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/max_connections": {
+ "display_name": "MySQL Tunable Max Connections",
+ "default": "800",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/wait_timeout": {
+ "display_name": "MySQL Tunable Wait Timeout",
+ "default": "180",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/net_read_timeout": {
+ "display_name": "MySQL Tunable Net Read Timeout",
+ "default": "30",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/net_write_timeout": {
+ "display_name": "MySQL Tunable Net Write Timeout",
+ "default": "30",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/back_log": {
+ "display_name": "MySQL Tunable Back Log",
+ "default": "128",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/table_cache": {
+ "display_name": "MySQL Tunable Table Cache for MySQL < 5.1.3",
+ "default": "128",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/table_open_cache": {
+ "display_name": "MySQL Tunable Table Cache for MySQL >= 5.1.3",
+ "default": "128",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/max_heap_table_size": {
+ "display_name": "MySQL Tunable Max Heap Table Size",
+ "default": "32M",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/expire_logs_days": {
+ "display_name": "MySQL Exipre Log Days",
+ "default": "10",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/tunable/max_binlog_size": {
+ "display_name": "MySQL Max Binlog Size",
+ "default": "100M",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client": {
+ "display_name": "MySQL Connector/C Client",
+ "description": "Hash of MySQL client attributes",
+ "type": "hash",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/version": {
+ "display_name": "MySQL Connector/C Version",
+ "default": "6.0.2",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/arch": {
+ "display_name": "MySQL Connector/C Architecture",
+ "default": "win32",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/package_file": {
+ "display_name": "MySQL Connector/C Package File Name",
+ "default": "mysql-connector-c-6.0.2-win32.msi",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/url": {
+ "display_name": "MySQL Connector/C Download URL",
+ "default": "http://www.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.0.2-win32.msi/from/http://mysql.mirrors.pair.com/",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/package_name": {
+ "display_name": "MySQL Connector/C Registry DisplayName",
+ "default": "MySQL Connector C 6.0.2",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/basedir": {
+ "display_name": "MySQL Connector/C Base Install Directory",
+ "default": "C:\\Program Files (x86)\\MySQL\\Connector C 6.0.2",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/lib_dir": {
+ "display_name": "MySQL Connector/C Library Directory (containing libmysql.dll)",
+ "default": "C:\\Program Files (x86)\\MySQL\\Connector C 6.0.2\\lib\\opt",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/bin_dir": {
+ "display_name": "MySQL Connector/C Executable Directory",
+ "default": "C:\\Program Files (x86)\\MySQL\\Connector C 6.0.2\\bin",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "mysql/client/ruby_dir": {
+ "display_name": "Ruby Executable Directory which should gain MySQL support",
+ "default": "system ruby",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ }
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "mysql": "Includes the client recipe to configure a client",
+ "mysql::client": "Installs packages required for mysql clients using run_action magic",
+ "mysql::server": "Installs packages required for mysql servers w/o manual intervention",
+ "mysql::server_ec2": "Performs EC2-specific mountpoint manipulation"
+ },
+ "version": "1.2.6"
+}
View
226 mysql/metadata.rb
@@ -1,106 +1,132 @@
-maintainer "Blue Box Group, LLC"
-maintainer_email "support@blueboxgrp.com"
-license "Apache v2.0"
-description "Installs/Configures mysql"
-long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
-version "0.5.0"
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs and configures mysql for client or server"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "1.2.6"
+recipe "mysql", "Includes the client recipe to configure a client"
+recipe "mysql::client", "Installs packages required for mysql clients using run_action magic"
+recipe "mysql::server", "Installs packages required for mysql servers w/o manual intervention"
+recipe "mysql::server_ec2", "Performs EC2-specific mountpoint manipulation"
-depends "system-users"
-conflicts "percona"
-
-%w{centos redhat}.each do |os|
+%w{ debian ubuntu centos suse fedora redhat scientific amazon freebsd windows }.each do |os|
supports os
end
-grouping 'mysql/server/replication',
- :title => "MySQL Replication Options",
- :description => "Describe MySQL replication settings below."
-
-attribute 'mysql/server/replication/role',
- :display_name => "MySQL Replication Role",
- :description => "Describes what role the MySQL machine is set to (slave/master/dualmaster)",
- :choice => [ 'slave', 'master', 'standalone', 'dualmaster' ],
- :type => "string",
- :required => "recommended",
- :recipes => [ 'mysql::master', 'mysql::slave', 'mysql::dualmaster' ],
- :default => "standalone"
-
-attribute 'mysql/server/replication/user',
- :display_name => "MySQL Replication User",
- :description => "Username that should be created and used on a master server for replication.",
- :type => "string",
- :required => "optional",
- :recipes => [ 'mysql::master', 'mysql::slave', 'mysql::dualmaster' ],
- :default => "replication"
-
-attribute 'mysql/server/replication/password',
- :display_name => "MySQL Replication Password",
- :description => "Password for connecting to a master server with the replication user.",
- :type => "string",
- :required => "required",
- :recipes => [ 'mysql::master', 'mysql::slave', 'mysql::dualmaster' ]
-
-attribute 'mysql/server/replication/id',
- :display_name => "MySQL server ID",
- :description => "The 'server-id' configuration setting set for each machine in a specific cluster.",
- :type => "string",
- :calculated => true,
- :required => "optional"
-
-attribute 'mysql/server/replication/autoincrementincrement',
- :display_name => "MySQL 'auto_increment_increment'",
- :description => "The 'auto_increment_increment' configuration setting set for each machine in
- a specific cluster.",
- :type => "string",
- :calculated => true,
- :required => "optional"
-
-attribute 'mysql/server/replication/autoincrementoffset',
- :display_name => "MySQL 'auto_increment_offset'",
- :description => "The 'auto_increment_offset' configuration setting set for each machine in
- a specific cluster.",
- :type => "string",
- :calculated => true,
- :required => "optional"
-
-attribute 'mysql/server/replication/log_file',
- :display_name => "MySQL master log file",
- :description => "Last recorded MySQL master log file.",
- :type => "string",
- :calculated => true,
- :required => "optional"
-
-attribute 'mysql/server/replication/log_pos',
- :display_name => "MySQL master log position",
- :description => "Last recorded MySQL master log position.",
- :type => "string",
- :calculated => true,
- :required => "optional"
-
-grouping 'mysql/server',
- :title => "General MySQL Options",
- :description => "Describe general MySQL options below."
-
-attribute 'mysql/server/datadir',
- :display_name => "MySQL data directory",
- :description => "Where your MySQL databases live.",
- :type => "string",
- :required => "optional",
- :recipes => [ 'mysql::server' ],
+depends "openssl"
+depends "windows"
+
+attribute "mysql/server_root_password",
+ :display_name => "MySQL Server Root Password",
+ :description => "Randomly generated password for the mysqld root user",
+ :default => "randomly generated"
+
+attribute "mysql/bind_address",
+ :display_name => "MySQL Bind Address",
+ :description => "Address that mysqld should listen on",
+ :default => "ipaddress"
+
+attribute "mysql/data_dir",
+ :display_name => "MySQL Data Directory",
+ :description => "Location of mysql databases",
:default => "/var/lib/mysql"
-attribute 'mysql/server/logdir',
- :display_name => "MySQL log directory",
- :description => "Where your MySQL logs are stored.",
- :type => "string",
- :required => "optional",
- :recipes => [ 'mysql::server' ],
- :default => "/var/log/mysql"
-
-attribute 'mysql/server/bindaddress',
- :display_name => "MySQL bind address",
- :description => "Which IP address MySQL will bind to.",
- :type => "string",
- :required => "recommended",
- :recipes => [ 'mysql::server' ],
- :default => "127.0.0.1"
+attribute "mysql/conf_dir",
+ :display_name => "MySQL Conf Directory",
+ :description => "Location of mysql conf files",
+ :default => "/etc/mysql"
+
+attribute "mysql/ec2_path",
+ :display_name => "MySQL EC2 Path",
+ :description => "Location of mysql directory on EC2 instance EBS volumes",
+ :default => "/mnt/mysql"
+
+attribute "mysql/tunable",
+ :display_name => "MySQL Tunables",
+ :description => "Hash of MySQL tunable attributes",
+ :type => "hash"
+
+attribute "mysql/tunable/key_buffer",
+ :display_name => "MySQL Tuntable Key Buffer",
+ :default => "250M"
+
+attribute "mysql/tunable/max_connections",
+ :display_name => "MySQL Tunable Max Connections",
+ :default => "800"
+
+attribute "mysql/tunable/wait_timeout",
+ :display_name => "MySQL Tunable Wait Timeout",
+ :default => "180"
+
+attribute "mysql/tunable/net_read_timeout",
+ :display_name => "MySQL Tunable Net Read Timeout",
+ :default => "30"
+
+attribute "mysql/tunable/net_write_timeout",
+ :display_name => "MySQL Tunable Net Write Timeout",
+ :default => "30"
+
+attribute "mysql/tunable/back_log",
+ :display_name => "MySQL Tunable Back Log",
+ :default => "128"
+
+attribute "mysql/tunable/table_cache",
+ :display_name => "MySQL Tunable Table Cache for MySQL < 5.1.3",
+ :default => "128"
+
+attribute "mysql/tunable/table_open_cache",
+ :display_name => "MySQL Tunable Table Cache for MySQL >= 5.1.3",
+ :default => "128"
+
+attribute "mysql/tunable/max_heap_table_size",
+ :display_name => "MySQL Tunable Max Heap Table Size",
+ :default => "32M"
+
+attribute "mysql/tunable/expire_logs_days",
+ :display_name => "MySQL Exipre Log Days",
+ :default => "10"
+
+attribute "mysql/tunable/max_binlog_size",
+ :display_name => "MySQL Max Binlog Size",
+ :default => "100M"
+
+attribute "mysql/client",
+ :display_name => "MySQL Connector/C Client",
+ :description => "Hash of MySQL client attributes",
+ :type => "hash"
+
+attribute "mysql/client/version",
+ :display_name => "MySQL Connector/C Version",
+ :default => "6.0.2"
+
+attribute "mysql/client/arch",
+ :display_name => "MySQL Connector/C Architecture",
+ :default => "win32"
+
+attribute "mysql/client/package_file",
+ :display_name => "MySQL Connector/C Package File Name",
+ :default => "mysql-connector-c-6.0.2-win32.msi"
+
+attribute "mysql/client/url",
+ :display_name => "MySQL Connector/C Download URL",
+ :default => "http://www.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.0.2-win32.msi/from/http://mysql.mirrors.pair.com/"
+
+attribute "mysql/client/package_name",
+ :display_name => "MySQL Connector/C Registry DisplayName",
+ :default => "MySQL Connector C 6.0.2"
+
+attribute "mysql/client/basedir",
+ :display_name => "MySQL Connector/C Base Install Directory",
+ :default => "C:\\Program Files (x86)\\MySQL\\Connector C 6.0.2"
+
+attribute "mysql/client/lib_dir",
+ :display_name => "MySQL Connector/C Library Directory (containing libmysql.dll)",
+ :default => "C:\\Program Files (x86)\\MySQL\\Connector C 6.0.2\\lib\\opt"
+
+attribute "mysql/client/bin_dir",
+ :display_name => "MySQL Connector/C Executable Directory",
+ :default => "C:\\Program Files (x86)\\MySQL\\Connector C 6.0.2\\bin"
+
+attribute "mysql/client/ruby_dir",
+ :display_name => "Ruby Executable Directory which should gain MySQL support",
+ :default => "system ruby"
View
92 mysql/recipes/client.rb
@@ -2,7 +2,7 @@
# Cookbook Name:: mysql
# Recipe:: client
#
-# Copyright 2010, Blue Box Group, LLC
+# Copyright 2008-2011, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,48 +17,64 @@
# limitations under the License.
#
-case node[:platform]
-when "centos","redhat","fedora"
- bash "mysql-fetch-client" do
- user "root"
- cwd "/tmp"
- code <<-EOH
- (cd /tmp; wget http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.1/MySQL-devel-community-5.1.51-1.rhel5.x86_64.rpm)
- (cd /tmp; wget http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.1/MySQL-client-community-5.1.51-1.rhel5.x86_64.rpm)
- EOH
- not_if "test -f /tmp/MySQL-client-community-5.1.51-1.rhel5.x86_64.rpm"
+# Include Opscode helper in Recipe class to get access
+# to debian_before_squeeze? and ubuntu_before_lucid?
+::Chef::Recipe.send(:include, Opscode::Mysql::Helpers)
+
+mysql_packages = case node['platform']
+when "centos", "redhat", "suse", "fedora", "scientific", "amazon"
+ %w{mysql mysql-devel}
+when "ubuntu","debian"
+ if debian_before_squeeze? || ubuntu_before_lucid?
+ %w{mysql-client libmysqlclient15-dev}
+ else
+ %w{mysql-client libmysqlclient-dev}
end
-
- bash "mysql-install-client" do
- user "root"
- cwd "/tmp"
- code <<-EOH
- (cd /tmp; rpm -Uvh MySQL-devel-community-5.1.51-1.rhel5.x86_64.rpm)
- (cd /tmp; rpm -Uvh MySQL-client-community-5.1.51-1.rhel5.x86_64.rpm)
- EOH
- not_if "rpm -qa | grep 'MySQL-client-community-5.1.51'"
+when "freebsd"
+ %w{mysql55-client}
+when "windows"
+ package_file = node['mysql']['client']['package_file']
+ remote_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do
+ source node['mysql']['client']['url']
+ not_if { File.exists? "#{Chef::Config[:file_cache_path]}/#{package_file}" }
end
- bash "mysql-fetch-shared-compat" do
- user "root"
- cwd "/tmp"
- code <<-EOH
- (cd /tmp; wget http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.1/MySQL-shared-compat-5.1.51-1.rhel5.x86_64.rpm)
- EOH
- not_if "test -f /tmp/MySQL-shared-compat-5.1.51-1.rhel5.x86_64.rpm"
+ windows_package node['mysql']['client']['package_name'] do
+ source "#{Chef::Config[:file_cache_path]}/#{package_file}"
+ end
+ windows_path node['mysql']['client']['bin_dir'] do
+ action :add
+ end
+ def package(*args, &blk)
+ windows_package(*args, &blk)
end
+ [node['mysql']['client']['package_name']]
+else
+ %w{mysql-client libmysqlclient-dev}
+end
- bash "mysql-install-shared-compat" do
- user "root"
- cwd "/tmp"
- code <<-EOH
- (cd /tmp; rpm -Uvh MySQL-shared-compat-5.1.51-1.rhel5.x86_64.rpm)
- EOH
- not_if "rpm -qa | grep 'MySQL-shared-compat-5.1.51'"
+mysql_packages.each do |mysql_pack|
+ package mysql_pack do
+ action :install
end
-when "debian","ubuntu"
- packages = %w{libmysqlclient15-dev mysql-client}
- packages.each do |pkg|
- package pkg
+end
+
+if platform?(%w{ redhat centos fedora suse scientific amazon })
+ package 'ruby-mysql'
+elsif platform?(%w{ debian ubuntu })
+ package "libmysql-ruby"
+else
+ gem_package "mysql" do
+ action :install
+ end
+end
+
+if platform? 'windows'
+ ruby_block "copy libmysql.dll into ruby path" do
+ block do
+ require 'fileutils'
+ FileUtils.cp "#{node['mysql']['client']['lib_dir']}\\libmysql.dll", node['mysql']['client']['ruby_dir']
+ end
+ not_if { File.exist?("#{node['mysql']['client']['ruby_dir']}\\libmysql.dll") }
end
end
View
2 mysql/recipes/default.rb
@@ -2,7 +2,7 @@
# Cookbook Name:: mysql
# Recipe:: default
#
-# Copyright 2010, Blue Box Group, LLC
+# Copyright 2008-2009, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
View
232 mysql/recipes/server.rb
@@ -1,8 +1,8 @@
#
# Cookbook Name:: mysql
-# Recipe:: server
+# Recipe:: default
#
-# Copyright 2010, Blue Box Group, LLC
+# Copyright 2008-2011, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,114 +17,162 @@
# limitations under the License.
#
+::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
+
include_recipe "mysql::client"
-include_recipe "system-users::mysql"
-
-template "/etc/init.d/mysql" do
- source "mysql-init.erb"
- owner "root"
- group "root"
- mode "0755"
- backup false
-end
-directory node[:mysql][:server][:datadir] do
- owner "mysql"
- group "mysql"
- mode "0755"
- recursive true
- action :create
-end
+# generate all passwords
+node.set_unless['mysql']['server_debian_password'] = secure_password
+node.set_unless['mysql']['server_root_password'] = secure_password
+node.set_unless['mysql']['server_repl_password'] = secure_password
+
+if platform?(%w{debian ubuntu})
+
+ directory "/var/cache/local/preseeding" do
+ owner "root"
+ group node['mysql']['root_group']
+ mode 0755
+ recursive true
+ end
+
+ execute "preseed mysql-server" do
+ command "debconf-set-selections /var/cache/local/preseeding/mysql-server.seed"
+ action :nothing
+ end
+
+ template "/var/cache/local/preseeding/mysql-server.seed" do
+ source "mysql-server.seed.erb"
+ owner "root"
+ group node['mysql']['root_group']
+ mode "0600"
+ notifies :run, resources(:execute => "preseed mysql-server"), :immediately
+ end
+
+ template "#{node['mysql']['conf_dir']}/debian.cnf" do
+ source "debian.cnf.erb"
+ owner "root"
+ group node['mysql']['root_group']
+ mode "0600"
+ end
-directory node[:mysql][:server][:logdir] do
- owner "mysql"
- group "mysql"
- mode "0755"
- recursive true
- action :create
end
-directory "/var/run/mysql" do
- owner "mysql"
- group "mysql"
- mode "0755"
- action :create
+if platform? 'windows'
+ package_file = node['mysql']['package_file']
+
+ remote_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do
+ source node['mysql']['url']
+ not_if { File.exists? "#{Chef::Config[:file_cache_path]}/#{package_file}" }
+ end
+
+ windows_package node['mysql']['package_name'] do
+ source "#{Chef::Config[:file_cache_path]}/#{package_file}"
+ end
+
+ def package(*args, &blk)
+ windows_package(*args, &blk)
+ end
end
-# Assign the proper values to our configuration based on total memory in system.
-if node[:memory][:total].to_i >= 16000000
- table_cache = "1024"
- thread_cache = "256"
- innodb_buffer_pool_size = "11G"
- innodb_additional_mem_pool_size = "20M"
-elsif node[:memory][:total].to_i >= 8000000
- table_cache = "1024"
- thread_cache = "256"
- innodb_buffer_pool_size = "5G"
- innodb_additional_mem_pool_size = "20M"
-elsif node[:memory][:total].to_i >= 4000000
- table_cache = "512"
- thread_cache = "128"
- innodb_buffer_pool_size = "2G"
- innodb_additional_mem_pool_size = "10M"
-elsif node[:memory][:total].to_i >= 2000000
- table_cache = "256"
- thread_cache = "64"
- innodb_buffer_pool_size = "1G"
- innodb_additional_mem_pool_size = "4M"
-else
- table_cache = "128"
- thread_cache = "32"
- innodb_buffer_pool_size = "512M"
- innodb_additional_mem_pool_size = "2M"
+package node['mysql']['package_name'] do
+ action :install
end
-template "/etc/my.cnf" do
- source "my.cnf"
- variables(
- :table_cache => table_cache,
- :thread_cache => thread_cache,
- :innodb_buffer_pool_size => innodb_buffer_pool_size,
- :innodb_additional_mem_pool_size => innodb_additional_mem_pool_size
- )
- backup false
+directory node['mysql']['confd_dir'] do
+ owner "mysql" unless platform? 'windows'
+ group "mysql" unless platform? 'windows'
+ action :create
+ recursive true
end
-case node[:platform]
-when "centos","redhat","fedora"
- bash "mysql-fetch-server" do
- user "root"
- cwd "/tmp"
- code <<-EOH
- (cd /tmp; wget http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.1/MySQL-server-community-5.1.51-1.rhel5.x86_64.rpm)
- EOH
- not_if "test -f /tmp/MySQL-server-community-5.1.51-1.rhel5.x86_64.rpm"
- end
-
- bash "mysql-install-server" do
- user "root"
- cwd "/tmp"
- code <<-EOH
- (cd /tmp; rpm -Uvh MySQL-server-community-5.1.51-1.rhel5.x86_64.rpm)
- EOH
- not_if "rpm -qa | grep 'MySQL-server-community-5.1.51'"
+if platform? 'windows'
+ require 'win32/service'
+
+ windows_path node['mysql']['bin_dir'] do
+ action :add
end
-when "debian","ubuntu"
- packages = %w{mysql-server}
- packages.each do |pkg|
- package pkg
+
+ windows_batch "install mysql service" do
+ command "\"#{node['mysql']['bin_dir']}\\mysqld.exe\" --install #{node['mysql']['service_name']}"
+ not_if { Win32::Service.exists?(node['mysql']['service_name']) }
end
end
service "mysql" do
+ service_name node['mysql']['service_name']
+ if node['mysql']['use_upstart']
+ restart_command "restart mysql"
+ stop_command "stop mysql"
+ start_command "start mysql"
+ end
supports :status => true, :restart => true, :reload => true
- action [ :enable, :start ]
+ action :nothing
end
-template "/etc/logrotate.d/mysql_slowqueries" do
- source "mysql-server-logrotate"
- owner "root"
- group "root"
+skip_federated = case node['platform']
+ when 'fedora', 'ubuntu', 'amazon'
+ true
+ when 'centos', 'redhat', 'scientific'
+ node['platform_version'].to_f < 6.0
+ else
+ false
+ end
+
+template "#{node['mysql']['conf_dir']}/my.cnf" do
+ source "my.cnf.erb"
+ owner "root" unless platform? 'windows'
+ group node['mysql']['root_group'] unless platform? 'windows'
mode "0644"
- backup false
+ notifies :restart, resources(:service => "mysql"), :immediately
+ variables :skip_federated => skip_federated
+end
+
+unless Chef::Config[:solo]
+ ruby_block "save node data" do
+ block do
+ node.save
+ end
+ action :create
+ end
+end
+
+# set the root password on platforms
+# that don't support pre-seeding
+unless platform?(%w{debian ubuntu})
+
+ execute "assign-root-password" do
+ command "\"#{node['mysql']['mysqladmin_bin']}\" -u root password \"#{node['mysql']['server_root_password']}\""
+ action :run
+ only_if "\"#{node['mysql']['mysql_bin']}\" -u root -e 'show databases;'"
+ end
+
+end
+
+grants_path = node['mysql']['grants_path']
+
+begin
+ t = resources("template[#{grants_path}]")
+rescue
+ Chef::Log.info("Could not find previously defined grants.sql resource")
+ t = template grants_path do
+ source "grants.sql.erb"
+ owner "root" unless platform? 'windows'
+ group node['mysql']['root_group'] unless platform? 'windows'
+ mode "0600"
+ action :create
+ end
+end
+
+if platform? 'windows'
+ windows_batch "mysql-install-privileges" do
+ command "\"#{node['mysql']['mysql_bin']}\" -u root #{node['mysql']['server_root_password'].empty? ? '' : '-p' }\"#{node['mysql']['server_root_password']}\" < \"#{grants_path}\""
+ action :nothing
+ subscribes :run, resources("template[#{grants_path}]"), :immediately
+ end
+else
+ execute "mysql-install-privileges" do
+ command "\"#{node['mysql']['mysql_bin']}\" -u root #{node['mysql']['server_root_password'].empty? ? '' : '-p' }\"#{node['mysql']['server_root_password']}\" < \"#{grants_path}\""
+ action :nothing
+ subscribes :run, resources("template[#{grants_path}]"), :immediately
+ end
end
View
51 mysql/recipes/server_ec2.rb
@@ -0,0 +1,51 @@
+#
+# Cookbook Name:: mysql
+# Recipe:: default
+#
+# Copyright 2008-2009, Opscode, Inc.
+#
+# 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.
+#
+
+
+if (node.attribute?('ec2') && ! FileTest.directory?(node['mysql']['ec2_path']))
+
+ service "mysql" do
+ action :stop
+ end
+
+ execute "install-mysql" do
+ command "mv #{node['mysql']['data_dir']} #{node['mysql']['ec2_path']}"
+ not_if do FileTest.directory?(node['mysql']['ec2_path']) end
+ end
+
+ [node['mysql']['ec2_path'], node['mysql']['data_dir']].each do |dir|
+ directory dir do
+ owner "mysql"
+ group "mysql"
+ end
+ end
+
+ mount node['mysql']['data_dir'] do
+ device node['mysql']['ec2_path']
+ fstype "none"
+ options "bind,rw"
+ action [:mount, :enable]
+ end
+
+ service "mysql" do
+ action :start
+ end
+
+end
+
View
12 mysql/templates/default/debian.cnf.erb
@@ -0,0 +1,12 @@
+[client]
+host = localhost
+user = debian-sys-maint
+password = <%= node['mysql']['server_debian_password'] %>
+socket = <%= node['mysql']['socket'] %>
+
+[mysql_upgrade]
+host = localhost
+user = debian-sys-maint
+password = <%= node['mysql']['server_debian_password'] %>
+socket = <%= node['mysql']['socket'] %>
+basedir = /usr
View
15 mysql/templates/default/grants.sql.erb
@@ -0,0 +1,15 @@
+# Generated by Chef for <%= node['hostname'] %>.
+# Local modifications will be overwritten.
+
+<% case node['platform'] -%>
+<% when "debian","ubuntu" -%>
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<%= node[:mysql][:server_debian_password] %>' WITH GRANT OPTION;
+<% end -%>
+# Grant replication for a slave user.
+GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' identified by '<%= node['mysql']['server_repl_password'] %>';
+
+# Set the server root password. This should be preseeded by the package installation.
+<% if node['mysql']['allow_remote_root'] -%>
+GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '<%= node['mysql']['server_root_password'] %>' WITH GRANT OPTION;
+<% end -%>
+SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node['mysql']['server_root_password'] %>');
View
176 mysql/templates/default/my.cnf.erb
@@ -0,0 +1,176 @@
+#
+# Generated by Chef for <%= node['hostname'] %>
+#
+# Local modifications will be overwritten.
+#
+# The MySQL database server configuration file.
+#
+# You can copy this to one of:
+# - "/etc/mysql/my.cnf" to set global options,
+# - "~/.my.cnf" to set user-specific options.
+#
+# One can use all long options that the program supports.
+# Run program with --help to get a list of available options and with
+# --print-defaults to see which it would actually understand and use.
+#
+# For explanations see
+# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
+
+# This will be passed to all mysql clients
+# It has been reported that passwords should be enclosed with ticks/quotes
+# escpecially if they contain "#" chars...
+# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
+[client]
+port = 3306
+socket = <%= node['mysql']['socket'] %>
+
+# Here is entries for some specific programs
+# The following values assume you have at least 32M ram
+
+# This was formally known as [safe_mysqld]. Both versions are currently parsed.
+[mysqld_safe]
+socket = <%= node['mysql']['socket'] %>
+nice = 0
+
+[mysqld]
+#
+# * Basic Settings
+#
+
+#
+# * IMPORTANT
+# If you make changes to these settings and your system uses apparmor, you may
+# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
+#
+
+user = mysql
+pid-file = <%= node['mysql']['pid_file'] %>
+socket = <%= node['mysql']['socket'] %>
+port = 3306
+basedir = <%= node['mysql']['basedir'] %>
+datadir = <%= node['mysql']['data_dir'] %>
+tmpdir = /tmp
+skip-external-locking
+#
+# Instead of skip-networking the default is now to listen only on
+# localhost which is more compatible and is not less secure.
+bind-address = <%= node['mysql']['bind_address'] %>
+#
+# * Fine Tuning
+#
+key_buffer = <%= node['mysql']['tunable']['key_buffer'] %>
+max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
+thread_stack = <%= node['mysql']['tunable']['thread_stack'] %>
+thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %>
+# This replaces the startup script and checks MyISAM tables if needed
+# the first time they are touched
+myisam-recover = BACKUP
+#max_connections = 100
+#table_cache = 64
+#thread_concurrency = 10
+max_connections = <%= node['mysql']['tunable']['max_connections'] %>
+wait_timeout = <%= node['mysql']['tunable']['wait_timeout'] %>
+net_read_timeout = <%= node['mysql']['tunable']['net_read_timeout'] %>
+net_write_timeout = <%= node['mysql']['tunable']['net_write_timeout'] %>
+back_log = <%= node['mysql']['tunable']['back_log'] %>
+table_cache = <%= node['mysql']['tunable']['table_cache'] %>
+max_heap_table_size = <%= node['mysql']['tunable']['max_heap_table_size'] %>
+
+#
+# * Query Cache Configuration
+#
+query_cache_limit = <%= node['mysql']['tunable']['query_cache_limit'] %>
+query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %>
+#
+# * 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
+#
+# Error logging goes to syslog. This is a Debian improvement :)
+#
+# Here you can see queries with especially long duration
+log_slow_queries = <%= node['mysql']['tunable']['log_slow_queries'] %>
+long_query_time = <%= node['mysql']['tunable']['long_query_time'] %>
+log-queries-not-using-indexes
+#
+# The following can be used as easy to replay backup logs or for replication.
+# note: if you are setting up a replication slave, see README.Debian about
+# other settings you may need to change.
+#server-id = 1
+#log_bin = /var/log/mysql/mysql-bin.log
+expire_logs_days = <%= node['mysql']['tunable']['expire_logs_days'] %>
+max_binlog_size = <%= node['mysql']['tunable']['max_binlog_size'] %>
+#binlog_do_db = include_database_name
+#binlog_ignore_db = include_database_name
+#
+# * 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
+innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %>
+
+<% if @skip_federated %>
+#
+# * Federated
+#
+# The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files
+# shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth).
+#
+skip-federated
+<% end %>
+#
+# * Security Features
+#
+# Read the manual, too, if you want chroot!
+# chroot = /var/lib/mysql/
+#
+# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
+#
+# ssl-ca=/etc/mysql/cacert.pem
+# ssl-cert=/etc/mysql/server-cert.pem
+# ssl-key=/etc/mysql/server-key.pem
+
+[mysqldump]
+quick
+quote-names
+max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
+
+[mysql]
+#no-auto-rehash # faster start of mysql but no tab completition
+
+[isamchk]
+key_buffer = <%= node['mysql']['tunable']['max_allowed_packet'] %>
+
+#
+# * 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
+
+<% case node['platform'] -%>
+<% when "centos", "redhat", "fedora", "suse", "scientific", "amazon"-%>
+#
+# * BerkeleyDB
+#
+# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
+skip-bdb
+# Default to using old password format for compatibility with mysql 3.x
+# clients (those using the mysqlclient10 compatibility package).
+old_passwords = <%= node['mysql']['old_passwords'] %>
+
+<% else -%>
+#
+# * IMPORTANT: Additional settings that can override those from this file!
+# The files must end with '.cnf', otherwise they'll be ignored.
+#
+!includedir <%= node['mysql']['confd_dir'] %>/
+<% end -%>
View
10 mysql/templates/default/mysql-server.seed.erb
@@ -0,0 +1,10 @@
+mysql-server-5.0 mysql-server/root_password_again select <%= node['mysql']['server_root_password'] %>
+mysql-server-5.0 mysql-server/root_password select <%= node['mysql']['server_root_password'] %>
+mysql-server-5.0 mysql-server-5.0/really_downgrade boolean false
+mysql-server-5.0 mysql-server-5.0/need_sarge_compat boolean false
+mysql-server-5.0 mysql-server-5.0/start_on_boot boolean true
+mysql-server-5.0 mysql-server/error_setting_password boolean false
+mysql-server-5.0 mysql-server-5.0/nis_warning note
+mysql-server-5.0 mysql-server-5.0/postrm_remove_databases boolean false
+mysql-server-5.0 mysql-server/password_mismatch boolean false
+mysql-server-5.0 mysql-server-5.0/need_sarge_compat_done boolean true
View
3 mysql/templates/default/port_mysql.erb
@@ -0,0 +1,3 @@
+# MySQL
+-A FWR -p tcp -m tcp --dport 3306 -j ACCEPT
+-A FWR -p udp -m udp --dport 3306 -j ACCEPT
View
61 mysql/templates/windows/my.cnf.erb
@@ -0,0 +1,61 @@
+#
+# Generated by Chef for <%= node['hostname'] %>
+#
+# Local modifications will be overwritten.
+#
+# The MySQL database server configuration file.
+#
+# One can use all long options that the program supports.
+# Run program with --help to get a list of available options and with
+# --print-defaults to see which it would actually understand and use.
+#
+# For explanations see
+# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
+
+# This will be passed to all mysql clients
+# It has been reported that passwords should be enclosed with ticks/quotes
+# escpecially if they contain "#" chars...
+[client]
+port = 3306
+
+[mysql]
+default-character-set = latin1
+
+[mysqld]
+#
+# * Basic Settings
+#
+port = 3306
+basedir = <%= node['mysql']['basedir'] %>
+datadir = <%= node['mysql']['data_dir'] %>
+character-set-server = latin1
+default-storage-engine = INNODB
+sql-mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
+
+#
+# * Fine Tuning
+#
+thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %>
+max_connections = <%= node['mysql']['tunable']['max_connections'] %>
+table_cache = <%= node['mysql']['tunable']['table_cache'] %>
+query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %>
+tmp_table_size = 5M
+myisam_max_sort_file_size = 100G
+myisam_sort_buffer_size = 8M
+key_buffer_size = 8M
+read_buffer_size = 64K
+read_rnd_buffer_size = 256K
+sort_buffer_size = 212K
+
+#
+# * InnoDB
+#
+# 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.
+#
+innodb_additional_mem_pool_size = 2M
+innodb_flush_log_at_trx_commit = 1
+innodb_log_buffer_size = 1M
+innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %>
+innodb_log_file_size = 10M
+innodb_thread_concurrency = 8

0 comments on commit 6891672

Please sign in to comment.