SlideShare a Scribd company logo
Utilizing Ansible to Manage a Highly
Available MySQL Environment
MYSQL – ANSIBLE - MHA
Presented by ALKIN TEZUYSAL , MIKLOS SZEL
April 14 2015
About : Alkin Tezuysal
 Currently Team Manager, Pythian
 20 years experience in RDBMS world
 Acted as Sr. DBA to Supervisor roles
 Previously worked
 ebay Intl, Supervisor
 Bank of America, Sr. DBA
 AT&T, Sr. DBA
 How to Contact:
 Email: tezuysal@pythian.com
 Twitter: @ask_dba
 Linkedin: tr.linkedin.com/in/askdba/en
© 2015 Pythian Confidential2
About : Miklos ‘Mukka’ Szel
 Currently MySQL Consultant, Pythian
 10+ years experience System and Database world
 Acted as Sr. DBA, Sr. Ops, Developer
 Previously worked
Own startup
ISP
Walt Disney
 How to Contact:
 Email: szel@pythian.com
 Twitter: @42mukka
 Linkedin: hu.linkedin.com/in/miklosszel/en
© 2015 Pythian Confidential3
Ansible in a Nutshell
 Simple
 Agentless
 Easy to manage
 Idempotent
 100% Python
 Configuration management
 Uses ssh
For more: http://docs.ansible.com/intro_installation.html
© 2015 Pythian Confidential4
MHA in a Nutshell
 Automated Master failover
 Interactive Master failover
 Non-interactive Master failover
 Online Master switching
 Easy to configure
 Open Source HA utility
For more: https://code.google.com/p/mysql-master-ha/
© 2015 Pythian Confidential5
MySQL in a Nutshell
 De-facto standard for web, e-commerce and startup
companies
 Easy to manage and use
 Why we all are here
For more:
http://www.oracle.com/us/products/mysql/overview/index.ht
ml
© 2015 Pythian Confidential6
Back to Ansible
1) Installation
2) Configuration
3) Best practices
4) Demo on how to use with MySQL-MHA
© 2015 Pythian Confidential7
Installation - I
 Verify your version of Python, install pip:
$ sudo easy_install pip
 Add Python modules:
$ sudo pip install paramiko PyYAML Jinja2 httplib2
 Install Ansible via pip :
$ sudo pip install ansible
 Install Ansible via yum:
# install the epel-release RPM if needed on CentOS, RHEL, or Scientific Linux
$ sudo yum install ansible
 On OSX :
$ brew install ansible
For more: http://docs.ansible.com/intro_installation.html
© 2015 Pythian Confidential8
Installation - II
 Set hosts to test:
$ echo "127.0.0.1" > ~/ansible_hosts
$ export ANSIBLE_HOSTS=~/ansible_hosts
 Test your installation:
$ ansible all -m ping --ask-pass
SSH password:
127.0.0.1 | success >> {
"changed": false,
"ping": "pong"
}
© 2015 Pythian Confidential9
Configuration- I
 Setup Config file:
