From 377b6b4251834519c47aff71afa1ba2b7951c92c Mon Sep 17 00:00:00 2001 From: Piotr Parczewski Date: Wed, 5 Jan 2022 09:49:58 +0100 Subject: [PATCH] Improve MariaDB restore procedure Change-Id: Id05122cb564f3e7475b2b76da8c111e2c72601b8 --- .../roles/mariadb/tasks/recover_cluster.yml | 1 + .../admin/mariadb-backup-and-restore.rst | 24 +++++++++++++++---- ...grastate-mariabackup-58ae93adf32d2bcb.yaml | 4 ++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/create-grastate-mariabackup-58ae93adf32d2bcb.yaml diff --git a/ansible/roles/mariadb/tasks/recover_cluster.yml b/ansible/roles/mariadb/tasks/recover_cluster.yml index dd426f3bf4..21aef27ac7 100644 --- a/ansible/roles/mariadb/tasks/recover_cluster.yml +++ b/ansible/roles/mariadb/tasks/recover_cluster.yml @@ -98,6 +98,7 @@ - name: Set grastate.dat file from MariaDB container in bootstrap host become: true lineinfile: + create: yes dest: "{{ docker_runtime_directory or '/var/lib/docker' }}/volumes/mariadb/_data/grastate.dat" regexp: 'safe_to_bootstrap:(.*)$' line: 'safe_to_bootstrap: 1' diff --git a/doc/source/admin/mariadb-backup-and-restore.rst b/doc/source/admin/mariadb-backup-and-restore.rst index bead7e58c2..1dcf3435df 100644 --- a/doc/source/admin/mariadb-backup-and-restore.rst +++ b/doc/source/admin/mariadb-backup-and-restore.rst @@ -77,7 +77,7 @@ Full ---- For a full backup, start a new container using the Mariabackup image with the -following options on the master database node: +following options on the first database node: .. code-block:: console @@ -92,14 +92,14 @@ following options on the master database node: (dbrestore) $ mbstream -x -C /backup/restore/full/ < mysqlbackup-04-10-2018.qp.xbc.xbs (dbrestore) $ mariabackup --prepare --target-dir /backup/restore/full -Stop the MariaDB instance. +Stop the MariaDB instance on all nodes: .. code-block:: console - docker stop mariadb + kolla-ansible -i multinode stop -t mariadb --yes-i-really-really-mean-it Delete the old data files (or move them elsewhere), and copy the backup into -place: +place, again on the first node: .. code-block:: console @@ -111,7 +111,9 @@ place: (dbrestore) $ rm -rf /var/lib/mysql/\.[^\.]* (dbrestore) $ mariabackup --copy-back --target-dir /backup/restore/full -Then you can restart MariaDB with the restored data in place: +Then you can restart MariaDB with the restored data in place. + +For single node deployments: .. code-block:: console @@ -120,6 +122,18 @@ Then you can restart MariaDB with the restored data in place: 81004 15:48:27 mysqld_safe WSREP: Running position recovery with --log_error='/var/lib/mysql//wsrep_recovery.BDTAm8' --pid-file='/var/lib/mysql//scratch-recover.pid' 181004 15:48:30 mysqld_safe WSREP: Recovered position 9388319e-c7bd-11e8-b2ce-6e9ec70d9926:58 +For multinode deployment restores, a MariaDB recovery role should be run, +pointing to the first node of the cluster: + +.. code-block:: console + + kolla-ansible -i multinode mariadb_recovery -e mariadb_recover_inventory_name=controller1 + +The above procedure is valid also for a disaster recovery scenario. In such +case, first copy MariaDB backup file from the external source into +``mariadb_backup`` volume on the first node of the cluster. From there, +use the same steps as mentioned in the procedure above. + Incremental ----------- diff --git a/releasenotes/notes/create-grastate-mariabackup-58ae93adf32d2bcb.yaml b/releasenotes/notes/create-grastate-mariabackup-58ae93adf32d2bcb.yaml new file mode 100644 index 0000000000..fbe750faad --- /dev/null +++ b/releasenotes/notes/create-grastate-mariabackup-58ae93adf32d2bcb.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Fixes an issue with recovering multi-node MariaDB Galera cluster.