30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
CM for MariaDB Galera cluster
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
About Adfinis SyGroup
● OpenSource service provider for 15 years
● based in Switzerland (Bern/Basel/Zurich)
● Software development and System Engineering
● multiple partners in the OSS community
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Why Configuration Management
● automate and standardize configuration of services/servers
● Provisioning
● automate changes on services/servers
● Deployment / Orchestration
● Infrastructure as Code
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Classical CM is not enough
● used for provisioning
● can't handle node interdependencies
● can't handle states from other nodes
● no timed execution
We need more than configuration management!
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
What defines a modern CM
● Orchestration capabilities
● run commands on a set of hosts
● Configuration Management + Orchestration
● apply changes to a set of hosts in a defined manner
● defined manner is important for clusters!
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
CM for clusters
● Provision: initialize all hosts to a defined state
● install packages, add configuration
● Bootstrap: initialize the cluster
● run commands on specific hosts in specific order
● Update: update/reconfigure the cluster
● run commands on specific hosts in specific order
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Which tools can handle batches
● Ansible
● serial per playbook (numeric or percentage)
● from 2.0: execution strategies
● Saltstack
● batch-size as CLI option (numeric or percentage)
● from Boron: option in orchestrate runner
● Puppet Enterprise (MCollective)
● batch as CLI option (numeric or percentage)
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Quick Ansible introduction
● Agentless – tasks are executed via SSH
● Ad-Hoc commands
ansible webserver -m apt -a "name=nginx state=latest"
● Playbooks
ansible-playbook galera.yml
● powerful language for more complex tasks
● Playbooks contain tasks to be executed in order
● Tasks can notify handlers (e.g. reload configuration)
● Roles are used to structure complex playbooks
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Orchestration with Ansible
● batch size for rolling updates
● only update a number of hosts at a time
● maximum failure percentage
● stop after a percentage of hosts have failed
● delegation
● delegate a task to another node
● conditional execution
● only run a task under certain conditions
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
MariaDB Galera cluster with Ansible
● Playbooks for provisioning, bootstrap and rolling update
● Roles for
● package installation
● firewall
● MariaDB Galera configuration
● MariaDB privileges
● MariaDB Galera cluster bootstrapping
currently tested on RHEL/CentOS 7
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Provisioning
● open ports on the firewall
● add repositories (MariaDB, EPEL)
● install packages
● MariaDB Galera
● Percona Xtrabackup v2 (SST)
● configure MariaDB Galera
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Bootstrapping
● only two tasks in the playbook
● bootstrap MariaDB Galera cluster
– first node in group
● restart MariaDB and join cluster
– rest of group
● tasks run one node at a time (serial: 1)
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Bootstrapping
galera-db-01
service mysql bootstrap
galera-db-02
service mysql start
initialer SST
galera-db-03
service mysql start
initialer SST
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Rolling Update
● role galera_conf can also handle rolling updates
● variable bootstrapped: yes needs to be set
● enables restart handler
● serial set to 49%
● no loss of quorum
● execution strategies enable more advanced behaviour
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Rolling Update
galera-db-01
service mysql restart
galera-db-02
service mysql restart
galera-db-03
service mysql restart
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Demo
● Preparation
● Reset VM's
● git clone https://github.com/adfinis-sygroup/mariadb-ansible-galera-cluster
● Installing requirements
# ansible-playbook -i galera.hosts galera.yml --tags setup
● Configure MariaDB Galera cluster
# ansible-playbook -i galera.hosts galera.yml --skip-tags setup
● Bootstrapping MariaDB Galera cluster
# ansible-playbook -i galera.hosts galera_bootstrap.yml
● Rolling MariaDB Galera cluster updates
# ansible-playbook -i galera.hosts galera_rolling_update.yml
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Questions?
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Sources and Links
● Ansible - https://docs.ansible.com/ansible/
● SaltStack - https://docs.saltstack.com/
● Puppet - https://docs.puppetlabs.com/
● MariaDB Galera Cluster Ansible Playbook -
https://github.com/adfinis-sygroup/mariadb-ansible-galera-cluster
● Adfinis SyGroup - https://adfinis-sygroup.ch/
30.11.2016 CM for MariaDB Galera Cluster 30.11.2016
Adfinis SyGroup AG
Lukas Grossar
@lukasgrossar
lukas.grossar@adfinis-sygroup.ch
Check out our techblog:
https://blog.adfinis-sygroup.ch/ https://git.io/vwPJ2