– ANSIBLE_CONFIG (an environment variable)
– ansible.cfg (in the current directory)
– ansible.cfg (in the home directory)
– /etc/ansible/ansible.cfg
For more: http://docs.ansible.com/intro_configuration.html
© 2015 Pythian Confidential10
Configuration- II
• Inventory file : Define hosts and groups
• Default file : /etc/ansible/hosts
[databases]
54.167.36.187 mysql_role=master server_id=1
23.22.187.189 mysql_role=slave server_id=2 backup_src=54.167.36.187
54.87.24.162 mysql_role=slave server_id=3 backup_src=54.167.36.187
[system]
54.167.36.187 mycnf=plsc_s1 mysql_role=master nickname=dev-plsc-m
23.22.187.189 mycnf=plsc_s2 mysql_role=slave nickname=dev-plsc-s1
54.87.24.162 mysql_role=slave nickname=dev-plsc-s2ample:
• Dynamic Inventory :
– AWS EC2 External Inventory Script (ec2.py)
# ansible-playbook -i "localhost," ansible/playbooks/launch_ec2.yml
# /ec2.py --list
For more: http://docs.ansible.com/intro_inventory.html ,
http://docs.ansible.com/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script
© 2015 Pythian Confidential11
Configuration- III
• Playbooks
– YAML format
– One or more “plays” in a list
– Executes tasks
– Supports hosts
– Supports roles
– Supports tags
– Supports groups
– Supports remote_user
– Provides idempotent runs against host groups
– Uses ansible modules
Example:
$ ansible-playbook playbook.yml --list-hosts
$ ansible-playbook playbook.yml --list-tasks
$ ansible-playbook playbook.yml -f 10
$ ansible-playbook playbook.yml --tags=setup,configure --list-tasks
$ ansible-playbook playbook.yml --tags=always,setup,configure --list-tasks
For more: http://docs.ansible.com/playbooks_intro.html
© 2015 Pythian Confidential12
Configuration- IV
• Ansible built-in modules
– Providing robust functions
– Runtime or via playbook
– Can be customized or developed
Example:
Adhoc
$ansible –i hosts.yml dbservers -m service -a "name=mysqld state=started"
$ansible –i hosts.yml webservers -m command -a "/sbin/reboot -t now"
Playbooks
- name: reboot the servers
command: /sbin/reboot -t now
For more: http://docs.ansible.com/modules.html
© 2015 Pythian Confidential13
Configuration- IV (cntd)
• MySQL Modules
– mysql_db  Add remove databases to remote hosts
– mysql_replication  Manage MySQL replication
– mysql_user  MySQL user management
– mysql_variables  Manage global variables
• Others Modules
– Mongodb, postgresql
– Package managers (yum, apt)
– Service
– File
– Template
For more: http://docs.ansible.com/list_of_database_modules.html#mysql
© 2015 Pythian Confidential14
Best practices – Ansible Vault
• ansible-vault
– Key management (aes256 encryption)
• Create new encrypted vault
$ ansible-vault create system.yml
• Editing encrypted key
$ ansible-vault edit system.yml
• Rekeying
$ ansible-vault rekey system.yml
• Encrypt unencrypted files
$ ansible-vault encrypt system.yml
• Decrypt encrypted files
$ ansible-vault decrypt system.yml
• Viewing decrypted files
$ ansible-vault view system.yml
• Playbook integration
$ ansible-playbook -i clusters/test setup.yml --ask-vault-pass
• File integration
$ ansible-playbook -i clusters/test setup.yml --vault-password-file ~/.vault_pass.txt
For more: https://docs.ansible.com/playbooks_vault.html
© 2015 Pythian Confidential15
Best practices – Templates
• Use of templates
# MHA cluster configuration
# generated by Ansible, do not modify by hand.
# config for cluster: {{cluster_id}}
[server default]
user={{my_mha_user}}
password={{my_mha_pass}}
repl_user={{my_repl_user}}
repl_password={{my_repl_pass}}
ssh_user=root
manager_workdir=/var/log/masterha/{{cluster_id}}
remote_workdir=/var/log/masterha/{{cluster_id}}
...
#my.cnf
innodb_buffer_pool_size = {{ (ansible_memtotal_mb * 70 / 100) |round|int }}M
…
For more: https://github.com/mszel-pythian/ansible_mha/blob/master/roles/common/templates/etc/cluster.cnf
© 2015 Pythian Confidential16
MySQL Use Cases
• Installation and deployments
• MySQL configuration management
• User management
• DB task management
– Backup and Restores
– Bootstrapping
• Database change management
• Database pool management
• Orchestration with other services
© 2015 Pythian Confidential17
Ansible Workflow
© 2015 Pythian Confidential18
© 2015 Pythian Confidential19
Demo – https://github.com/mszel-pythian/ansible_mha
• Show configuration files and sample setup
• Demonstrate launching ec2 mysql instances configuring MHA and failing
over with Ansible
– SYSTEM SETUP(common role)
• Fine tune system variables (sysctl)
• Install system packages and mha
• Create configuration files based on templates
• Create users based on public keys under files/users
– MYSQL PART(mysql role)
• Install mysql binaries
• Create my.cnf based on template (exception handling)
• Install mysql users (replica,system users, monitor app users), remove
passwordless users
• Build slave automatically with xtrabackup streaming
© 2015 Pythian Confidential20
Demo – (cntd)
roles/common/tasks/common_mha.yml
- yum: name=/root/mha4mysql-manager-0.56-0.el6.noarch.rpm state=present
when: "mysql_role == 'mha_manager'”
TASK: [common | yum name=/root/mha4mysql-manager-0.56-0.el6.noarch.rpm state=present] ***
skipping: [54.163.66.141]
skipping: [54.161.225.49]
skipping: [54.166.98.113]
changed: [54.157.195.13]
[…]
roles/mysql/tasks/main.yml:
- include: mysql_slave_xtrabackup.yml
when: "bootstrap_enabled and mysql_role != 'master'"
tags: slave
TASK: [mysql | Streaming the backup from {{ backup_src }} to {{ inventory_hostname }}] ***
skipping: [54.161.225.49]
changed: [54.166.98.113]
changed: [54.163.66.141]
Credits – Q & A
• Derek Downey @derek_downey Principal Consultant, Pythian
• Rick Pizzi DBA, Bravofly
• Narcis Pillao Devops, eDreams
• Contact us:
– Alkin Tezuysal : @ask_dba, tr.linkedin.com/in/askdba/en
– Mukka Szel : @42mukka, hu.linkedin.com/in/miklosszel/en
© 2015 Pythian Confidential22
ABOUT PYTHIAN
• 200+ leading brands trust us to keep their systems fast,
relaible, and secure
• Elite DBA & SysAdmin workforce: 7 Oracle ACEs, 2 Oracle
ACE Directors, 5 Microsoft MVPs, 1 Cloudera Champion of
Big Data, 1 Datastax Platinum Administrator — More than any
other company, regardless of head count
• Oracle, Microsoft, MySQL, Hadoop, Cassandra, MongoDB,
and more.
• Infrastructure, Cloud, SRE, DevOps, and application expertise
• Big data practice includes architects, R&D, data scientists,
and operations capabilities
• Zero lock-in, utility billing model, easily blended into existing
teams.
10,000Pythian currently manages more than 10,000
systems.
350Pythian currently employs more than 350
people in 25 countries worldwide.
1997Pythian was founded in 1997

