Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

mysql-multi (21) Versions 2.1.2

MySQL replication wrapper cookbook

Policyfile
Berkshelf
Knife
cookbook 'mysql-multi', '= 2.1.2', :supermarket
cookbook 'mysql-multi', '= 2.1.2'
knife supermarket install mysql-multi
knife supermarket download mysql-multi
README
Dependencies
Changelog
Quality 0%

mysql-multi

Circle CI

Chef wrapper cookbook to create master/slave MySQL server setups. This wrapper
should work on all Debian and RHEL platform family OS's.

Utilization

This cookbook provides libraries to work along with MySQL community cookbook to
allow for the creation of master/slave and master/multi-slave MySQL systems.

The recipes and libraries provided here are designed for clean initial server setups of
this type of systems. They are not designed to do any type of fail-over, this type
of automation is better addressed by other tools.

*** Special Note:
This cookbook only supports MySQL community cookbook version 6.x, major changes
in this cookbook prior to version 6 have caused it to not be backwards compatible.
If you need support for MySQL community cookbook 5.x then use version 1.4.2 of
this cookbook.

This cookbook provides two recipes depending on the server's role. Keep in mind this
cookbook as well as the community MySQL cookbook have gone to a pure library design.
These recipes are provided for backwards compatibility and as examples of how to
write wrapper recipes to utilize the libraries. They may be removed in later releases.

default.rb : install a MySQL server instance.

mysql_master.rb : sets up a master MySQL server and creates replicant users
for each slave node defined within attributes. This recipe only configures master
specific configurations, it expects default.rb to be ran prior for proper converge.

When utilized, search will look for the node(s) in the same environment with the tag
mysql_slave and grant the allowed replicating node(s). If you do not want to
use search, create the slave node(s) first before bootstrapping, and set the
attribute ['mysql-multi']['master'] with the correct IP array.

mysql_slave.rb : sets up a slave MySQL server pointing to the master node
defined within attributes. This recipe only configures slave specific
configurations, it expects default.rb to be ran prior for proper converge.

Search will look for the node in the same environment with the tag
mysql_master and set master replication to that node. If you do not want to
use search, create the master node first before bootstrapping, and set the
attribute ['mysql-multi']['master'] with the correct IP.

Note that once a master has been discovered, it will no longer be automatically
changed to new masters as they are deployed. If a new master is installed, or
the existing master is deleted, you must manually set a new master for existing
slaves by editing the ['mysql-multi']['master'] attribute as described below.

Attributes

['mysql-multi']['master'] : sets the IP address that defines the master node

['mysql-multi']['slaves'] : is any array that defines the IP address(es) of
the slave node(s).

['mysql-multi']['slave_user'] : allows for the setting of a custom name for
the slave MySQL user, by default it is set to 'replicant'.

['mysql-multi']['server_repl_password'] : sets password for replicant user

['mysql-multi']['bind_ip'] is an override for the logic that determines the
best bind_address for mysql. Allowing you to set it to whatever is needed for
your specific configuration.

['mysql-multi']['install_recipe'] default behaviour is to install MySQL using
mysql-multi::default recipe, however this allows the use of your own custom recipe
should you require alternative configuration (e.g. data directory). Default to 'mysql-multi'

['mysql-multi']['serverid'] default behaviour is to use a unique ID create from
the IP address, however this allows manual overriding. Default to nil

Additional attributes added due to the redesign of the community MySQL recipe.

['mysql-multi']['server_root_password'] sets root password for MySQL service.

['mysql-multi']['service_name'] sets name for mysql service used in MySQL community recipe. Default is set to 'chef'

['mysql-multi']['server_version'] sets version of mysql installed via MySQL community cookbook. Defaults to 5.5.

['mysql-multi']['bind_address'] sets listening bind_address to 0.0.0.0 by default

['mysql-multi']['service_port'] sets listening port for MySQL service. Default to 3306.

Notice on need for mysql2 gem

The libraries (specifically slave_grants and slave_sync) require the mysql2 gem to be
installed on the nodes. This is currently done within the slave/master sample recipes. If
you are calling these libraries directly you need to ensure you are addressing this
requirement.

It can be addresses by adding the cookbook `mysql2_chef_gem' to your depends lists
as well as adding this code to your recipe:

mysql2_chef_gem 'default' do
  client_version node['mysql-multi']['server_version']
  action :install
end

Custom my.cnf settings

Currently the community MySQL cookbook does not address the need to add custom my.cnf configuration options to the default my.cnf file.

It simply drops the default my.cnf provided by the OS. You are expected to write a custom my.cnf file and add it to the /etc/mysql-service/conf.d/ directory if needed.

This can be done using the mysql_config resource, below is an example of what that might look like:

mysql_config 'custom my.cnf stuff' do
  config_name 'custom.my.cnf'
  instance 'default'
  source 'custom.my.cnf.erb'
  variables(:foo => 'bar')
  action :create
  notifies :restart, 'mysql_service[default]'
end

For additional documentation and examples see MySQL community README

License & Authors

Copyright:: 2014-2015 Rackspace US, 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.

mysql-multi Cookbook CHANGELOG

This file is used to list changes made in each version of the mysql-multi
cookbook.

v2.1.2 (2015-04-06)
- Added guard to slave_sync provider to keep it from trying to setup replication every run.

v2.1.1 (2015-3-24)
- Minor changes to the way recipe handles serverid's and added chef_gem version attribute

v2.1.0 (2015-3-20)
- Major update to recipes, moved MySQL service install specific code to default.rb
Leaving Master/Slave specific code in the other recipes

v2.0.0 (2015-3-02)
- Major update to provide compatibility with MySQL community cookbook version 6.x

v1.4.3 (update me for the release)
- Bump for dev

v1.4.2 (2014-12-05)
- Use fail instead of Chef::Application.fatal! in _find_master so that it can be caught

v1.3.3 (2014-08-27)
- Set the slave root password to match master since the sync will change it (Issue #21)
- Fix serverspec tests. (PR #22)

v1.3.2 (2014-08-01)
- Don't fail hard on solo runs without proper attribute config
- Better logic for error checking on empty slaves
- Throw a warning with no slaves instead of raising a fatal
- Set up mysql_service with upstream attribute options to allow overriding

v1.3.1 (2014-07-28)
- Clean up search logic
- Handle array result from search for master

v1.3.0 (2014-07-25)
- Add Travis-CI testing
- Add supported OS in metadata
- Updated search logic

v1.2.2 (2014-07-15)

  • Fix attribute typo (#10)

v1.2.1 (2014-07-11)

  • Create a proper array so we don't run into nil issues (#8)
  • Fix bug preventing mulitiple slaves (#9)

v1.2.0 (2014-07-08)

  • Add search functionality
  • Add 100% coverage in ChefSpec

Foodcritic Metric
            

2.1.2 failed this metric

FC031: Cookbook without metadata file: /tmp/cook/28a366583ab717da170f57ef/mysql-multi/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/28a366583ab717da170f57ef/mysql-multi/metadata.rb:1