| Support Status | Test Case |
|---|---|
| Production | 1 |
| Version | 3.0.13 |
A staging cluster is a child cluster of a production cluster containing 3 nodes, one replica is detached from replication and proxies track the the status of the standalone node to enable dev team to test on production data
A staging cluster and a child cluster of a cluster are created in one call, on the same replication-manager as the parent, on OpenSVC or Kubernetes:
POST /api/clusters/{parent}/actions/create-staging or create-child, body
{"name", "dbImage", "dbCount", "confirm"}; confirm false returns the plan.cluster-create-staging, cluster-create-child.| Staging | Child | |
|---|---|---|
| Use | the dev team tests on production data | test a migration (another release) under the parent's real writes |
| Default name | <parent>-staging |
<parent>-child |
| Databases | 3 | 2 |
| Own replication-source-name | staging |
child |
| After the seed | one replica detached: 1 Master, 1 Slave, 1 StandAlone, the proxy tracking the StandAlone | every node keeps replicating |
What the creation does:
innodb_io_capacity_max 2000 (it kept the defaults, 300 IOPS, whatever the DBU).staging or
child).The progress is the state CINF0014 on the new cluster; WARN0239 tells the step where it stopped and why. A cluster whose creation stopped is kept: fix the cause and reseed it from its parent, or drop it.
Rights: cluster-staging (staging) or cluster-replication (child) on the parent, and the
right to create a cluster.
Each index of a MariaDB child is filled and kept up to date by a process of its own: its own reader of the parent's binlog, its own position, its own initial load. A slow or failing index never delays another one, and the indexes load in parallel. The cost is one binlog reader on the parent per index.
sql_log_bin=0, so they never reach the child's
binary logs nor its replicas. Each server that keeps the index does so through its own link, with
its own reader and its own position. The link's account on the child needs SUPER or
BINLOG ADMIN (to set sql_log_bin).Each index has its own merge interval (the index settings, Merge interval, 0 to 86400 seconds): 0 applies each change at once; more collects the changes in a staging table merged into the index every this many seconds. The merge interval concerns the engines with a consolidated apply: ColumnStore and DuckDB (the changed keys deleted, then the rows bulk-loaded) and S3 (consolidated by partition: the partition touched rebuilt and swapped in); their deletes scan the table, so they cost far less merged hourly (3600) while the other indexes stay live. A row engine (InnoDB, Aria, TidesDB, RocksDB) applies the changes as they come. Left empty, an index takes the child's Merge Interval, the default of its indexes. The child's dashboard shows, for each index, its merge interval, its last and next merge, and what is waiting.
Every build of an index (its first load, a Reload index, the reseed of its child) loads a new
version of its table beside the one that serves. The live index keeps answering queries and
keeps receiving the changes of its source during the whole reload; once the new version has caught
up with the live one, it is switched in by one RENAME TABLE (all the tables of the index at once),
and the old version is dropped after the next change applied. A failed or interrupted reload drops
its new version and starts again; the live version is never touched.
information_schema.DISKS), else from the database jobs' report of the data directory; when
neither tells, a table over 1 GB is not doubled blind: the build waits with WARN0378 saying so.shadow-reload-engine, beside target-engine): empty, the new
version is loaded directly in the index's target engine; set (for example InnoDB), it is loaded
in that engine, which takes concurrent writes, and each partition is moved to the target engine
(ALTER TABLE ... ENGINE=) before the switch.replication-plugin-reload-shadow = false reloads in place, as before versions:
the table is emptied, then filled again, and does not answer completely meanwhile.The child's dashboard shows, for each index, its versions (the current one, the one being built with its progress, the previous one kept for a rollback), the wait for space, and the last version dropped or aborted with its reason.
A table whose pages are out of primary-key order on disk is slow to scan from disk: InnoDB reads its pages one by one, without read-ahead (measured: 16.2 s for a cold scan of a 7.4-million-row partition, 2.85 s once the partition was rebuilt). A build therefore loads each partition in primary-key order: the source is read range by range in the order of the index's driving key, whatever the plan of its join, and each partition's table has one writer at a time, its rows written in that order (the build's writers work on different partitions). This costs nothing on the build's time: on a 24-million-row test index the build took the same time, and a cold scan of a partition went from 0.78 s to 0.43 s.
replication-plugin-load-pk-order (default true, GUI Analytic Child, Load In Primary
Key Order): false lets several writers load one partition at once, as before.replication-plugin-load-pk-rebuild (default false, GUI Rebuild In Primary Key Order):
also rebuilds each InnoDB partition table (ALTER TABLE ... FORCE, replication-plugin-threads
at once) before it joins the version, for a fully compact table. It writes the whole version a
second time: on slow disks it took longer than the load itself. The index status shows its time
under pk order rebuild. Other engines are never rebuilt (RocksDB keeps its rows in key order
itself, an Aria or S3 table is read in file order, ColumnStore and DuckDB are columnar).A reload is loaded by several writers at once, and the stream between the parent and the child is
uploaded by several uploads at once. Both counts tune themselves: they start at
replication-plugin-threads (default 2), rise while the rows applied per second (the reader) or the
bytes uploaded per second (the publisher) keep rising, and step back when they stop rising.
replication-plugin-threads-max caps both (default 0: four times replication-plugin-threads, at
most 64); 1 switches the publisher's concurrent uploads off (one upload at a time, as before). The
dashboard shows both current values under In flight.
Every table the CDC moves to the S3 engine is compressed: replication-plugin-s3-compression
(default zlib) is the COMPRESSION_ALGORITHM of those tables; none stores them uncompressed.
It applies to the tables moved from then on; a table already in S3 keeps its compression.
A build reads its source on one consistent snapshot (REPEATABLE READ for its own sessions, whatever the server's default), at one GTID, the source only read.
replication-plugin-threads above 1, the source is read by that many
sessions at once (at most 16), all opened on one point of the binary log: replication-manager's
source user runs BACKUP STAGE START and BACKUP STAGE BLOCK_COMMIT (the source's commits wait
for a few milliseconds, never more than 5 seconds whatever happens), opens every reader's snapshot,
reads the GTID and ends the stage. This needs the BACKUP privilege (MariaDB 10.5 and later;
RELOAD before). The work is split by ranges of the driving table's primary key, each range read
whole by one reader.replication-plugin-threads 1,
one session reads the source: the build is then one SELECT, its rows read continuously, never
paused, cut into parts on the disk of replication-manager (the spool) while they wait for their
upload. On a 24-million-row test index this read 356,000 rows/s, against 193,000 by ranges.replication-plugin-spool-max-gb (default 64, GUI Spool Max (GB)): the most
the spool may hold. Past it, or when its filesystem falls under 10% free (at least 2 GB), the
build stops with the reason in the index status (its version abandoned, the index serving as
before) and is tried again later. 0 reads that single session by ranges instead, pausing between
them: no spool.range-step, default 10000 rows): the width of a range read by a
parallel reader. An integer primary key is cut by arithmetic from its smallest and largest values
(no extra read); another key by a probe of the step's last key.A build is sent in parts cut by their size, not by a number of rows (a narrow row and a JSON
document differ a hundred times): replication-plugin-restore-batch-gb (default 1, 0.01 to 4, GUI
Init Part Size (GB)). Parts are spooled to disk on both sides, never held in memory; a reader
loads at most 4 GB of parts at once. A seed's restore checkpoint takes it up to 256 MB.
A build is never resumed: a stop of the child's plugin during a build (a restart, a crash) drops the partial version, and the index shows reload required with the reason until a new version of its table starts (by itself when its stream is rebuilt, else with Reload index). The live version keeps serving meanwhile.
Two or more indexes (two sources, or one query split) can fill one table: each index gets a
slice (index setting Slice, 1 to 65535, unique for that table, kept). The index fills its own
table <table>_s<slice>, its rows carrying cdc_source = its slice, with its own stream, position
and versions: reloading one slice never touches the others. replication-manager makes the table the
clients read, <table>, over every slice:
cdc_source, each slice's partition
reading its table by name (the db tag spider, added with the slice).cdc_source and the period, each
partition reading the slice's S3 (or packed Aria) table of that period directly. The plugin that
rebuilds a partition repoints the shared table before it drops the table it replaced.UNION ALL of the slices' tables (PostgreSQL appends them, each slice's
partitions pruned in its branch).A table of that name that is not such a front (an index filled it alone before) is never dropped: WARN0379 says so, as any failure to make the front, with the reason.
Spider link passwords. The Spider tables of a child (the fronts of sliced, S3 and packed Aria
indexes, the parallel views) read the child's own tables through local accounts whose passwords
replication-manager draws on the child and never shows. A link is made once and kept. To give them
new passwords (a security rotation), use Rotate Spider Link Passwords in the child's analytic
settings (POST /api/clusters/{cluster}/replication-plugin-actions/rotate-spider-links, grant
cluster-replication): each front reading through a key is locked, the key made again, then the
front flushed, so none keeps the old password.
Target engine aria-packed: each period partition of the index is an Aria table packed by
aria_pack (read-only, compressed), read through a Spider front of the same partitioning, as S3
tables are, on the child's own disk. The changes wait in InnoDB delta tables (the live view
<table>_live reads the front and the delta); a changed partition is rebuilt from its delta into a
new Aria table, packed, and swapped in. A version (the first load, a reload) has every closed
partition packed before it is switched in.
aria_pack works on the closed table files, next to the data directory: the
database jobs container runs it (task ariapack, the official MariaDB image has the tool). The
child records the tables to pack in replication_manager_schema.cdc_pack_requests;
replication-manager dispatches the task; each request ends done or failed with the commands'
output. A rebuild round waits at most 30 minutes for its packs; a failed pack keeps the previous
packed table and the delta, with the reason in the index status.spider on the child.replication-plugin-rebuild-threads at a time
(default 1): parallel loads into Aria contend on its page cache.spider_quick_mode 3, the spider tag's value). Keep the
child's tmpdir on its data volume, the default (./.system/tmp); the notmpdisk tag and
prov-db-docker-tmpfs-size put it on a memory tmpfs, which a full read of a large front fills.An index's option Parallel Views lists named aggregate queries over its table, each with its
group items (columns, or expression AS alias), its measures (COUNT, SUM, MIN, MAX, AVG of
an expression AS alias; no DISTINCT) and an optional condition:
[{"name": "by_day", "group": ["DATE(entry_d) AS dy"], "measures": ["COUNT(*) AS cnt", "SUM(amount) AS amt"]}]
replication-manager makes for each, in the index's schema on the child:
v_<name>, a view to query as any table (SELECT * FROM v_by_day ORDER BY dy);f_<name>(), the function behind it: one GROUP BY per partition of the index, all sent at once
through the target's connection keys (Spider, one per DBU of the server), the partial results
merged exactly (sums of sums, minimum of minimums, AVG as a sum over a count), returned as JSON;p_<name>(), the same as a procedure (CALL p_by_day()), for a result too large for one JSON
value (max_allowed_packet, about ten million rows of a few columns).The partitions' queries follow the index's partitions as they are added or dropped, and the objects are made again when their definition changes. A failure is WARN0380, with the reason; the index itself is untouched. Empty: no views.
Every index created from 4.0.1 on carries a document id: a 64-bit number per row, computed from
the row's primary key, the same in every engine (InnoDB, Aria, RocksDB, ColumnStore, DuckDB, S3,
PostgreSQL, Manticore). It is the last column of the index, replication_manager_doc_id. Manticore
uses it as its document id; in the other engines it lets you match the same row across engines, or
join a Manticore search result back to its MariaDB row.
How it is computed
|. You can compute the
same number yourself in MariaDB or MySQL:SELECT CAST(CONV(LEFT(MD5(CONCAT_WS('|', ol_w_id, ol_d_id, ol_o_id, ol_number)), 16), 16, 10) AS UNSIGNED) AS doc_id
FROM order_line;
and in PostgreSQL:
SELECT ((('x' || left(md5(concat_ws('|', ol_w_id, ol_d_id, ol_o_id, ol_number)), 16))::bit(64)::bigint)::numeric
% 18446744073709551616 + 18446744073709551616) % 18446744073709551616 AS doc_id
FROM order_line;
List the key columns in the order of the index's primary key.
Refused at creation, with the reason: a key column that can be NULL, a FLOAT or DOUBLE key column, or a key column in a character set other than utf8mb4, utf8mb3, ascii or binary.
Collisions: two keys can, rarely, give the same 64-bit id. replication-manager checks at the
initial load and on every change, and raises the warning WARN0376 naming the index, the id and both
keys. A SQL engine keeps both rows; Manticore keeps the row already there. It is never silent.
Turning it off: the index option doc-id (in the index form, or docId in the API) is on by
default for a new index. Indexes created before 4.0.1 have none and are not changed. Turning it on or
off reloads the index.
An index of a MariaDB child can be a ColumnStore table (engine ColumnStore in the New Child
Cluster or the index settings). The child runs the official mariadb image; ColumnStore comes from
MariaDB's packages of that release (the engines bundle) and the child gets the mcs and
localinfile database tags. The table is made from the index's columns only (ColumnStore takes no
key, and some types are widened); its changes go through the index's InnoDB staging and are merged
by deleting the changed keys and bulk-loading the rows. A ColumnStore index takes no partition
option (ColumnStore organises its own storage). The engine is shown greyed, with the reason, when
the child's image cannot load it.
An index of a MariaDB child can be a DuckDB table (engine DuckDB in the New Child Cluster or the
index settings). It is an index of the MariaDB CDC link like any other: the replications list
shows it as repl-mariadb-mariadb-cdc with the engine DuckDB. Its changes are applied by the
enterprise DuckDB plugin (repl-mariadb-duckdb-cdc), which writes out of the binary log, as the
DuckDB engine requires: replication-manager runs it for the DuckDB indexes, and the index list says
"DuckDB applied by repl-mariadb-duckdb-cdc". The child gets the duckdb and localinfile database
tags. A DuckDB index takes no partition option, and its source tables need a primary key (no
partitioned table, no generated, invisible or BIT column, utf8mb4, utf8mb3 or ascii only).
When the DuckDB plugin is not installed on the instance, or the plan does not include the enterprise plugins, the engine is shown greyed with that reason (it names the plugin), and an index of that engine is refused: it is never written in another engine. Children created before keep their DuckDB indexes as they are: nothing to change in their configuration.
An index of a child can also be written into an app of the child cluster instead of its database:
a search index in a Manticore app, or a cache in a Valkey (Redis) or Memcached app.
In the index settings, set Target engine to manticore, valkey or memcached, and
Target app to the app's name (template manticore, valkey or memcached). The index is then
shown under that app in the servers table, as a SLAVE Idx row under the app's MASTER row. Such an
index is an index of a query, with its document id on, not partitioned, and applied at once (no
merge interval).
On Valkey and Memcached, each row of the index is one key, <slave table>:<document id>, its
value the row as JSON, for example sales:4711 holding {"ol_o_id":12,"ol_number":3,"i_name":"pen","amount":2.5}.
A deleted row deletes its key. The document id is the one of every engine (above): a single
integer key as is, else the first 64 bits of the MD5 of the key, so an application computes the key
of a row from its primary key. The index also keeps a few keys of its own under <slave table>:_schema
and <slave table>:_sk:* (which keys a change of a joined table reaches).
target-ttl, seconds): how long each key lives; empty or 0, it never expires.VALKEY_PASSWORD secret is used for AUTH. An initial load first removes the
keys of the index's former load.target-vnodes, default 160) tunes it. Memcached may evict any key and cannot list its keys: a
row deleted while the key that tracks it was evicted, or a key of a former initial load, stays
until its TTL. On Memcached, set a TTL.Three more apps take an index, the same way (Target engine and Target app):
Elasticsearch (template elasticsearch, one node, security on: its ELASTIC_PASSWORD is generated
for the app and used by replication-manager): each row of the index is one document, its _id the
document id, its fields the row's columns; a deleted row deletes its document. Target name sets the
Elasticsearch index (empty: the slave table in lowercase). The index's own records (which documents a
change of a joined table reaches) are kept in <index>-rm-meta.
Kafka (template kafka, one node in KRaft mode): each row change is a message on a topic (Target
name, empty: the slave table), its key the document id, its value the row; a deleted row is a
tombstone (a message with no value), so a compacted topic keeps the latest row of each key. Each
checkpoint is written in one Kafka transaction with replication-manager's position: a consumer that
reads committed messages (isolation.level=read_committed) gets every change exactly once, even when
the plugin is killed in the middle. Kafka is an enterprise plugin (it needs an enterprise plan).
RabbitMQ (template rabbitmq): each row change is a persistent message published to an exchange
(Exchange, target-name, empty: repman-cdc, a topic exchange created when missing), its routing key
the slave table or, with Routing key id (target-routing-key), the document id. The headers say
what it is: rm-op (upsert or delete), rm-id (the document id), rm-table, rm-format,
rm-payload. A deleted row is a message with an empty body and rm-op = delete. Each checkpoint is
published in one AMQP transaction with replication-manager's position, so a change is never published
twice, even when the plugin is killed. Bind your queues to the exchange before the index starts: a
message the exchange routes nowhere is dropped.
Joined tables on Kafka and RabbitMQ. An index can join other tables (orders with their items, products
with their category). replication-manager keeps its own copy of the index in the child cluster's database
(tables <slave table>_rm_mirror*), so when a joined row changes, it knows which documents it reaches:
each of them is published again with its new values (rename a category: one message per product of that
category), and a document that no longer matches the join is published as a delete.
Each of these apps shows its indexes as SLAVE rows under its MASTER row, named after the source server
and the plugin, for example db1.dev (elasticsearch-cdc).
Each CDC destination and each format is free (every replication-manager, Cloud18's open sign-up included) or enterprise (it needs an enterprise plan: partner, support or developer; its plugin is delivered signed with the enterprise plugins, and an installation without it refuses the index with that reason).
| Destination or format | Tier |
|---|---|
| MariaDB child (InnoDB and the other MariaDB engines) | free |
| ColumnStore | free |
| Manticore | free |
| Memcached | free |
| Elasticsearch | free |
| RabbitMQ | free |
| PostgreSQL child, tables copied | free |
| DuckDB | enterprise |
| S3 partitions | enterprise |
| PostgreSQL child, indexes of a query | enterprise |
| The PostgreSQL feed (a PostgreSQL source into MariaDB) | enterprise |
| Kafka | enterprise |
| Valkey (Redis) | enterprise |
format json (and columns) |
free |
formats msgpack, avro |
enterprise |
Two index settings, the same for every destination, decide what is stored:
| Destination | Format (target-format, default first) |
Payload (target-payload) |
|---|---|---|
| a database engine (InnoDB, Aria, RocksDB, TidesDB, PostgreSQL) | columns, json, msgpack, avro |
row, event |
| ColumnStore, DuckDB, S3 | columns |
row |
| Valkey | json, msgpack, avro, columns |
row, event |
| Memcached, Kafka, RabbitMQ | json, msgpack, avro |
row, event |
| Elasticsearch | columns (the document's fields) |
row, event |
| Manticore | columns |
row |
row (the default): the value is the row itself, its columns and their values, no envelope.event: {"op": "upsert" | "delete", "id": "<document id>", "table": ..., "gtid": ..., "ts": <source time>, "row": {...} | null}. A delete stays a delete (a tombstone on Kafka, after the delete event; a key or a
document removed elsewhere).json: an object of the columns, numbers for the numeric columns, null for NULL.msgpack: a MessagePack map of the columns, integers as integers, FLOAT/DOUBLE as floats, DECIMAL and
BIGINT UNSIGNED as their exact digits in a string.avro: a record derived from the index's columns (each nullable: long for an integer, double for
FLOAT/DOUBLE, string otherwise, DECIMAL included to keep its digits; a column name other than letters,
digits and _ has them replaced). Without a registry each value is an Avro single-object encoding
(C3 01, the 8-byte fingerprint of the schema, the body) and the schema is published: on Kafka on the
topic <topic>-schema keyed by the fingerprint, on Valkey and Memcached in <slave table>:_schema. On
Kafka, Schema registry (target-schema-registry, an http(s) URL of a Confluent schema registry)
registers the schema under <topic>-value and writes each value in Confluent's wire format, so the
registry's deserializers read it.rm-format, rm-payload and, for Avro without a registry,
rm-schema (the fingerprint).columns is the usual table. json, msgpack or avro make it a key-value table:
one row per document, replication_manager_doc_id (the key) and value (a JSON column for json, a
binary column otherwise). The event payload makes it a changelog: one row per change, rm_seq and
rm_n (the checkpoint and the change's order in it), op, the document id, gtid, ts, then the row's
columns (or one value column with the encoded event); each checkpoint's rows are written once, in one
transaction. Both need InnoDB (or Aria, RocksDB, TidesDB, PostgreSQL).columns: each document is a hash, one field per column (a NULL column has no field).A MariaDB child can keep indexes in MariaDB's S3 engine (target engine S3). The S3 engine reads
its storage keys from its configuration when the database starts, so the short-lived keys of the
Cloud18 sign-in cannot serve it. On an instance registered to Cloud18, replication-manager gives the
child a bucket and a key of its own, in the storage area of the account the instance is registered
with:
POST /api/clusters/{cluster}/settings/actions/cloud18-s3-engine (right
cluster-settings).replication-manager signs in to the storage with the account's stored credential, creates the
bucket <your id>-dwh in that account's area, then an access key of that account limited to that
bucket. The key is kept once (encrypted at rest, never shown, never in a log) and reused; it is the
S3 provider cloud18-dwh of the child, set as the S3 engine's provider with the s3 database tag.
A rolling restart of the child's databases then loads the S3 engine with it. The answer names
the bucket and what was made, never a key.
How an S3 index is laid out (since 4.0.1). An S3 index is partitioned (its partition column and
period are required). Each partition is its own S3 table, <index table>_<partition>, and the index
table itself is a Spider table of the same partitioning that reads them, so a query reads one
table and only the partitions its WHERE selects. The changes wait in InnoDB delta tables; a changed
partition is rebuilt into a new S3 table and swapped in with RENAME TABLE, never with
EXCHANGE PARTITION: MariaDB 12.3's S3 engine crashed the server when a partitioned S3 table was
opened during an exchange. <index table>_live shows the S3 rows and the waiting changes together.
The child therefore needs the spider database tag besides s3 (the engines bundle fetches
Spider of the server's release; a restart loads it): without it the index is refused with that
reason. replication-manager makes a local, read-only account and a Spider server for the schema
(its password drawn once, kept only by the database, never shown). Keep
spider_direct_aggregate off on such a child: MariaDB 12.3.4's Spider returns 0 for SUM,
MIN or MAX over an exact primary-key lookup when it is on.
Bootstrap Staging From Parent (API POST /api/clusters/{staging}/actions/staging-reseed-from-parent)
reloads an existing staging cluster with the parent's data of now:
gtid_strict_mode it
refuses to write an older one after them (error 1950). The fresh backup is past that
position, the parent's domain only moves forward. A new cluster holds none of the
parent's domain: its creation does not need it. MariaDB.A backup restored on a master with the binary log on goes to every replica through its binary log. While it runs (since 3.1.45):
max_binlog_total_size is
held at 2G on the master and its replicas, and slave_connections_needed_for_purge at 0
on the replicas (with the default 1, a server with no replica of its own never purges);
MariaDB purges by itself. The values come back at the end: the plan's
max_binlog_total_size under the dynamic config, the one found otherwise.Seconds_Behind_Master 0). A replica whose replication
is stopped, or delayed on purpose (hosts-delayed, MASTER_DELAY), does not take part.
WARN0254 names the replica the restore waits for. There is no timer: a restore can take
days.rpl_semi_sync_master_enabled,
rpl_semi_sync_source_enabled on MySQL and Percona 8.0.26 and later) and set back on at
the end, only when it was on: the pause already holds the restore for the replicas, and
every commit of the restore waited for an acknowledgement (a 858 MB backup took 16m51s
with it, 12m37s without).Cancelling a restore: a running logical reseed, from the parent or from the cluster's own
backup, single file or splitdump, stops with
GET /api/clusters/{cluster}/servers/{server}/actions/job-cancel/reseedmysqldump, also while
it is paused on a rotation. The binary log limit and semi-sync come back at once, without
waiting for the replicas. The data is then incomplete: the server's replication stays stopped,
WARN0252 says so until a reseed of that server ends. A reseed from the parent refused before
anything was loaded (no parent backup, no parent master, a reseed already running) starts the
master's replication from the parent again.
Outside a restore, prov-db-binlog-total-size-pct (default 25) gives max_binlog_total_size
as that share of prov-db-disk-size, never under 2G (template variable
%%ENV:SVC_CONF_ENV_MAX_BINLOG_TOTAL_SIZE%%, MariaDB 11.4 and later): the binary logs bounded
by the plan, not only by prov-db-expire-log-days, once the replication ruleset of the
configurator sets it.
## 4.4.12.2 To be change when proxy tracking state is enable
haproxy = false
## 4.4.12.3 Specify an other domain for staging
prov-db-domain = "3"
## 4.4.12.4 Specify an other source of replication for the staging cluster
replication-source-name = "staging"
## 4.4.12.5 Point the production cluster to enable mutti-tiers cluster master prod to master staging extra replication source
replication-multisource-head-cluster="prod-cluster"
## 4.4.12.6 Proxy Upgrade script
db-servers-state-change-script = "/data/repman/script/database_state_change.sh"
## 4.4.12.7 To enable ssh to database and proxy hosts, use ssh-keygen ssh-copy-id for first deployment
onpremise-ssh = true
onpremise-ssh-credential = "root:"
onpremise-ssh-private-key = "/root/.ssh/id_rsa_preprod"
scheduler-jobs-ssh = true
## 4.4.12.8 To automate logical backup
monitoring-scheduler = true
Api call should trigger similar script that will comes embedded in share
#!/bin/bash
# Variables
REPLICATION_MANAGER_USER="admin"
REPLICATION_MANAGER_PASSWORD="xxx"
REPLICATION_MANAGER_URL="https://repman-01:10005"
REPLICATION_MANAGER_CLUSTER_NAME="staging"
REPLICATION_MANAGER_HOST_NAME=$1
REPLICATION_MANAGER_HOST_PORT="3306"
NB_SLAVES=0
##### This bloc is for getting the replication-manager token
GET="wget -q --no-check-certificate -O- --header Content-Type:application/json"
AUTH_DATA="{\"username\": \"$REPLICATION_MANAGER_USER\", \"password\": \"$REPLICATION_MANAGER_PASSWORD\"}"
TOKEN=$($GET --post-data "$AUTH_DATA" --header Accept:text/html $REPLICATION_MANAGER_URL/api/login)
function get {
$GET --header Accept:application/json --header "Authorization: Bearer $TOKEN" "$@"
}
# Counting the slaves, depending, we will play one of the two following scenarios
NB_SLAVES=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq length)
echo $NB_SLAVES
# Scenario 1 : 2 slaves, then we will stop the replication on one that will be the "staging"
if [ $NB_SLAVES -eq 2 ]; then
echo "picking first slave \n"
ID=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].id' | sed 's/"//g' )
PORT=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].port')
echo "$ID:$PORT"
echo "Reseting first slave \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/reset-slave-all
sleep 2
echo "Stopping first server slave replication \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop-slave
sleep 20
echo "Stopping first mariadb server \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop
echo "Starting first mariadb server \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/start
loop=true
while $loop; do
sleep 1
IO_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].replications[0].slaveIoRunning.String')
SQL_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].replications[0].slaveSqlRunning.String')
echo $IO_THREADS
echo $SQL_THREADS
if [ "$IO_THREADS" == "\"No\"" ] || [ "$SQL_THREADS" == "\"No\"" ]; then
loop=false
fi
done
echo "Getting and saving slaves initial statuses \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].replications'>replications.save
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/reset-slave-all
sleep 2
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop
echo "Waiting for database server $ID to status failed \n"
loop=true
while $loop; do
ID_CHECK=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select(.state == "Failed").id' | sed 's/"//g')
if [ "$ID_CHECK" == "$ID" ]; then
loop=false
fi
done
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/start
fi
if [ $NB_SLAVES -eq 1 ]; then
echo "picking last slave and founding standalone \n"
ID=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select( .state == "StandAlone" ).id' | sed 's/"//g')
echo "found standalone server $ID \n"
echo "reseting master position on standalone \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/reset-master
echo "setup replication manager for reseeding \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autoseed
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-logical-backup
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-force-restore
sleep 2
echo "Stopping database server $ID \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop
echo "Waiting for database server $ID to status failed \n"
loop=true
while $loop; do
ID_CHECK=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select(.state == "Failed").id' | sed 's/"//g')
if [ "$ID_CHECK" == "$ID" ]; then
loop=false
fi
done
echo "Start database server $ID \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/start
sleep 20
echo "Reseting replciation manager settings for reseed = false \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autoseed
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-logical-backup
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-force-restore
###### Now set last slave as standalone
# Get the last available slave
ID_SLAVE=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select(.state == "Slave").id' | sed 's/"//g')
echo "last slave found for staging $ID_SLAVE \n"
echo "Stopping replication on last slave \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/stop-slave
loop=true
while $loop; do
echo "Waiting replication to stop \n"
sleep 5
IO_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq --arg id "$ID_SLAVE" '.[] | select(.id == $id).replications[0].slaveIoRunning.String')
SQL_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq --arg id "$ID_SLAVE" '.[] | select(.id == $id).replications[0].slaveSqlRunning.String')
# IO_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[] | select( .id == $ID_SLAVE ).replications[0].slaveIoRunning.String')
# SQL_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[] | select( .id == $ID_SLAVE ).replications[0].slaveSqlRunning.String')
echo $IO_THREADS
echo $SQL_THREADS
if [ "$IO_THREADS" == "\"No\"" ] || [ "$SQL_THREADS" == "\"No\"" ]; then
loop=false
fi
done
echo "Saving replication info in replication.save \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq --arg id "$ID_SLAVE" '.[] | select(.id == $id).replications' > replications.save
# get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[] | select( .id == $ID_SLAVE ).replications'>replications.save
echo "Reset all replication information \n"
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/reset-slave-all
sleep 2
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/stop
sleep 2
get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/start
fi
Today we can customize status change script to trigger some dedicated proxy config reload bu need native proxy integration
database_state_change.sh
#!/bin/bash
# This script is given as sample and will be overwrite on upgrade
# db-servers-state-change-script
echo "Database state change script args"
echo "Script:$0, Cluster:$1, Host:$2, Port:$3, State:$4, OldState:$5"
if [ "$4" = "StandAlone" ]; then
scp /data/repman/script/ha.cfg.$2 root@staging-proxy:/etc/haproxy/haproxy.cfg
ssh root@staging-proxy "systemctl reload haproxy"
fi