More Related Content

What's hot (20)

PDF
Cloud Foundry V2を、もうちょっと深掘りしよう
Kazuto Kusama
 
PPTX
Hands on ansible
sumit23kumar
 
PPTX
Herd your chickens: Ansible for DB2 configuration management
Frederik Engelen
 
PPTX
RxJS 6 新手入門
Will Huang
 
PDF
FreeBSD jail+vnetと戯れた話
Masaru Oki
 
PDF
Ansible, best practices
Bas Meijer
 
PDF
Ansible - Hands on Training
Mehmet Ali Aydın
 
PPTX
第六回渋谷Java Java8のJVM監視を考える
chonaso
 
PDF
[1A7]Ansible의이해와활용
NAVER D2
 
PPTX
Automating with Ansible
Ricardo Schmidt
 
PPTX
Automated Deployments with Ansible
Martin Etmajer
 
PPTX
Ansible for beginners
Kuo-Le Mei
 
PPTX
Webアプリケーション負荷試験実践入門
樽八 仲川
 
PDF
Javaコードが速く実⾏される秘密 - JITコンパイラ⼊⾨(JJUG CCC 2020 Fall講演資料)
NTT DATA Technology & Innovation
 
PDF
오픈스택 멀티노드 설치 후기
영우 김
 
PDF
Ansible
Kamil Lelonek
 
PDF
Using Azure Compute with VMSS, Kubernetes, and Service Fabric
Takeshi Fukuhara
 
PDF
Run Qt on Linux embedded systems using Yocto
Marco Cavallini
 
PPTX
CRX: Container Runtime Executive 
imurata8203
 
Cloud Foundry V2を、もうちょっと深掘りしよう
Kazuto Kusama
 
Hands on ansible
sumit23kumar
 
