cdelgehier.XtraDB-Cluster
Ansible Role: ansible-role-XtraDB-Cluster
This Ansible role helps you set up a Percona XtraDB Cluster. This role specifically handles:
- Installing the necessary packages
- Securing connections
- Bootstrapping the cluster
Requirements
No special requirements are needed.
Role Variables
Basics
Variable | Default | Comments |
---|---|---|
xtradb_bind_address |
- | The IP address to listen on |
xtradb_bind_interface |
eth0 |
The network interface for the cluster |
xtradb_cluster_name |
foo |
Name of the cluster |
xtradb_configured |
xtradb_datadir/configured |
Used for idempotency |
xtradb_datadir |
/var/lib/mysql |
Data directory |
xtradb_master_node |
groups[xtradb_nodes_group][0] |
The node designated as master |
xtradb_mysql_user |
mysql |
User to run Galera |
xtradb_nodes_group |
xtradb-cluster-nodes |
Group of nodes in the cluster |
xtradb_root_password |
root |
Password for the root user |
xtradb_root_user |
root |
The root user |
xtradb_secured |
xtradb_datadir/secured |
Used for idempotency |
xtradb_service |
mysql |
Linux service name |
xtradb_sst_password |
sstpassword |
Password for the xtradb_sst_user |
xtradb_sst_user |
sstuser |
User for state snapshot transfer |
xtradb_swappiness |
0 |
The swappiness value |
xtradb_databases |
[] | List of database names to add |
xtradb_users |
[] | List of users to add |
xtradb_version |
57 |
Version of XtraDB |
MySQL Parameters
For additional details, refer to the MariaDB Server System Variables.
Variable | Default | Comments |
---|---|---|
xtradb_binlog_format |
ROW |
Format for binary logging |
xtradb_character_set_server |
utf |
Character set used |
xtradb_collation_server |
utf8_general_ci |
Collation |
xtradb_default_storage_engine |
InnoDB |
Default storage engine setting |
xtradb_innodb_autoinc_lock_mode |
2 |
Lock modes for auto-increment |
xtradb_innodb_buffer_pool_instances |
|
Number of buffer pool instances |
xtradb_innodb_buffer_pool_size |
|
Size of the InnoDB buffer pool |
xtradb_innodb_file_per_table |
on |
Enables separate tablespace for each table |
xtradb_innodb_flush_log_at_trx_commit |
|
Determines logging behavior during commits |
xtradb_innodb_log_buffer_size |
|
Size of the log buffer |
xtradb_max_connections |
4096 |
Maximum number of connections |
xtradb_slow_query_log |
0 |
Set to 1 to enable slow query logging |
xtradb_skip_name_resolve |
1 |
Only use IP addresses, set to 0 for hostnames |
Adding Databases
Databases are defined with a dictionary containing name:
(required) and init_script:
(optional). The init script initializes the database with tables and values.
xtradb_databases:
- name: keystone
- name: mydb
init_script: files/init_mydb.sql
Adding Users
Users are defined with a dictionary containing name:
, password:
, priv:
, and optionally host:
.
xtradb_users:
- name: keystone
password: KEYSTONE_DBPASS
priv: 'keystone.*:SUPER'
- name: cdelgehier
password: yolo
priv: 'mydb.*:ALL'
host: '192.168.1.%'
Dependencies
There are no dependencies required.
Example Playbook
- hosts: db
gather_facts: true
become: true
roles:
- role: ansible-role-XtraDB-Cluster
xtradb_cluster_name: "prod-customer"
xtradb_sst_user: sstuser
xtradb_sst_password: s3cr3t
xtradb_root_password: yolo
xtradb_bind_interface: eth0
- hosts: db
gather_facts: true
become: true
roles:
- role: ansible-role-XtraDB-Cluster
xtradb_cluster_name: "prod-customer"
xtradb_bind_address: "{{ ansible_default_ipv4.address }}"
xtradb_master_node: "{{ hostvars[ groups['db'][0] ].ansible_default_ipv4.address }}"
[db]
node1 ansible_host=192.168.1.173
node2 ansible_host=192.168.1.156
node3 ansible_host=192.168.1.154
Testing
You can test using two environments: one with Vagrant and the other with Docker, suitable for automated tests. Check the README files in the corresponding branches for setup instructions.
- Docker: docker-tests
Remove
To start fresh and remove all traces:
ansible db -m shell -a 'rm -rf /var/lib/mysql /var/log/mysqld.log /etc/percona-xtradb-cluster.conf.d ; yum remove Percona* -y'
Contributing
Feel free to report issues or suggest features in the Issues section. Pull requests are welcomed. To submit a PR, fork the project and create a topic branch for your change, then push to your fork and create a PR on GitHub.
License
This project is licensed under the 2-clause BSD license. See LICENSE.md for details.
Contributors
- Cedric DELGEHIER (maintainer)
Install and configure a Cluster Mysql
ansible-galaxy install cdelgehier.XtraDB-Cluster