Skip to content

Commit 69a4326

Browse files
author
Marc Schöchlin
committed
Enhance mariadb recovery procedure
Signed-off-by: Marc Schöchlin <marc.schoechlin@uhurutec.com>
1 parent 1a89baa commit 69a4326

File tree

1 file changed

+61
-6
lines changed

1 file changed

+61
-6
lines changed

docs/guides/operations-guide/infrastructure.md

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,72 @@ EOF
109109

110110
### Restore
111111

112-
* Stop all MariaDb Instances
113-
112+
* Gather the image and tag the current mariadb container
113+
* Opetion 1: Evaluate variables
114+
(Follow the references. TODO: Is there a more conventient way to do that??
115+
```
116+
osism dump inventory <host> mariadb_image
117+
osism dump inventory <host> mariadb_tag
118+
osism dump inventory <host> kolla_mariadb_version
119+
```
120+
* Opetion 2: Get image refernce from running container
121+
```
122+
ssh <first controller node>
123+
docker ps|grep mariadb-server
124+
```
125+
* Stop all MariaDB Instances
114126
```
115-
osism apply -s stop maria
127+
osism apply -a stop mariadb
116128
```
117-
118-
* Follow the [restore procedure described in the kolla-ansible manual](https://docs.openstack.org/kolla-ansible/latest/admin/mariadb-backup-and-restore.html#restoring-backups)
129+
* Perform restore operation<BR>
130+
(Based on the the [restore procedure described in the kolla-ansible manual](https://docs.openstack.org/kolla-ansible/latest/admin/mariadb-backup-and-restore.html#restoring-backups))
131+
* Login to the first controller nodes where the backups reside
132+
```
133+
ssh ${THE_NAME_OF_THE_RESTORE_NODE?}
134+
# example: "quay.io/osism/mariadb-server:10.11.9.20240909"
135+
IMAGE_REFERENCE="..."
136+
docker run --rm -it --volumes-from mariadb --name dbrestore \
137+
--volume mariadb_backup:/backup \
138+
${IMAGE_REFERENCE?} \
139+
/bin/bash
140+
```
141+
* Docker: Perform restore operation
142+
```
143+
cd /backup
144+
ls -latr
145+
rm -rf /backup/restore # remove old restore dir
146+
mkdir -p /backup/restore/full
147+
zcat mysqlbackup-18-12-2024-1734505244.qp.xbc.xbs.gz | mbstream -x -C /backup/restore/full/
148+
mariabackup --prepare --target-dir /backup/restore/full
149+
```
150+
* Docker: Eliminate old files
151+
```
152+
OLD_DATA_FILES_DIR="/backup/restore/old_data_files_$(date --date="today" "+%Y-%m-%d_%H-%M-%S")"
153+
mkdir -p ${OLD_DATA_FILES_DIR?}
154+
mv /var/lib/mysql/\.[^\.]* ${OLD_DATA_FILES_DIR?}/
155+
```
156+
* Docker: Restore backup into place
157+
```
158+
mariabackup --copy-back --target-dir /backup/restore/full
159+
exit
160+
```
161+
* TODO: Fix grastate.dat, already seems to be part of the mariadb_recovery playbook, but recovery procedure not seems to work
162+
```
163+
sed -i '~s,safe_to_bootstrap: .*,safe_to_bootstrap: 1,' /var/lib/mysql/grastate.dat
164+
```
165+
* Start container
166+
```
167+
exit
168+
docker start mariadb
169+
docker logs mariadb
170+
tail -f /var/log/kolla/mariadb/mariadb.log
171+
grep -P "Running position recovery with|Recovered position" /var/log/kolla/mariadb/mariadb.log
172+
```
119173
120174
* Execute the recovery procedure with the node name where you executed the recovery
121175
122176
```
123-
osism apply mariadb_recovery -e mariadb_recover_inventory_name=THE_NAME_OF_THE_RESTORE_NODE
177+
osism apply mariadb_recovery -e mariadb_recover_inventory_name=${THE_NAME_OF_THE_RESTORE_NODE?}
124178
```
125179
126180
### Recovery
@@ -130,6 +184,7 @@ to start a recovery.
130184
131185
```
132186
osism apply mariadb_recovery
187+
osism apply mariadb_recovery -e mariadb_recover_inventory_name=${THE_NAME_OF_THE_RECOVERY_NODE_OF_YOUR_CHOICE?}
133188
```
134189
135190
### Create database & user

0 commit comments

Comments
 (0)