Herd your chickens: Ansible for DB2 configuration management
Frederik Engelen
 
RxJS 6 新手入門
Will Huang
 
FreeBSD jail+vnetと戯れた話
Masaru Oki
 
Ansible, best practices
Bas Meijer
 
Ansible - Hands on Training
Mehmet Ali Aydın
 
第六回渋谷Java Java8のJVM監視を考える
chonaso
 
[1A7]Ansible의이해와활용
NAVER D2
 
Automating with Ansible
Ricardo Schmidt
 
Automated Deployments with Ansible
Martin Etmajer
 
Ansible for beginners
Kuo-Le Mei
 
Webアプリケーション負荷試験実践入門
樽八 仲川
 
Javaコードが速く実⾏される秘密 - JITコンパイラ⼊⾨(JJUG CCC 2020 Fall講演資料)
NTT DATA Technology & Innovation
 
오픈스택 멀티노드 설치 후기
영우 김
 
Ansible
Kamil Lelonek
 
Using Azure Compute with VMSS, Kubernetes, and Service Fabric
Takeshi Fukuhara
 
Run Qt on Linux embedded systems using Yocto
Marco Cavallini
 
CRX: Container Runtime Executive 
imurata8203
 

Viewers also liked (18)

PDF
Managing MySQL with Ansible
Ben Mildren
 
PPTX
Proxysql use case scenarios plam 2016
Alkin Tezuysal
 
PDF
Devops with ansible
Edwin Cruz
 
PDF
Proxysql ha plam_2016_2_keynote
Marco Tusa
 
PDF
ProxySQL Tutorial - PLAM 2016
Derek Downey
 
KEY
SLQ vs NOSQL - friends or foes
Pedro Gomes
 
PDF
Microsoft Azure : DevOps pour le Cloud... et réciproquement…
Microsoft Technet France
 
PDF
Using Vault to decouple MySQL Secrets
Derek Downey
 
PDF
OpenStack 2014 - Entre projet et stratégie
Savoir-faire Linux
 
PDF
OASIS TOSCA: Cloud Portability and Lifecycle Management
Cloud Standards Customer Council
 
PDF
Mix ‘n’ Match Async and Group Replication for Advanced Replication Setups
Pedro Gomes
 
PDF
Performance schema and sys schema
Mark Leith
 
PDF
MySQL sys schema deep dive
Mark Leith
 
PDF
Instrumenting plugins for Performance Schema
Mark Leith
 
PPTX
Proxysql use case scenarios fosdem17
Alkin Tezuysal
 
PDF
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem Overview
OpenTOSCA
 
PDF
Using Optimizer Hints to Improve MySQL Query Performance
oysteing
 
PPTX
Template Languages for OpenStack - Heat and TOSCA
Cloud Native Day Tel Aviv
 
Managing MySQL with Ansible
Ben Mildren
 
Proxysql use case scenarios plam 2016
Alkin Tezuysal
 
Devops with ansible
Edwin Cruz
 
Proxysql ha plam_2016_2_keynote
Marco Tusa
 
ProxySQL Tutorial - PLAM 2016
Derek Downey
 
SLQ vs NOSQL - friends or foes
Pedro Gomes
 
Microsoft Azure : DevOps pour le Cloud... et réciproquement…
Microsoft Technet France
 
Using Vault to decouple MySQL Secrets
Derek Downey
 
OpenStack 2014 - Entre projet et stratégie
Savoir-faire Linux
 
OASIS TOSCA: Cloud Portability and Lifecycle Management
Cloud Standards Customer Council
 
Mix ‘n’ Match Async and Group Replication for Advanced Replication Setups
Pedro Gomes
 
Performance schema and sys schema
Mark Leith
 
MySQL sys schema deep dive
Mark Leith
 
Instrumenting plugins for Performance Schema
Mark Leith
 
Proxysql use case scenarios fosdem17
Alkin Tezuysal
 
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem Overview
OpenTOSCA
 
Using Optimizer Hints to Improve MySQL Query Performance
oysteing
 
Template Languages for OpenStack - Heat and TOSCA
Cloud Native Day Tel Aviv
 
