TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/wikioasis/salt/llms.txt
Use this file to discover all available pages before exploring further.
mariadb Salt state manages the full lifecycle of MariaDB on every db* server in the WikiOasis fleet. It installs the mariadb-server package, renders a Jinja-templated 50-server.cnf, ensures the log directory has the correct ownership, and keeps the service running and watching for config changes. Sub-states extend the base with automated backup/restore tooling, binlog streaming, and monitoring users for Icinga and Prometheus.
Base state (mariadb)
Log directory
Creates
/var/log/mysql owned by mysql:adm with setgid mode 2750 so log files are group-readable by monitoring agents.Server configuration
Renders
/etc/mysql/mariadb.conf.d/50-server.cnf from the Jinja template salt://mariadb/files/50-server.cnf.jinja using values from the mariadb pillar key.Pillar reference
All keys live under the top-levelmariadb mapping. The innodb sub-key groups InnoDB-specific tunables.
Top-level mariadb pillar keys
Top-level mariadb pillar keys
| Key | Default | Description |
|---|---|---|
datadir | /var/lib/mysql | Path to the MariaDB data directory |
bind_address | 0.0.0.0 | Interface address the server listens on |
key_buffer_size | 128M | MyISAM index key buffer (keep small if InnoDB-only) |
max_allowed_packet | 1G | Maximum packet size for large LOAD DATA / BLOB operations |
thread_stack | 192K | Stack size per connection thread |
thread_cache_size | 8 | Threads to cache for reuse on new connections |
max_connections | 100 | Maximum simultaneous client connections |
table_cache | 64 | Number of open table descriptors to cache |
expire_logs_days | 10 | Automatic binary log expiry in days |
server_id | (unset) | Unique replication server ID; also enables binary logging when set |
innodb.* pillar keys
innodb.* pillar keys
| Key | Default | Description |
|---|---|---|
innodb.buffer_pool_size | 1G | InnoDB buffer pool — set to ~80 % of available RAM |
innodb.log_file_size | 256M | InnoDB redo log file size |
innodb.flush_log_at_trx_commit | 1 | 1 = fully ACID; 2 = flush once per second (faster, slight risk) |
innodb.file_per_table | true | Each table gets its own .ibd file |
innodb.open_files | 1000 | Maximum open .ibd file descriptors |
When
server_id is set in the pillar, the config template automatically enables binary logging at /var/log/mysql/mysql-bin.log with binlog_format = ROW and a 100 MB per-file cap. Omitting server_id leaves binary logging commented out.Server configuration template
Pillar examples
- db-c1-us-east-021 (primary C1, 20 GB pool)
- db-pc-us-east-011 (PC cluster, 8 GB pool)
- Default pillar (init.sls)
Backup sub-state (mariadb.backup)
The mariadb.backup sub-state is conditionally applied — all resources are skipped unless the pillar key mariadb:backup:destination:host is set. When enabled it installs the backup toolchain, creates a dedicated DB user, schedules cron jobs, and runs a persistent systemd service for real-time binlog streaming.
Full backup
Weekly on Sunday at 01:00 using
mariadb-backup-run.sh full. Streams an xbstream archive directly to the remote host over SSH — no local disk usage.Incremental backup
Mon–Sat at 02:00 using
mariadb-backup-run.sh incremental. Uses the LSN checkpoints from the previous run; falls back to a full backup if checkpoints are missing or stale (> 7 days).Binlog streaming
mariadb-binlog-stream.service runs mariadb-binlog with --stop-never to continuously stream binary logs to /var/backups/mariadb/binlogs/. Runs as a systemd service with Restart=always.Binlog sync
Every 5 minutes via cron,
mariadb-binlog-sync.sh rsyncs the local binlog directory to the remote backup server over SSH.Installed files
| Path | Purpose |
|---|---|
/usr/local/bin/mariadb-backup-run.sh | Full / incremental backup runner |
/usr/local/bin/mariadb-binlog-stream.sh | Continuous binlog streaming daemon |
/usr/local/bin/mariadb-binlog-sync.sh | Rsync binlogs to remote |
/etc/mariadb-backup/ssh_key | SSH private key (from pillar, mode 0600) |
/var/backups/mariadb/ | Local state files: LSN checkpoints, last backup timestamps |
/var/backups/mariadb/binlogs/ | Locally streamed binlog files |
Backup user grants
Themariabackup_db_user state creates and maintains the mariadb_backup@localhost user with the minimum grants required:
Backup pillar keys
Notification webhooks
The backup runner sends Discord and/or Slack notifications on completion or failure. Configure via thenotifications pillar:
Cron schedule
Monitoring sub-states
mariadb.monitoring_user
Creates the icinga_monitor@'%' user used by Icinga/NRPE health checks. The password is read from monitoring:monitoring_db_password in the pillar. The user is granted only USAGE (no data access).
mariadb.prometheus_user
Creates the prom_exporter@'127.0.0.1' user for the mysqld_exporter Prometheus agent. Password is read from monitoring:mysqld_exporter_password. Grants allow the exporter to read process list, replication status, and performance schema metrics.
mariadb.nrpe_backup
Installs an NRPE plugin and configuration to monitor backup freshness:
| Path | Description |
|---|---|
/usr/lib/nagios/plugins/check_mariadb_backup.sh | Custom check script (mode 0755) |
/etc/nagios/nrpe.d/mariadb_backup.cfg | NRPE command definition; triggers nagios-nrpe-server reload on change |