MySQL InnoDB Cluster: Automated Installation with Puppet

We saw yesterday that the new MySQL Shell was out and how we could create a MySQL InnoDB Cluster manually using the Shell.

Today, I would like to show you how easy it is to create recipes to automate all the process. I have created a Puppet module that can be used as Proof-of-concept (You might need more features to use it in production, feel free to fork it).

The module can be found on this github repo.

When using Puppet, I really like to put all configuration in hiera.

Environment

We have 3 GNU/Linux servers: mysql1, mysql2 and mysql3.

We won’t install anything related to MySQL manually, everything will be handled by Puppet.

Nodes definition

So, we will define our classes and parameters in hiera.

We need to specify that our classes will be defined in hiera:

manifests/site.pp

hiera_include('classes')
node mysql1 {
}
node mysql2 {
}
node mysql3 {
}

This is the content of our hiera.yaml:

---
:backends:
  - yaml
:yaml:
  :datadir: /vagrant/hieradata
:hierarchy:
  - "%{::hostname}"
  - "%{::operatingsystem}"
  - common

We will have a common yaml file defining common parameters to all cluster nodes like the credentials and the seed, which point to the node we will use to bootsrap the group (see how to launch Group Replication).

common.yaml

---
 innodbcluster::mysql_root_password: fred
 innodbcluster::mysql_bind_interface: eth1
 innodbcluster::cluster_name: mycluster
 innodbcluster::grant::user: root
 innodbcluster::grant::password: fred
 innodbcluster::seed: mysql1

And finally every nodes need to have the class defined (it could also be defined in common.yaml) and the unique server_id:

mysql1.yaml:

---
classes:
- innodbcluster

innodbcluster::mysql_serverid:  1

mysql2.yaml:

---
classes:
- innodbcluster

innodbcluster::mysql_serverid:  2

mysql3:yaml:

---
classes:
- innodbcluster

innodbcluster::mysql_serverid:  3

And this is it !!

Easy isn’t it ?

The video below illustrates the full deployment of a MySQL InnoDB Cluster of 3 nodes using Puppet:

As usual, your feedback is important, don’t hesitate to submit bugs and features requests to https://bugs.mysql.com/ and if you like it, you can tell it too 😉

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

4 Comments

  1. […] So you’re interested in the “new” MySQL Group Replication feature but are concerned that configuring it is going to be difficult.  Let me soothe those concerns with this blog post.  Yes, the MySQL team has recently been discussing other methods to configure Group Replication using the RC release of MySQL Shell and how it can be used for tools such as Puppet for enhanced provisioning of a Group as Lefred has demonstrated in his MySQL Puppet post. […]

  2. […] So you’re interested in the “new” MySQL Group Replication feature but are concerned that configuring it is going to be difficult.  Let me soothe those concerns with this blog post.  Yes, the MySQL team has recently been discussing other methods to configure Group Replication using the RC release of MySQL Shell and how it can be used for tools such as Puppet for enhanced provisioning of a Group as Lefred has demonstrated in his MySQL Puppet post. […]

  3. Hello Lefred,

    Thanks for the great article, I just wanted to confirm that using Puppet it will also configure Group-replication as well for all Cluster nodes?

  4. Hi Lefred,

    Good Morning, Thanks for the great article.

    I’ve one question, In this article, the Puppet is also doing Group Replication configuration on this cluster?

    Regards!
    Mohsin

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.