Ad

Similar to Ansible MySQL MHA (20)

PDF
Ansible : what's ansible & use case by REX
Saewoong Lee
 
PPTX
Ansible for large scale deployment
Karthik .P.R
 
PPTX
Ansible for large scale deployment
Remote MySQL DBA
 
PDF
Ansible automation tool with modules
mohamedmoharam
 
PPTX
Introduction to ansible
Dharmit Shah
 
PDF
MariaDB, MySQL and Ansible: automating database infrastructures
Federico Razzoli
 
PDF
Ansible is Our Wishbone
Mydbops
 
PDF
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
M Malai
 
PPTX
Automate DBA Tasks With Ansible
Ivica Arsov
 
PPTX
ansible : Infrastructure automation,idempotent and more
Sabarinath Gnanasekar
 
PDF
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
PPTX
Ansible
Afroz Hussain
 
PPTX
Introduction to Ansible
CoreStack
 
PDF
Using ansible to manage cloud platform by Accelerite
Madan Ganesh Velayudham
 
PDF
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Jumping Bean
 
PPTX
Ansible_Automation_tools that used in devops
priyanshmishra1991
 
PPTX
Ansible as configuration management tool for devops
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PDF
Using ansible to manage cloud stack
Kiran Manohar Chavala
 
PDF
Ansible Tutorial.pdf
NigussMehari4
 
PDF
Configuration of Ansible - DevOps: Beginner's Guide To Automation With Ansible
TetraNoodle_Tech
 
Ansible : what's ansible & use case by REX
Saewoong Lee
 
Ansible for large scale deployment
Karthik .P.R
 
Ansible for large scale deployment
Remote MySQL DBA
 
Ansible automation tool with modules
mohamedmoharam
 
Introduction to ansible
Dharmit Shah
 
MariaDB, MySQL and Ansible: automating database infrastructures
Federico Razzoli
 
Ansible is Our Wishbone
Mydbops
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
M Malai
 
Automate DBA Tasks With Ansible
Ivica Arsov
 
ansible : Infrastructure automation,idempotent and more
Sabarinath Gnanasekar
 
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
Ansible
Afroz Hussain
 
Introduction to Ansible
CoreStack
 
Using ansible to manage cloud platform by Accelerite
Madan Ganesh Velayudham
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Jumping Bean
 
Ansible_Automation_tools that used in devops
priyanshmishra1991
 
Ansible as configuration management tool for devops
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Using ansible to manage cloud stack
Kiran Manohar Chavala
 
Ansible Tutorial.pdf
NigussMehari4
 
Configuration of Ansible - DevOps: Beginner's Guide To Automation With Ansible
TetraNoodle_Tech
 
Ad

More from Alkin Tezuysal (20)

PDF
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
PDF
Unified Observability - Alkin Tezuysal - FOSSASIA Summit March 2025 .pdf
Alkin Tezuysal
 
PDF
Boosting MySQL with Vector Search Scale22X 2025.pdf
Alkin Tezuysal
 
PDF
Boosting MySQL with Vector Search Fosdem 2025.pdf
Alkin Tezuysal
 
PDF
London MySQL Day - Lightning Talk Dec 2024.pdf
Alkin Tezuysal
 
PDF
Design and Modeling with MySQL and PostgreSQL - Percona University Istanbul S...
Alkin Tezuysal
 
PDF
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Alkin Tezuysal
 
PPTX
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Alkin Tezuysal
 
PDF
FOSSASIA - MySQL Cookbook 4e Journey APR 2023.pdf
Alkin Tezuysal
 
PDF
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
Alkin Tezuysal
 
PDF
How OLTP to OLAP Archival Demystified
Alkin Tezuysal
 
PDF
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
Alkin Tezuysal
 
PDF
My first 90 days with ClickHouse.pdf
Alkin Tezuysal
 
PDF
KubeCon_NA_2021
Alkin Tezuysal
 
PDF
Integrating best of breed open source tools to vitess orchestrator pleu21
Alkin Tezuysal
 
