Added mariadb backendmaster
Usage | Usage | ||||
===== | ===== | ||||
Galera Cluster for MySQL is a true Multimaster Cluster based on synchronous | |||||
Galera Cluster for MySQL or Mariadb is a true Multimaster Cluster based on synchronous | |||||
replication. Galera Cluster is an easy-to-use, high-availability solution, | replication. Galera Cluster is an easy-to-use, high-availability solution, | ||||
which provides high system uptime, no data loss and scalability for future | which provides high system uptime, no data loss and scalability for future | ||||
growth. | growth. | ||||
version: | version: | ||||
mysql: 5.6 | mysql: 5.6 | ||||
galera: 3 | galera: 3 | ||||
engine: mysql or mariadb | |||||
master: | master: | ||||
enabled: true | enabled: true | ||||
name: openstack | name: openstack | ||||
Usage | Usage | ||||
===== | ===== | ||||
MySQL Galera check sripts | |||||
MySQL/Mariadb Galera check sripts | |||||
.. code-block:: bash | .. code-block:: bash | ||||
{% set engine = pillar.galera.get('engine', 'mysql') %} | |||||
# All files in this package is subject to the GPL v2 license | # All files in this package is subject to the GPL v2 license | ||||
# More information is in the COPYING file in the top directory of this package. | # More information is in the COPYING file in the top directory of this package. | ||||
# Copyright (C) 2011 severalnines.com | # Copyright (C) 2011 severalnines.com | ||||
innodb_doublewrite=0 | innodb_doublewrite=0 | ||||
innodb_autoinc_lock_mode=2 | innodb_autoinc_lock_mode=2 | ||||
innodb_locks_unsafe_for_binlog=1 | innodb_locks_unsafe_for_binlog=1 | ||||
wsrep_on=ON | |||||
{%- if service.members|length > 1 %} | {%- if service.members|length > 1 %} | ||||
wsrep_cluster_address="gcomm://{% for member in service.members %}{{ member.host}}:4567{% if not loop.last %},{% endif %}{% endfor %}/?pc.wait_prim=no" | wsrep_cluster_address="gcomm://{% for member in service.members %}{{ member.host}}:4567{% if not loop.last %},{% endif %}{% endfor %}/?pc.wait_prim=no" | ||||
{%- else %} | {%- else %} | ||||
wsrep_cluster_name="openstack" | wsrep_cluster_name="openstack" | ||||
wsrep_slave_threads={{ service.get('wsrep_slave_threads', 8) }} | wsrep_slave_threads={{ service.get('wsrep_slave_threads', 8) }} | ||||
{%- if engine == 'mysql' %} | |||||
wsrep_sst_method=xtrabackup-v2 | wsrep_sst_method=xtrabackup-v2 | ||||
wsrep_sst_auth={{ service.admin.user }}:{{ service.admin.password }} | wsrep_sst_auth={{ service.admin.user }}:{{ service.admin.password }} | ||||
{%- endif %} | |||||
wsrep_node_address={{ service.bind.address }} | wsrep_node_address={{ service.bind.address }} | ||||
wsrep_provider_options="gcache.size = 256M" | wsrep_provider_options="gcache.size = 256M" | ||||
wsrep_provider_options="gmcast.listen_addr = tcp://{{ service.bind.address }}:4567" | wsrep_provider_options="gmcast.listen_addr = tcp://{{ service.bind.address }}:4567" |
{% set engine = pillar.galera.get('engine', 'mysql') %} | |||||
{%- if pillar.galera is defined %} | {%- if pillar.galera is defined %} | ||||
include: | include: | ||||
{%- if pillar.galera.master is defined %} | {%- if pillar.galera.master is defined %} | ||||
{%- if engine == 'mysql' %} | |||||
- galera.master | - galera.master | ||||
{%- else %} | |||||
- galera.master_mariadb | |||||
{%- endif %} | |||||
{%- endif %} | {%- endif %} | ||||
{%- if pillar.galera.slave is defined %} | {%- if pillar.galera.slave is defined %} | ||||
{%- if engine == 'mysql' %} | |||||
- galera.slave | - galera.slave | ||||
{%- else %} | |||||
- galera.slave_mariadb | |||||
{%- endif %} | |||||
{%- endif %} | {%- endif %} | ||||
{%- if pillar.galera.clustercheck is defined %} | {%- if pillar.galera.clustercheck is defined %} | ||||
- galera.clustercheck | - galera.clustercheck |
{% set mysql_version = pillar.galera.get('version', {}).get('mysql', '5.6') %} | {% set mysql_version = pillar.galera.get('version', {}).get('mysql', '5.6') %} | ||||
{% set galera_version = pillar.galera.get('version', {}).get('galera', '3') %} | {% set galera_version = pillar.galera.get('version', {}).get('galera', '3') %} | ||||
{% set engine = pillar.galera.get('engine', 'mysql') %} | |||||
{%- load_yaml as master %} | {%- load_yaml as master %} | ||||
default: | default: | ||||
innodb_buffer_pool_size: '3138M' | innodb_buffer_pool_size: '3138M' | ||||
Debian: | Debian: | ||||
pkgs: | pkgs: | ||||
{%- if engine == 'mysql' %} | |||||
- mysql-wsrep-{{ mysql_version }} | - mysql-wsrep-{{ mysql_version }} | ||||
- python-mysqldb | |||||
- libdbd-mysql | |||||
- percona-xtrabackup | |||||
{%- else %} | |||||
- mariadb-server | |||||
- mariadb-client | |||||
{%- endif %} | |||||
- galera-{{ galera_version }} | - galera-{{ galera_version }} | ||||
- rsync | - rsync | ||||
- python-mysqldb | |||||
- psmisc | - psmisc | ||||
- netcat | - netcat | ||||
- percona-xtrabackup | |||||
- socat | - socat | ||||
- libdbd-mysql | |||||
- python-pymysql | - python-pymysql | ||||
service: mysql | |||||
service: {{ engine }} | |||||
wsrep_provider: /usr/lib/galera/libgalera_smm.so | wsrep_provider: /usr/lib/galera/libgalera_smm.so | ||||
log_file: /var/log/mysql.log | log_file: /var/log/mysql.log | ||||
socket: /var/run/mysqld/mysqld.sock | socket: /var/run/mysqld/mysqld.sock | ||||
innodb_buffer_pool_size: '3138M' | innodb_buffer_pool_size: '3138M' | ||||
Debian: | Debian: | ||||
pkgs: | pkgs: | ||||
{%- if engine == 'mysql' %} | |||||
- mysql-wsrep-{{ mysql_version }} | - mysql-wsrep-{{ mysql_version }} | ||||
- galera-{{ galera_version }} | |||||
- rsync | |||||
- python-mysqldb | - python-mysqldb | ||||
- libdbd-mysql | |||||
- libmysqlclient18 | - libmysqlclient18 | ||||
- percona-xtrabackup | |||||
{%- else %} | |||||
- mariadb-server | |||||
- mariadb-client | |||||
{%- endif %} | |||||
- galera-{{ galera_version }} | |||||
- rsync | |||||
- psmisc | - psmisc | ||||
- netcat | - netcat | ||||
- percona-xtrabackup | |||||
- socat | - socat | ||||
- libdbd-mysql | |||||
- python-pymysql | - python-pymysql | ||||
service: mysql | |||||
service: {{ engine }} | |||||
wsrep_provider: /usr/lib/galera/libgalera_smm.so | wsrep_provider: /usr/lib/galera/libgalera_smm.so | ||||
log_file: /var/log/mysql.log | log_file: /var/log/mysql.log | ||||
socket: /var/run/mysqld/mysqld.sock | socket: /var/run/mysqld/mysqld.sock |
{%- from "galera/map.jinja" import master with context %} | |||||
{%- if master.get('enabled', False) %} | |||||
{%- if master.get('ssl', {}).get('enabled', False) %} | |||||
include: | |||||
- galera._ssl | |||||
{%- endif %} | |||||
galera_packages: | |||||
pkg.installed: | |||||
- names: {{ master.pkgs }} | |||||
- refresh: true | |||||
- force_yes: True | |||||
galera_run_dir: | |||||
file.directory: | |||||
- name: /var/run/mysqld | |||||
- makedirs: true | |||||
- mode: 755 | |||||
- user: mysql | |||||
- group: root | |||||
- require: | |||||
- galera_packages | |||||
{%- if salt['cmd.shell']('test -e /etc/salt/.galera_bootstrap; echo $?') != '0' %} | |||||
galera_mariadb_stop_service: | |||||
service.dead: | |||||
- name: {{ master.service }} | |||||
galera_mariadb_new_cluster: | |||||
cmd.run: | |||||
- name: /usr/bin/galera_new_cluster | |||||
- require: | |||||
- galera_packages | |||||
- galera_config | |||||
galera_set_root_password: | |||||
cmd.run: | |||||
- name: mysqladmin password "{{ master.admin.password }}" | |||||
{%- if grains.get('noservices') %} | |||||
- onlyif: /bin/false | |||||
{%- endif %} | |||||
- require: | |||||
- galera_mariadb_new_cluster | |||||
mariadb_update_maint_password: | |||||
cmd.run: | |||||
- name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';" | |||||
{%- if grains.get('noservices') %} | |||||
- onlyif: /bin/false | |||||
{%- endif %} | |||||
- require: | |||||
- galera_mariadb_new_cluster | |||||
galera_mariadb_finish_flag: | |||||
file.touch: | |||||
- name: /etc/salt/.galera_bootstrap | |||||
- require: | |||||
- galera_mariadb_new_cluster | |||||
{%- endif %} | |||||
galera_config: | |||||
file.managed: | |||||
- name: {{ master.config }} | |||||
- source: salt://galera/files/my.cnf | |||||
- mode: 644 | |||||
- template: jinja | |||||
mariadb_service_enable: | |||||
service.running: | |||||
- name: {{ master.service }} | |||||
- enable: true | |||||
- require: | |||||
- galera_packages | |||||
- galera_config | |||||
{%- endif %} |
{%- from "galera/map.jinja" import slave with context %} | |||||
{%- if slave.get('enabled', False) %} | |||||
{%- if slave.get('ssl', {}).get('enabled', False) %} | |||||
include: | |||||
- galera._ssl | |||||
{%- endif %} | |||||
galera_packages: | |||||
pkg.installed: | |||||
- names: {{ slave.pkgs }} | |||||
- refresh: true | |||||
- force_yes: True | |||||
galera_run_dir: | |||||
file.directory: | |||||
- name: /var/run/mysqld | |||||
- makedirs: true | |||||
- mode: 755 | |||||
- user: mysql | |||||
- group: root | |||||
- require: | |||||
- galera_packages | |||||
{%- if salt['cmd.shell']('test -e /etc/salt/.galera_bootstrap; echo $?') != '0' %} | |||||
galera_set_root_password: | |||||
cmd.run: | |||||
- name: mysqladmin password "{{ slave.admin.password }}" | |||||
{%- if grains.get('noservices') %} | |||||
- onlyif: /bin/false | |||||
{%- endif %} | |||||
mariadb_update_maint_password: | |||||
cmd.run: | |||||
- name: mysql -u root -p{{ slave.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ slave.maintenance_password }}';" | |||||
{%- if grains.get('noservices') %} | |||||
- onlyif: /bin/false | |||||
{%- endif %} | |||||
mariadb_service_dead: | |||||
service.dead: | |||||
- name: {{ slave.service }} | |||||
galera_mariadb_finish_flag: | |||||
file.touch: | |||||
- name: /etc/salt/.galera_bootstrap | |||||
{%- endif %} | |||||
galera_config: | |||||
file.managed: | |||||
- name: {{ slave.config }} | |||||
- source: salt://galera/files/my.cnf | |||||
- mode: 644 | |||||
- template: jinja | |||||
mariadb_service_enable: | |||||
service.running: | |||||
- name: {{ slave.service }} | |||||
- enable: true | |||||
- require: | |||||
- galera_packages | |||||
- galera_config | |||||
{%- endif %} |
6xiZViPc4VayFnhDIC1w1oBqlhyIZ0AG/D7gqvfYiG6mHO32kPtHEN6Qzny8 | 6xiZViPc4VayFnhDIC1w1oBqlhyIZ0AG/D7gqvfYiG6mHO32kPtHEN6Qzny8 | ||||
-----END RSA PRIVATE KEY----- | -----END RSA PRIVATE KEY----- | ||||
galera: | galera: | ||||
engine: mariadb | |||||
master: | master: | ||||
enabled: true | enabled: true | ||||
name: galeracluster | name: galeracluster |
galera: | galera: | ||||
engine: mariadb | |||||
master: | master: | ||||
enabled: true | enabled: true | ||||
name: galeracluster | name: galeracluster |