Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update the mariadb ops guide to show how to dump the databases #206

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions docs/infrastructure-mariadb-connect.md

This file was deleted.

54 changes: 54 additions & 0 deletions docs/infrastructure-mariadb-ops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# MariaDB Operations

Tips and tricks for managing and operating the MariaDB cluster within a Genestack environment.

## Connect to the database

Sometimes an operator may need to connect to the database to troubleshoot things or otherwise make modifications to the databases in place. The following command can be used to connect to the database from a node within the cluster.

``` shell
mysql -h $(kubectl -n openstack get service maxscale-galera -o jsonpath='{.spec.clusterIP}') \
-p$(kubectl --namespace openstack get secret maxscale -o jsonpath='{.data.password}' | base64 -d) \
-u maxscale-galera-client
```

!!! info

The following command will leverage your kube configuration and dynamically source the needed information to connect to the MySQL cluster. You will need to ensure you have installed the mysql client tools on the system you're attempting to connect from.

## Dumping the databases

When running `mysqldump` or `mariadbdump` the following commands can be useful for generating a quick backup.

``` shell
mysqldump --host=$(kubectl -n openstack get service mariadb-galera -o jsonpath='{.spec.clusterIP}')\
--user=root \
--password=$(kubectl --namespace openstack get secret mariadb -o jsonpath='{.data.root-password}' | base64 -d) \
--single-transaction \
--routines \
--triggers \
--events \
${DATABASE_NAME} \
--result-file=/tmp/${DATABASE_NAME}-$(date +%s).sql
```

!!! example "Dump all databases as individual files in `/tmp`"

``` shell
mysql -h $(kubectl -n openstack get service mariadb-galera -o jsonpath='{.spec.clusterIP}') \
-u root \
-p$(kubectl --namespace openstack get secret mariadb -o jsonpath='{.data.root-password}' | base64 -d) \
-e 'show databases;' \
--column-names=false \
--vertical | \
awk '/[:alnum:]/' | \
xargs -i mysqldump --host=$(kubectl -n openstack get service mariadb-galera -o jsonpath='{.spec.clusterIP}') \
--user=root \
--password=$(kubectl --namespace openstack get secret mariadb -o jsonpath='{.data.root-password}' | base64 -d) \
--single-transaction \
--routines \
--triggers \
--events \
{} \
--result-file=/tmp/{}-$(date +%s).sql
```
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ nav:
- Running Kubespray Upgrade: k8s-kubespray-upgrade.md
- Infrastructure:
- OVN Database Backup: infrastructure-ovn-db-backup.md
- Connecting to MySQL: infrastructure-mariadb-connect.md
- MariaDB Operations: infrastructure-mariadb-ops.md
- OpenStack:
- Generating Clouds YAML: openstack-clouds.md
- Keystone Federation to Rackspace: openstack-keystone-federation.md
Expand Down
Loading