kolla-ansible/ansible/roles/mariadb/templates/galera.cnf.j2
Mark Goddard b25c0ee477 Fix MariaDB 10.3 upgrade
Upgrading MariaDB from Rocky to Stein currently fails, with the new
container left continually restarting. The problem is that the Rocky
container does not shutdown cleanly, leaving behind state that the new
container cannot recover. The container does not shutdown cleanly
because we run dumb-init with a --single-child argument, causing it to
forward signals to only the process executed by dumb-init. In our case
this is mysqld_safe, which ignores various signals, including SIGTERM.
After a (default 10 second) timeout, Docker then kills the container.

A Kolla change [1] removes the --single-child argument from dumb-init
for the MariaDB container, however we still need to support upgrading
from Rocky images that don't have this change. To do that, we add new
handlers to execute 'mysqladmin shutdown' to cleanly shutdown the
service.

A second issue with the current upgrade approach is that we don't
execute mysql_upgrade after starting the new service. This can leave the
database state using the format of the previous release. This patch also
adds handlers to execute mysql_upgrade.

[1] https://review.openstack.org/644244

Depends-On: https://review.openstack.org/644244
Depends-On: https://review.openstack.org/645990
Change-Id: I08a655a359ff9cfa79043f2166dca59199c7d67f
Closes-Bug: #1820325
2019-03-23 10:21:37 +00:00

64 lines
2.1 KiB
Django/Jinja

{%- set wsrep_driver = '/usr/lib/galera/libgalera_smm.so' if kolla_base_distro in ['debian', 'ubuntu'] else '/usr/lib64/galera/libgalera_smm.so' %}
{% set sst_method = 'mariabackup' %}
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
basedir=/usr
bind-address={{ api_interface_address }}
port={{ mariadb_port }}
log-error=/var/log/kolla/mariadb/mariadb.log
log-bin=mysql-bin
binlog_format=ROW
expire_logs_days=14
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
datadir=/var/lib/mysql/
wsrep_cluster_address=gcomm://{% if (groups['mariadb'] | length) > 1 %}{% for host in groups['mariadb'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mariadb_wsrep_port }}{% if not loop.last %},{% endif %}{% endfor %}{% endif %}
wsrep_provider_options=gmcast.listen_addr=tcp://{{ api_interface_address }}:{{ mariadb_wsrep_port }};ist.recv_addr={{ api_interface_address }}:{{ mariadb_ist_port }}
wsrep_node_address={{ api_interface_address }}:{{ mariadb_wsrep_port }}
wsrep_sst_receive_address={{ api_interface_address }}:{{ mariadb_sst_port }}
wsrep_provider={{ wsrep_driver }}
wsrep_cluster_name="{{ database_cluster_name }}"
wsrep_node_name={{ ansible_hostname }}
wsrep_sst_method={{ sst_method }}
wsrep_sst_auth={{ database_user }}:{{ database_password }}
wsrep_slave_threads=4
wsrep_notify_cmd=/usr/local/bin/wsrep-notify.sh
wsrep_on = ON
max_connections=10000
key_buffer_size = '64M'
max_heap_table_size = '64M'
tmp_table_size = '64M'
{% set dynamic_pool_size_mb = (hostvars[inventory_hostname]['ansible_memtotal_mb'] * 0.4) | round | int %}
{% if dynamic_pool_size_mb < 8192 %}
innodb_buffer_pool_size = '{{ dynamic_pool_size_mb }}M'
{% else %}
innodb_buffer_pool_size = '8192M'
{% endif %}
# The default value for innodb_lock_schedule_algorithm is VATS, but this does
# not work with galera. Set FCFS explicitly to avoid a warning.
# https://mariadb.com/kb/en/library/innodb-system-variables/#innodb_lock_schedule_algorithm.
innodb_lock_schedule_algorithm = FCFS
[server]
pid-file=/var/lib/mysql/mariadb.pid