PDF
Vitess: Scalable Database Architecture - Kubernetes Community Days Africa Ap...
Alkin Tezuysal
 
PDF
How to shard MariaDB like a pro - FOSDEM 2021
Alkin Tezuysal
 
PDF
Vitess - Data on Kubernetes
Alkin Tezuysal
 
PDF
MySQL Ecosystem in 2020
Alkin Tezuysal
 
PDF
Introduction to Vitess on Kubernetes for MySQL - Webinar
Alkin Tezuysal
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Unified Observability - Alkin Tezuysal - FOSSASIA Summit March 2025 .pdf
Alkin Tezuysal
 
Boosting MySQL with Vector Search Scale22X 2025.pdf
Alkin Tezuysal
 
Boosting MySQL with Vector Search Fosdem 2025.pdf
Alkin Tezuysal
 
London MySQL Day - Lightning Talk Dec 2024.pdf
Alkin Tezuysal
 
Design and Modeling with MySQL and PostgreSQL - Percona University Istanbul S...
Alkin Tezuysal
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Alkin Tezuysal
 
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Alkin Tezuysal
 
FOSSASIA - MySQL Cookbook 4e Journey APR 2023.pdf
Alkin Tezuysal
 
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
Alkin Tezuysal
 
How OLTP to OLAP Archival Demystified
Alkin Tezuysal
 
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
Alkin Tezuysal
 
My first 90 days with ClickHouse.pdf
Alkin Tezuysal
 
KubeCon_NA_2021
Alkin Tezuysal
 
Integrating best of breed open source tools to vitess orchestrator pleu21
Alkin Tezuysal
 
Vitess: Scalable Database Architecture - Kubernetes Community Days Africa Ap...
Alkin Tezuysal
 
How to shard MariaDB like a pro - FOSDEM 2021
Alkin Tezuysal
 
Vitess - Data on Kubernetes
Alkin Tezuysal
 
MySQL Ecosystem in 2020
Alkin Tezuysal
 
Introduction to Vitess on Kubernetes for MySQL - Webinar
Alkin Tezuysal
 

Recently uploaded (20)

PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
July Patch Tuesday
Ivanti
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 

