Oefenweb.percona_server_tools
percona-server-tools
Manage percona-server server (or any other flavour of MySQL) in Debian-like systems.
Requirements
mysql(will not be installed)mysqld, version>= 5.5(will not be installed)
Variables
Reset root password
Uses the debian-sys-maint from /etc/mysql/debian.cnf to login with.
percona_server_tools_reset_root_password: [default:{}]:percona_server_tools_reset_root_password.run: [default:false]: Whether or not to runreset-root-password.ymlpercona_server_tools_reset_root_password.root_password: [required]: Root passwordpercona_server_tools_reset_root_password.unsafe_variables: [optional, default:[]]: Variables (e.g. fromplugins) that causemysqldnot to start when started with--skip-grant-tables(e.g.^query_response_time_)
Resize InnoDB logs
Removes the current InnoDB log files in a safe way.
percona_server_tools_reset_ib_logfile: [default:{}]:percona_server_tools_reset_ib_logfile.run: [default:false]: Whether or not to runreset-ib-logfile.ymlpercona_server_tools_reset_ib_logfile.check_innodb_shutdown_mode: [default:true]: Whether or not to check the InnoDB shutdown modepercona_server_tools_reset_ib_logfile.ib_logfiles: [default:[/var/lib/mysql/ib_logfile0, /var/lib/mysql/ib_logfile1]]: InnoDB logs to resize
Setup slave replication (using xtrabackup)
Sets up slave replication on one or more slaves from a healthy master. Assumes that the slaves are able to pull backups using rsync over ssh, so ssh (keys) need to be set up.
Notes
- Recommends using the
any_errors_fataloption to interrupt execution on any error
percona_server_tools_setup_slave_replication: [default:{}]:percona_server_tools_setup_slave_replication.run: [default:false]: Whether or not to runsetup-slave-replication.ymlpercona_server_tools_setup_slave_replication.inventory: [required]: Inventory sectionpercona_server_tools_setup_slave_replication.inventory.master: [required]: The inventory hostname of the master server (e.g.db-01.example.com)percona_server_tools_setup_slave_replication.inventory.slaves: [required]: The inventory hostname(s) of the slave server(s) (e.g.[db-02.example.com, db-03.example.com])percona_server_tools_setup_slave_replication.innobackupex: [required]: Innobackupex sectionpercona_server_tools_setup_slave_replication.innobackupex.user: [optional]: Specifies the user (i.e., the MySQL username used when connecting to the server) to login as, if that's not the current user. It is passed to themysqlchild process without alterationpercona_server_tools_setup_slave_replication.innobackupex.password: [optional]: Specifies the password to use when connecting to the database. It is passed to themysqlchild process without alterationpercona_server_tools_setup_slave_replication.innobackupex.parallel: [optional]: Specifies the number of threads thextrabackupchild process should use to back up files concurrentlypercona_server_tools_setup_slave_replication.innobackupex.rsync: [optional]: Use thersyncutility to optimize local file transfers. When this option is specified,innobackupexusesrsyncto copy all non-InnoDB files instead of spawning a separatecpfor each file, which can be much faster for servers with a large number of databases or tablespercona_server_tools_setup_slave_replication.innobackupex.backup_dir: [required]: Specifies the backup directorypercona_server_tools_setup_slave_replication.innobackupex.use_memory: [optional]: Specifies the amount of memory in bytes forxtrabackupto use for crash recovery while preparing a backuppercona_server_tools_setup_slave_replication.master: [required]: Master sectionpercona_server_tools_setup_slave_replication.master.host: [required]: Specifies theMASTER_HOST, needed to setup the replication, but also the pull backups from the master (rsyncoverssh) (e.g.{{ hostvars['db-01.example.com']['ansible_eth1']['ipv4']['address'] }})percona_server_tools_setup_slave_replication.master.user: [required]: Specifies theMASTER_USER(e.g.replicator)percona_server_tools_setup_slave_replication.master.password: [required]: Specifies theMASTER_PASSWORDpercona_server_tools_setup_slave_replication.ssh_opts: [optional]: SSH options (e.g.['-o Ciphers=arcfour'])
Setup master replication (using xtrabackup)
Sets up master replication on one master from a healthy master. Assumes that the master is able to pull backups using rsync over ssh, so ssh (keys) need to be set up. Also assumes that there are no writes on the (secondary) master during the run of this playbook.
Notes
- Recommends using the
any_errors_fataloption to interrupt execution on any error - Requires
master(1|2).userto have bothGRANT REPLICATION SLAVEandREPLICATION CLIENTgrants
percona_server_tools_setup_master_replication.run: [default:false]: Whether or not to runsetup-master-replication.ymlpercona_server_tools_setup_master_replication.inventory.master1: [required]: The inventory hostname of the (primary) master server (e.g.db-01.example.com)percona_server_tools_setup_master_replication.inventory.master2: [required]: The inventory hostname of the (secondary) master server (e.g.db-02.example.com)percona_server_tools_setup_master_replication.innobackupex.user: [optional]: Specifies the user (i.e., the MySQL username used when connecting to the server) to login as, if that's not the current user. It is passed to themysqlchild process without alterationpercona_server_tools_setup_master_replication.innobackupex.password: [optional]: Specifies the password to use when connecting to the database. It is passed to themysqlchild process without alterationpercona_server_tools_setup_master_replication.innobackupex.parallel: [optional]: Specifies the number of threads thextrabackupchild process should use to back up files concurrentlypercona_server_tools_setup_master_replication.innobackupex.rsync: [optional]: Use thersyncutility to optimize local file transfers. When this option is specified,innobackupexusesrsyncto copy all non-InnoDB files instead of spawning a separatecpfor each file, which can be much faster for servers with a large number of databases or tablespercona_server_tools_setup_master_replication.innobackupex.backup_dir: [required]: Specifies the backup directorypercona_server_tools_setup_master_replication.innobackupex.use_memory: [optional]: Specifies the amount of memory in bytes forxtrabackupto use for crash recovery while preparing a backuppercona_server_tools_setup_master_replication.master1.host: [required]: Specifies theMASTER_HOST(onmaster2), needed to setup the replication, but also the pull backups from the master (rsyncoverssh) (e.g.{{ hostvars[percona_server_tools_setup_slave_replication_master]['ansible_eth1']['ipv4']['address'] }})percona_server_tools_setup_master_replication.master1.user: [required]: Specifies theMASTER_USER(e.g.replicator)percona_server_tools_setup_master_replication.master1.password: [required]: Specifies theMASTER_PASSWORDpercona_server_tools_setup_master_replication.master2.host: [required]: Specifies theMASTER_HOST(onmaster1), needed to setup the replication, but also the pull backups from the master (rsyncoverssh) (e.g.{{ hostvars[percona_server_tools_setup_slave_replication_master]['ansible_eth1']['ipv4']['address'] }})percona_server_tools_setup_master_replication.master2.user: [default:master1.user]: Same as abovepercona_server_tools_setup_master_replication.master2.password: [default:master1.password]: Same as abovepercona_server_tools_setup_master_replication.ssh_opts: [optional]: SSH options (e.g.['-o Ciphers=arcfour'])
Dependencies
None
Recommended
Example(s)
Reset root password
---
- hosts: all
roles:
- oefenweb.percona-server-tools
vars:
percona_server_tools_reset_root_password:
run: true
root_password: '6j~14F(Um~@nAz4hn6dT'
Resize InnoDB logs
---
- hosts: all
roles:
- oefenweb.percona-server-tools
vars:
percona_server_tools_reset_ib_logfile:
run: true
Setup slave replication
---
- hosts: all
roles:
- oefenweb.percona-server-tools
vars:
percona_server_tools_setup_slave_replication:
run: true
inventory:
master: db-01.example.com
slaves:
- db-02.example.com
innobackupex:
backup_dir: /tmp/xtrabackup
master:
host: "{{ hostvars[percona_server_tools_setup_slave_replication_master]['ansible_eth1']['ipv4']['address'] }}"
user: replicator
password: 'Z$8>YM"KUVRv6sW#=O-A'
Setup master replication
---
- hosts: all
roles:
- oefenweb.percona-server-tools
vars:
percona_server_tools_setup_master_replication:
run: true
inventory:
master1: db-01.example.com
master2: db-02.example.com
innobackupex:
backup_dir: /tmp/xtrabackup
master1:
host: "{{ hostvars['db-01.example.com']['ansible_eth1']['ipv4']['address'] }}"
user: replicator
password: 'Z$8>YM"KUVRv6sW#=O-A'
master2:
host: "{{ hostvars['db-02.example.com']['ansible_eth1']['ipv4']['address'] }}"
License
MIT
Author Information
Mischa ter Smitten
Feedback, bug-reports, requests, ...
Are welcome!
Manage percona-server server (or any other flavour of MySQL) in Debian-like systems
ansible-galaxy install Oefenweb.percona_server_tools