Commit 590bc924 authored by Xavier Thompson's avatar Xavier Thompson

stack/erp5: Add failover script

Add a script in bin directory that can be called manually to turn a
replica into a primary. Being able to turn a replica into a primary
is an absolutely necessary feature of replication. It's a necessary
step of a takoever procedure.

Questions remain for automatisation. One option is to provide a url
the user may simply interact with (clickable button ...) to trigger
the script, that may also be used automatically as part of a larger
takoever procedure.

Triggering the change to primary by editing the instance parameters
- such as by removing the replication-related parameters - does not
seem best: one immediate drawback is the uncertain propagation time
of instance parameters; another is the reliance on the availability
of the SlapOS master to trigger a usually time-sensitive operation.
parent 9d0849d9
...@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196 ...@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196
[template-mariadb] [template-mariadb]
filename = instance-mariadb.cfg.in filename = instance-mariadb.cfg.in
md5sum = cbc826eff8950c95d57ea5482a675259 md5sum = 34fb63681f1adcb38b7b1c36c0d54e47
[template-kumofs] [template-kumofs]
filename = instance-kumofs.cfg.in filename = instance-kumofs.cfg.in
......
...@@ -385,6 +385,26 @@ eggs = ...@@ -385,6 +385,26 @@ eggs =
file = ${mariadb-replication-sense:output} file = ${mariadb-replication-sense:output}
output = ${directory:plugins}/mariadb_replication.py output = ${directory:plugins}/mariadb_replication.py
[{{ section('mariadb-replica-become-primary') }}]
# See https://mariadb.com/kb/en/changing-a-replica-to-become-the-primary
recipe = slapos.cookbook:wrapper
wrapper-path = ${directory:bin}/${:_buildout_section_name_}
logfile = ${directory:log}/${:_buildout_section_name_}.log
command-line =
set -eu
mysql="${binary-wrap-mysql:wrapper-path}"
{
date
$mysql -e "
STOP ALL SLAVES;
RESET SLAVE ALL;
SHOW MASTER STATUS;
SELECT @@global.gtid_binlog_pos;
"
echo ""
} >> "${:logfile}"
echo "See ${:logfile}"
[{{ section('mariadb-backup-static-server-promise') }}] [{{ section('mariadb-backup-static-server-promise') }}]
<= monitor-promise-base <= monitor-promise-base
promise = check_socket_listening promise = check_socket_listening
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment