Version information
This version is compatible with:
- Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.4.x
- Puppet >=4.9.0 < 6.0.0
- , ,
Start using this module
Add this module to your Puppetfile:
mod 'hfm-mha', '2.2.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-mha
Table of Contents
- Description
- Setup - The basics of getting started with MHA
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Description
The MHA module handles installing, configuring, and running MHA for MySQL.
Setup
Setup Requirements
The MHA module requires the following puppet modules:
- puppetlabs-stdlib: version 3.0.0 or newer.
- puppetlabs-mysql: version 3.5.0 or newer.
- proletaryo-supervisor: version 0.5.0 - 0.6.0.
- stahnma-epel: version 1.0.0 or newer.
Beginning with MHA
To install the mha4mysql-manager with default parameters, declare the mha::manager
class.
include '::mha::manager'
To install the mha4mysql-node with default parameters, declare the mha::node
class.
include '::mha::node'
Usage
Configuring mha::manager
class { '::mha::manager':
version => '0.57-0',
node_version => '0.57-0',
script_ensure => present,
}
Configuring mha::node
class { '::mha::node':
user => 'mha',
password => 'mysq1m@$terh@',
repl_user => 'replicator',
repl_password => 'rep1ic@t1r',
manager => 'master-ha.example.com',
nodes => [
{
'hostname' => 'node001.example.com',
'candidate_master' => 1,
},
{
'hostname' => 'node002.example.com',
'candidate_master' => 1,
},
{
'hostname' => 'node003.example.com',
},
],
ssh_private_key => '-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----',
ssh_key_type => 'ssh-rsa',
ssh_public_key => 'AAAAB3NzaC1yc2EAAAADAQABAAABAQCtnFFI/ICCBmr4LY0gIgyF3Jex20KwTFT67aoNGxAvjRSsg9d+c0/sxq0oBZSdgLoRrlnSu226mvv89E6dnc61JFbJpWN6et8qTW75e2/cU/DIe2vS3nTBcBvgj23oF2c5Wv7Vy2FacdDXaLa7tKmAnetI7FT+0IwmR7FMCvREmOqn4eCTkoUNXdLHqkQ0f2SSYBUUyno68nUM1bXgc63bQU8T1tr8kZ2t3NHpAa8YEYraKbCltsBkyqr7FExe5o23RyML4NuKfa1UllJhZO3IrQgbiAXsIFZpEqbcL8tObQ55nQIrNzZEvHoDN7K7jZP4WdjfTF26xSqJ+LrlGsRV',
}
Configuring modules from Hiera
---
mha::manager::version: '0.57-0'
mha::manager::node_version: '0.57-0'
mha::node::user: 'mha'
mha::node::password: 'mysq1m@$terh@'
mha::node::repl_user: 'replicator'
mha::node::repl_password: 'rep1ic@t0r'
mha::node::manager: 'master-ha.example.com'
mha::node::nodes:
- hostname: 'node001.example.com'
candidate_master: 1
- hostname: 'node002.example.com'
candidate_master: 1
- hostname: 'node003.example.com'
mha::node::ssh_key_type: 'ssh-rsa'
mha::node::ssh_public_key: 'AAAAB3NzaC1yc2EAAAADAQABAAABAQCtnFFI/ICCBmr4LY0gIgyF3Jex20KwTFT67aoNGxAvjRSsg9d+c0/sxq0oBZSdgLoRrlnSu226mvv89E6dnc61JFbJpWN6et8qTW75e2/cU/DIe2vS3nTBcBvgj23oF2c5Wv7Vy2FacdDXaLa7tKmAnetI7FT+0IwmR7FMCvREmOqn4eCTkoUNXdLHqkQ0f2SSYBUUyno68nUM1bXgc63bQU8T1tr8kZ2t3NHpAa8YEYraKbCltsBkyqr7FExe5o23RyML4NuKfa1UllJhZO3IrQgbiAXsIFZpEqbcL8tObQ55nQIrNzZEvHoDN7K7jZP4WdjfTF26xSqJ+LrlGsRV'
mha::node::ssh_private_key: |
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
Reference
Public Classes
mha::manager
Install and configure mha4mysql-manager, and install the mysql_online_switch script.
version
: Specify a mha4mysql-manager version. Valid values is 'x.y-z' like '0.57-0'.node_version
: Specify a mha4mysql-node version. Valid values is 'x.y-z' like '0.57-0'.script_ensure
: Whether the mysql_online_switch script should exist. Default to present.
mha::node
Install and configure mha4mysql-node, create grant permissions to access MySQL for administrator and replicator, configure the cron job to run purge_relay_logs script, and install a ssh key-pair.
manager
: Specify the host for mha4mysql-manager. Default to undef.version
: Specify the mha4mysql-node version. Valid values is 'x.y-z' like '0.57-0'.nodes
: Specify The array of the target MySQL servers that include hostname or IP address, or candidate_master. Default to [].user
: The MySQL administrative database username (ref). Default: 'root'.password
: The MySQL password of the "$user" user (ref). Default to '' (empty).repl_user
: The MySQL replication username (ref). Default to 'repl'.repl_password
: The MySQL password of the repl user (ref). Default: '' (empty).ssh_user
: The user connecting to mha-node with ssh. Default to 'root'ssh_key_type
: The encryption type used (ref).ssh_public_key
: The public key itself as the same as Ssh_authorized_key key attributes.ssh_key_path
: The path to the private key to manage. Default to '/root/.ssh/id_mha'.ssh_private_key
: The private key itself. See also ./manifests/params.pp.cron_ensure
: Whether the cron job should be in. Default to present.cron_user
: The user who owns the cron job. This user must be allowed to run this job. Default to 'root'.cron_minute
: The minute at which to run the cron job. Default to '10'.cron_hour
: The hour at which to run the cron job. Default to '2-23/6'.
Private Classes
mha::node::grants
: Create grant permissions to access MySQL for administrator and replicator.mha::node::install
: Install mha4mysql-node package.mha::node::purge_relay_logs
: Configure the cron job to run purge_relay_logs script.
Defined Types
mha::manager::app
Set up an application configuration file and configure mha4mysql-manager.
nodes
: The array of the target MySQL servers that include hostname or IP address, or candidate_master. Default to [].user
: The MySQL administrative database username. See https://code.google.com/p/mysql-master-ha/wiki/Parameters#user. Default: 'root'.password
: The MySQL password of the "$user" user. See https://code.google.com/p/mysql-master-ha/wiki/Parameters#password. Default to '' (empty).repl_user
: The MySQL replication username. See https://code.google.com/p/mysql-master-ha/wiki/Parameters#repl_user. Default to 'repl'.repl_password
: The MySQL password of the repl user. See https://code.google.com/p/mysql-master-ha/wiki/Parameters#repl_password. Default: '' (empty).ping_interval
: See https://code.google.com/p/mysql-master-ha/wiki/Parameters#ping_interval. Default to '3'.ping_type
: See https://code.google.com/p/mysql-master-ha/wiki/Parameters#ping_type. Default to 'SELECT'.ssh_user
: See https://code.google.com/p/mysql-master-ha/wiki/Parameters#ssh_user. Default to 'root'.ssh_port
: See https://code.google.com/p/mysql-master-ha/wiki/Parameters#ssh_port. Default to '22'.ssh_key_path
: The path to the private key to manage. Default to '/root/.ssh/id_mha'.ssh_private_key
: The private key itself. See also ./manifests/params.pp.default
: Other parameters for [server default] block. Default to {}.manage_daemon
: Whether the masterha_manager program should be managed by suporvisord. Default to false.
mha::node::grants::admin
Create grant permissions to access MySQL for administrator.
user
: The MySQL administrative database username. Default: undef.password
: The MySQL password of the "$user" user. Default: undef.host
: The host to use as part of user@host for grants. Default is a resource name ($name
).
mha::node::grants::repl
Create grant permissions to access MySQL for replicator.
user
: The MySQL replication username. Default: undef.password
: The MySQL password of the repl user. Default: undef.host
: The host to use as part of user@host for grants. Default is a resource name ($name
).
Limitations
This module has been tested on:
- RedHat Enterprise Linux 5, 6, 7
- CentOS 5, 6, 7
- Scientific Linux 5, 6, 7
Development
Running tests
The MHA puppet module contains tests for both rspec-puppet (unit tests) and beaker-rspec (acceptance tests) to verify functionality. For detailed information on using these tools, please see their respective documentation.
Testing quickstart
- Unit tests:
$ bundle install
$ bundle exec rake
- Acceptance tests:
# Set your DOCKER_HOST variable
$ eval "$(docker-machine env default)"
# List available beaker nodesets
$ bundle exec rake beaker_nodes
centos6
centos7
# Run beaker acceptance tests
$ BEAKER_set=centos7 bundle exec rake beaker
Smoke tests
You can run smoke tests using Vagrant:
$ vagrant up <vm> --provision
Authors
Changelog
v2.2.0 (2018-11-13)
v2.1.0 (2018-10-02)
v2.0.0 (2018-07-01)
Release 1.1.1 (2017/11/02)
Release 1.1.0 (2017/11/01)
Release 1.0.0 (2017/11/01)
Release 0.3.0 (2017/10/31)
Release 0.2.1 (2017/03/09)
- fixed bug variable name
- Fixed bug #25 (v0.2.0)
Release 0.2.0 (2017/03/09)
- Specify any ssh user
- Enable to specify ssh user to access to MHA nodes.
Release 0.1.1 (2017/02/13)
- Fixed RPM installation source can not be used and some tests
- RPM installation source now changes from Google Drive to this repository.
Release 0.0.13 (2016/07/07)
Release 0.0.12 (2016/06/02)
- Make ping options customizable
- Add params of ping_interval and ping_type
Release 0.0.11 (2016/05/31)
Release 0.0.10 (2016/03/28)
Release 0.0.9 (2016/03/27)
- Add the parameter to manage script #14
- Move /etc/masterma resource to mha::manager::install class #15
- Add default value to the version of mha::node::install class #16
Release 0.0.8 (2016/03/26)
- 10d1a4d Add packages for CentOS7
- Now mha4mysql-manager can be installed for CentOS7.
- mha4mysql-node can also.
Release 0.0.7 (2016/03/26)
- 18709fa Stop using ensure_resource()
Release 0.0.6 (2016/03/25)
- 698281d Fix: remove wget package from mha::node
- d77bf06 Newer MHA versions (from 0.56) will be hosted on Google Drive instead.
Release 0.0.5 (2016/03/25)
- 0fa8b2f Use curl instead of wget to download mha-manager
- 662bb1e Remove wget package resource on manifests
- f429e1c Use ensure params to configure mysql_online_switch file to manage
- 385373b Use file function instead of source
Release 0.0.4 (2016/03/24)
- Require epel module in mha::manager::install class.
Release 0.0.3 (2016/03/24)
- Add path to wget in mha::manager::install class.
Release 0.0.2 (2016/03/24)
- Initial release.
Dependencies
- puppetlabs-stdlib (>= 3.0.0 < 6.0.0)
- puppetlabs-mysql (>= 3.5.0 < 8.0.0)
- proletaryo-supervisor (>= 0.5.0 < 1.0.0)
- stahnma-epel (>= 1.0.0 < 2.0.0)