Commit fdc879bf 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 719b4ff9
......@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196
[template-mariadb]
filename = instance-mariadb.cfg.in
md5sum = 78dd18b8342eea855c2c84b6a453c8c9
md5sum = 1994cc11cc0da9c1df68ea0221e127b8
[template-kumofs]
filename = instance-kumofs.cfg.in
......
......@@ -383,6 +383,26 @@ eggs =
file = ${mariadb-replication-sense:output}
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') }}]
<= monitor-promise-base
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