Ansible MySQL MHA

  • 1. Utilizing Ansible to Manage a Highly Available MySQL Environment MYSQL – ANSIBLE - MHA Presented by ALKIN TEZUYSAL , MIKLOS SZEL April 14 2015
  • 2. About : Alkin Tezuysal  Currently Team Manager, Pythian  20 years experience in RDBMS world  Acted as Sr. DBA to Supervisor roles  Previously worked  ebay Intl, Supervisor  Bank of America, Sr. DBA  AT&T, Sr. DBA  How to Contact:  Email: [email protected]  Twitter: @ask_dba  Linkedin: tr.linkedin.com/in/askdba/en © 2015 Pythian Confidential2
  • 3. About : Miklos ‘Mukka’ Szel  Currently MySQL Consultant, Pythian  10+ years experience System and Database world  Acted as Sr. DBA, Sr. Ops, Developer  Previously worked Own startup ISP Walt Disney  How to Contact:  Email: [email protected]  Twitter: @42mukka  Linkedin: hu.linkedin.com/in/miklosszel/en © 2015 Pythian Confidential3
  • 4. Ansible in a Nutshell  Simple  Agentless  Easy to manage  Idempotent  100% Python  Configuration management  Uses ssh For more: http://docs.ansible.com/intro_installation.html © 2015 Pythian Confidential4
  • 5. MHA in a Nutshell  Automated Master failover  Interactive Master failover  Non-interactive Master failover  Online Master switching  Easy to configure  Open Source HA utility For more: https://code.google.com/p/mysql-master-ha/ © 2015 Pythian Confidential5
  • 6. MySQL in a Nutshell  De-facto standard for web, e-commerce and startup companies  Easy to manage and use  Why we all are here For more: http://www.oracle.com/us/products/mysql/overview/index.ht ml © 2015 Pythian Confidential6
  • 7. Back to Ansible 1) Installation 2) Configuration 3) Best practices 4) Demo on how to use with MySQL-MHA © 2015 Pythian Confidential7
  • 8. Installation - I  Verify your version of Python, install pip: $ sudo easy_install pip  Add Python modules: $ sudo pip install paramiko PyYAML Jinja2 httplib2  Install Ansible via pip : $ sudo pip install ansible  Install Ansible via yum: # install the epel-release RPM if needed on CentOS, RHEL, or Scientific Linux $ sudo yum install ansible  On OSX : $ brew install ansible For more: http://docs.ansible.com/intro_installation.html © 2015 Pythian Confidential8
  • 9. Installation - II  Set hosts to test: $ echo "127.0.0.1" > ~/ansible_hosts $ export ANSIBLE_HOSTS=~/ansible_hosts  Test your installation: $ ansible all -m ping --ask-pass SSH password: 127.0.0.1 | success >> { "changed": false, "ping": "pong" } © 2015 Pythian Confidential9
  • 10. Configuration- I  Setup Config file: – ANSIBLE_CONFIG (an environment variable) – ansible.cfg (in the current directory) – ansible.cfg (in the home directory) – /etc/ansible/ansible.cfg For more: http://docs.ansible.com/intro_configuration.html © 2015 Pythian Confidential10
  • 11. Configuration- II • Inventory file : Define hosts and groups • Default file : /etc/ansible/hosts [databases] 54.167.36.187 mysql_role=master server_id=1 23.22.187.189 mysql_role=slave server_id=2 backup_src=54.167.36.187 54.87.24.162 mysql_role=slave server_id=3 backup_src=54.167.36.187 [system] 54.167.36.187 mycnf=plsc_s1 mysql_role=master nickname=dev-plsc-m 23.22.187.189 mycnf=plsc_s2 mysql_role=slave nickname=dev-plsc-s1 54.87.24.162 mysql_role=slave nickname=dev-plsc-s2ample: • Dynamic Inventory : – AWS EC2 External Inventory Script (ec2.py) # ansible-playbook -i "localhost," ansible/playbooks/launch_ec2.yml # /ec2.py --list For more: http://docs.ansible.com/intro_inventory.html , http://docs.ansible.com/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script © 2015 Pythian Confidential11
  • 12. Configuration- III • Playbooks – YAML format – One or more “plays” in a list – Executes tasks – Supports hosts – Supports roles – Supports tags – Supports groups – Supports remote_user – Provides idempotent runs against host groups – Uses ansible modules Example: $ ansible-playbook playbook.yml --list-hosts $ ansible-playbook playbook.yml --list-tasks $ ansible-playbook playbook.yml -f 10 $ ansible-playbook playbook.yml --tags=setup,configure --list-tasks $ ansible-playbook playbook.yml --tags=always,setup,configure --list-tasks For more: http://docs.ansible.com/playbooks_intro.html © 2015 Pythian Confidential12
  • 13. Configuration- IV • Ansible built-in modules – Providing robust functions – Runtime or via playbook – Can be customized or developed Example: Adhoc $ansible –i hosts.yml dbservers -m service -a "name=mysqld state=started" $ansible –i hosts.yml webservers -m command -a "/sbin/reboot -t now" Playbooks - name: reboot the servers command: /sbin/reboot -t now For more: http://docs.ansible.com/modules.html © 2015 Pythian Confidential13
  • 14. Configuration- IV (cntd) • MySQL Modules – mysql_db  Add remove databases to remote hosts – mysql_replication  Manage MySQL replication – mysql_user  MySQL user management – mysql_variables  Manage global variables • Others Modules – Mongodb, postgresql – Package managers (yum, apt) – Service – File – Template For more: http://docs.ansible.com/list_of_database_modules.html#mysql © 2015 Pythian Confidential14
  • 15. Best practices – Ansible Vault • ansible-vault – Key management (aes256 encryption) • Create new encrypted vault $ ansible-vault create system.yml • Editing encrypted key $ ansible-vault edit system.yml • Rekeying $ ansible-vault rekey system.yml • Encrypt unencrypted files $ ansible-vault encrypt system.yml • Decrypt encrypted files $ ansible-vault decrypt system.yml • Viewing decrypted files $ ansible-vault view system.yml • Playbook integration $ ansible-playbook -i clusters/test setup.yml --ask-vault-pass • File integration $ ansible-playbook -i clusters/test setup.yml --vault-password-file ~/.vault_pass.txt For more: https://docs.ansible.com/playbooks_vault.html © 2015 Pythian Confidential15
  • 16. Best practices – Templates • Use of templates # MHA cluster configuration # generated by Ansible, do not modify by hand. # config for cluster: {{cluster_id}} [server default] user={{my_mha_user}} password={{my_mha_pass}} repl_user={{my_repl_user}} repl_password={{my_repl_pass}} ssh_user=root manager_workdir=/var/log/masterha/{{cluster_id}} remote_workdir=/var/log/masterha/{{cluster_id}} ... #my.cnf innodb_buffer_pool_size = {{ (ansible_memtotal_mb * 70 / 100) |round|int }}M … For more: https://github.com/mszel-pythian/ansible_mha/blob/master/roles/common/templates/etc/cluster.cnf © 2015 Pythian Confidential16
  • 17. MySQL Use Cases • Installation and deployments • MySQL configuration management • User management • DB task management – Backup and Restores – Bootstrapping • Database change management • Database pool management • Orchestration with other services © 2015 Pythian Confidential17
  • 18. Ansible Workflow © 2015 Pythian Confidential18
  • 19. © 2015 Pythian Confidential19
  • 20. Demo – https://github.com/mszel-pythian/ansible_mha • Show configuration files and sample setup • Demonstrate launching ec2 mysql instances configuring MHA and failing over with Ansible – SYSTEM SETUP(common role) • Fine tune system variables (sysctl) • Install system packages and mha • Create configuration files based on templates • Create users based on public keys under files/users – MYSQL PART(mysql role) • Install mysql binaries • Create my.cnf based on template (exception handling) • Install mysql users (replica,system users, monitor app users), remove passwordless users • Build slave automatically with xtrabackup streaming © 2015 Pythian Confidential20
  • 21. Demo – (cntd) roles/common/tasks/common_mha.yml - yum: name=/root/mha4mysql-manager-0.56-0.el6.noarch.rpm state=present when: "mysql_role == 'mha_manager'” TASK: [common | yum name=/root/mha4mysql-manager-0.56-0.el6.noarch.rpm state=present] *** skipping: [54.163.66.141] skipping: [54.161.225.49] skipping: [54.166.98.113] changed: [54.157.195.13] […] roles/mysql/tasks/main.yml: - include: mysql_slave_xtrabackup.yml when: "bootstrap_enabled and mysql_role != 'master'" tags: slave TASK: [mysql | Streaming the backup from {{ backup_src }} to {{ inventory_hostname }}] *** skipping: [54.161.225.49] changed: [54.166.98.113] changed: [54.163.66.141]
  • 22. Credits – Q & A • Derek Downey @derek_downey Principal Consultant, Pythian • Rick Pizzi DBA, Bravofly • Narcis Pillao Devops, eDreams • Contact us: – Alkin Tezuysal : @ask_dba, tr.linkedin.com/in/askdba/en – Mukka Szel : @42mukka, hu.linkedin.com/in/miklosszel/en © 2015 Pythian Confidential22
  • 23. ABOUT PYTHIAN • 200+ leading brands trust us to keep their systems fast, relaible, and secure • Elite DBA & SysAdmin workforce: 7 Oracle ACEs, 2 Oracle ACE Directors, 5 Microsoft MVPs, 1 Cloudera Champion of Big Data, 1 Datastax Platinum Administrator — More than any other company, regardless of head count • Oracle, Microsoft, MySQL, Hadoop, Cassandra, MongoDB, and more. • Infrastructure, Cloud, SRE, DevOps, and application expertise • Big data practice includes architects, R&D, data scientists, and operations capabilities • Zero lock-in, utility billing model, easily blended into existing teams. 10,000Pythian currently manages more than 10,000 systems. 350Pythian currently employs more than 350 people in 25 countries worldwide. 1997Pythian was founded in 1997