CM for MariaDB Galera cluster

  • 1.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 CM for MariaDB Galera cluster
  • 2.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 About Adfinis SyGroup ● OpenSource service provider for 15 years ● based in Switzerland (Bern/Basel/Zurich) ● Software development and System Engineering ● multiple partners in the OSS community
  • 3.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Why Configuration Management ● automate and standardize configuration of services/servers ● Provisioning ● automate changes on services/servers ● Deployment / Orchestration ● Infrastructure as Code
  • 4.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Classical CM is not enough ● used for provisioning ● can't handle node interdependencies ● can't handle states from other nodes ● no timed execution We need more than configuration management!
  • 5.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 What defines a modern CM ● Orchestration capabilities ● run commands on a set of hosts ● Configuration Management + Orchestration ● apply changes to a set of hosts in a defined manner ● defined manner is important for clusters!
  • 6.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 CM for clusters ● Provision: initialize all hosts to a defined state ● install packages, add configuration ● Bootstrap: initialize the cluster ● run commands on specific hosts in specific order ● Update: update/reconfigure the cluster ● run commands on specific hosts in specific order
  • 7.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Which tools can handle batches ● Ansible ● serial per playbook (numeric or percentage) ● from 2.0: execution strategies ● Saltstack ● batch-size as CLI option (numeric or percentage) ● from Boron: option in orchestrate runner ● Puppet Enterprise (MCollective) ● batch as CLI option (numeric or percentage)
  • 8.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Quick Ansible introduction ● Agentless – tasks are executed via SSH ● Ad-Hoc commands ansible webserver -m apt -a "name=nginx state=latest" ● Playbooks ansible-playbook galera.yml ● powerful language for more complex tasks ● Playbooks contain tasks to be executed in order ● Tasks can notify handlers (e.g. reload configuration) ● Roles are used to structure complex playbooks
  • 9.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Orchestration with Ansible ● batch size for rolling updates ● only update a number of hosts at a time ● maximum failure percentage ● stop after a percentage of hosts have failed ● delegation ● delegate a task to another node ● conditional execution ● only run a task under certain conditions
  • 10.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 MariaDB Galera cluster with Ansible ● Playbooks for provisioning, bootstrap and rolling update ● Roles for ● package installation ● firewall ● MariaDB Galera configuration ● MariaDB privileges ● MariaDB Galera cluster bootstrapping currently tested on RHEL/CentOS 7
  • 11.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Provisioning ● open ports on the firewall ● add repositories (MariaDB, EPEL) ● install packages ● MariaDB Galera ● Percona Xtrabackup v2 (SST) ● configure MariaDB Galera
  • 12.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Bootstrapping ● only two tasks in the playbook ● bootstrap MariaDB Galera cluster – first node in group ● restart MariaDB and join cluster – rest of group ● tasks run one node at a time (serial: 1)
  • 13.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Bootstrapping galera-db-01 service mysql bootstrap galera-db-02 service mysql start initialer SST galera-db-03 service mysql start initialer SST
  • 14.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Rolling Update ● role galera_conf can also handle rolling updates ● variable bootstrapped: yes needs to be set ● enables restart handler ● serial set to 49% ● no loss of quorum ● execution strategies enable more advanced behaviour
  • 15.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Rolling Update galera-db-01 service mysql restart galera-db-02 service mysql restart galera-db-03 service mysql restart
  • 16.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Demo ● Preparation ● Reset VM's ● git clone https://github.com/adfinis-sygroup/mariadb-ansible-galera-cluster ● Installing requirements # ansible-playbook -i galera.hosts galera.yml --tags setup ● Configure MariaDB Galera cluster # ansible-playbook -i galera.hosts galera.yml --skip-tags setup ● Bootstrapping MariaDB Galera cluster # ansible-playbook -i galera.hosts galera_bootstrap.yml ● Rolling MariaDB Galera cluster updates # ansible-playbook -i galera.hosts galera_rolling_update.yml
  • 17.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Questions?
  • 18.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Sources and Links ● Ansible - https://docs.ansible.com/ansible/ ● SaltStack - https://docs.saltstack.com/ ● Puppet - https://docs.puppetlabs.com/ ● MariaDB Galera Cluster Ansible Playbook - https://github.com/adfinis-sygroup/mariadb-ansible-galera-cluster ● Adfinis SyGroup - https://adfinis-sygroup.ch/
  • 19.
    30.11.2016 CM forMariaDB Galera Cluster 30.11.2016 Adfinis SyGroup AG Lukas Grossar @lukasgrossar lukas.grossar@adfinis-sygroup.ch Check out our techblog: https://blog.adfinis-sygroup.ch/ https://git.io/vwPJ2