summaryrefslogtreecommitdiff
path: root/topics/systems/mariadb/mariadb.gmi
blob: 56661b6a70ba3d0657a24a35f849d35ab0e4c767 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# MariaDB

Here we capture some common actions

## Tags

* type: info, documentation
* keywords: mariadb, systems

## Check the transaction logs

Start the client and:

```
MariaDB [db_webqtl]> show binary logs;
+-----------------------+-----------+
| Log_name              | File_size |
+-----------------------+-----------+
| gn0-binary-log.000012 | 374532448 |
| gn0-binary-log.000013 | 933672549 |
| gn0-binary-log.000014 |  12774545 |
+-----------------------+-----------+
3 rows in set (0.001 sec)
```

To get a log

```
mysql -p -u webqtlout  db_webqtl -e "SHOW BINLOG EVENTS IN 'gn0-binary-log.000014';"
```

To get a log with some stuff filtered out try

```
mysql -p -u webqtlout db_webqtl -e "SHOW BINLOG EVENTS IN 'gn0-binary-log.000014';" -r -s |grep -v -e "Access\|GTID\|INSERT_ID\|COMMIT\|Temp\|lastlogin\|LITERA\|flush\|ROLLBACK"
```

## Update MariaDB on penguin2 to the latest production database

The MariaDB instance running on penguin2 needs to be periodically updated to the latest version of the database running on production. We do this by restoring backups of the production database stored on penguin2 into the penguin2 MariaDB database directory. Here's how.

Backups are managed using Borg as the ibackup user. First, become the ibackup user.
```
me@penguin2$ sudo -su ibackup
```
Borg expects the passphrase in an environment variable. Set it by sourcing this shell script.
```
ibackup@penguin2$ . /home/ibackup/.borg-pass
```
Change directory to /export/backup/tux01 and list the backup archives.
```
ibackup@penguin2:/export/backup/tux01$ /home/wrk/opt/borg/bin/borg list borg-tux01/
```
Stop the running mariadb-guix.service. Restore the latest backup archive and overwrite the existing database directory at /var/lib/mysql. Finally, restart the service. Note that /var/lib/mysql is actually a symbolic link to the real database directory at /export/mysql.

=> https://www.borgbackup.org/ Borg
=> https://borgbackup.readthedocs.io/en/stable/ Borg documentation