Module: MYSQL
MySQL is a widely used open-source relational database. Pigsty’s MYSQL module installs a fixed native MySQL 8.4 LTS platform on managed nodes. Choose a standalone instance or three-node single-primary InnoDB Cluster with Group Replication. The module manages TLS, backups, monitoring, and lifecycle.
MYSQL is a supplementary pilot module for a simple, low-cost MySQL cluster. Its scope is smaller than PGSQL. Core capabilities have been systematically tested: deployment convergence, HA failover, recovery after a complete three-node outage, replacement at the same address, daily backups, and monitoring/alerts. Destructive procedures such as physical backup copy-back remain manual operations. See the runbooks under Administration.
Module Capabilities
The MYSQL module currently provides:
- Fixed native MySQL 8.4 LTS server, client, Shell, Router, and matching XtraBackup packages.
- Standalone or three-node single-primary InnoDB Cluster, created and reconciled through MySQL Shell AdminAPI.
- Flexible HA access: MySQL Router on every HA member (RW
6446, RO6447), with optional reuse of theNODELayer 2 VIP (<vip>:6446/6447, automatically added to certificate SANs) - TLS with leaf certificates from the shared Pigsty CA. Non-TLS connections are rejected.
- Additive
mysql_databasesandmysql_usersdeclarations that never delete data implicitly. mysql_parametersoverrides, includingmax_connections, with rolling restarts after configuration changes.- Daily full physical backups: XtraBackup with preparation, an initial baseline backup on first deployment, retention, a concurrency lock, atomic commit, and freshness metrics
- Complete observability:
mysqld_exporterand backup metrics, 70 recording rules, 8 actionable alerts, 5 Grafana dashboards, and error logs in VictoriaLogs - Default
sql_require_primary_key, blocking tables without primary keys that would break MGR replication and recovery. - Convergent operations: rerun
mysql.ymlto recover offline members, a complete three-node outage (all members reachable, selecting the highest GTID), or a replacement machine at the same IP (stale registration cleanup and Clone rebuild), with safeguards for dangerous operations
Module Architecture
NODE supplies node management, repositories, and the shared CA. INFRA supplies VictoriaMetrics, VictoriaLogs, Grafana, and Alertmanager. MYSQL depends on both, but not ETCD or PGSQL.
flowchart LR
admin["Pigsty admin node"] -->|"mysql.yml"| mysqld["mysqld ×3 / single-primary MGR<br>3306 · TLS"]
client["Application clients"] -->|"RW 6446 / RO 6447"| router["MySQL Router<br>(on every HA member)"]
router --> mysqld
mysqld --> backup["XtraBackup daily full<br>(current primary only)"]
mysqld --> exporter["mysqld_exporter :9104"]
mysqld --> journal["Error log → Journald"]
exporter --> vm["VictoriaMetrics"]
journal --> vector["Vector"] --> vl["VictoriaLogs"]
vm --> grafana["Grafana"]
vl --> grafana
vm --> alertmanager["Alertmanager"]
style mysqld fill:#4479A1,stroke:#33618a,color:#fff
style router fill:#70C1B3,stroke:#4f968b,color:#fff
style vm fill:#E66B7A,stroke:#b84e5c,color:#fff
style vl fill:#C98367,stroke:#9e634e,color:#fff
In three-node clusters, mysql_seq=1 coordinates bootstrap only. Runtime PRIMARY is elected. Reruns never force it back to node 1.
Components and Ports
| Component | Purpose | Fixed endpoint |
|---|---|---|
mysqld | Standalone server or MGR member | Classic 3306, X Protocol 33060 |
| Group Replication | Three-member replication and consensus (XCOM) | 33061 |
| MySQL Router | Topology-aware entry point on every HA member | RW 6446, RO 6447 |
| MySQL Shell | AdminAPI cluster lifecycle | Local control plane |
| XtraBackup | Daily full physical backup | Local backup repository |
mysqld_exporter | Server and MGR metrics | 9104 |
The role creates and manages three platform identities:
dbuser_cluster@'%': TLS-only AdminAPI and Router bootstrap identity (created on HA clusters only);dbuser_monitor@'127.0.0.1': least-privilege exporter identity;dbuser_backup@'localhost': local XtraBackup identity.
Supported Platforms
The native-package platform gate admits:
| Arch | Supported systems |
|---|---|
x86_64 | EL 8/9/10, Debian 12/13, Ubuntu 22/24 |
aarch64 | EL 9/10 |
Preflight rejects Debian/Ubuntu ARM64 because Oracle APT has no MySQL 8.4 arm64 packages. On ARM, use EL 9/10, such as Rocky Linux.
Scope and Boundaries
MYSQL provides a fixed platform. Before adoption, accept these scope limits:
- One or three nodes only: No in-place 1→3 or 3→5 expansion and no persistent two-node operation. Use logical migration for capacity changes and same-address replacement for hardware refresh.
- Fixed versions, ports, and character set: these are not exposed as parameters. Data defaults to
/data/mysql, configurable withmysql_data. Memory settings are derived from node resources and PostgreSQL colocation; override key settings withmysql_parameters. - Daily local full backups: no incremental chains, continuous binlog archiving, or PITR. Physical copy-back recovery is manual; see the runbook.
- Automatic complete-outage recovery requires all three members to be reachable: it always uses
force: false. If fewer than three hosts are reachable, repair them or follow Complete Outage Recovery. The role never forces majority recovery automatically. - Local Router with an optional L2 VIP: clients can use any member’s Router, a multi-address DSN, or the
NODELayer 2 VIP (<vip>:6446/6447). No DNS / HAProxy access layer is included.
Documentation
| Page | Content |
|---|---|
| Configuration | Topology, identity, data directory, application databases/users, parameter overrides, and backups |
| Parameters | 16 public parameters (13 deployment + 3 removal) and fixed platform conventions |
| Administration | Status, shortcuts, client access, configuration changes, automatic recovery, and physical restore runbooks |
| Playbook | mysql.yml and mysql-rm.yml usage, tags, and guardrails |
| Monitoring | Dashboards, recording rules, alert rules, log queries |
| Metrics | Label model and the derived-metric dictionary |
| FAQ | Platform limits, primary-key policy, recovery, troubleshooting |
Quick Start
Declare a cluster in the inventory (full template: conf/demo/mysql.yml):
After NODE provisioning, deploy:
Then open the Grafana MySQL Overview dashboard to inspect the cluster.
Plan MySQL topology and identity; declare databases, users, parameter overrides, and backup policy.
The MYSQL module’s 16 public parameters: 13 for deployment, 3 for protected removal, and fixed platform conventions.
MySQL status checks, shortcuts, client access, configuration changes, automatic recovery, member replacement, physical restore, and outage recovery.
Deploy, converge, tune, and retire MySQL clusters with mysql.yml and mysql-rm.yml.
MySQL metric collection, Grafana dashboards, alert rules, and log queries.
Label model, derived-metric dictionary, and raw metric families of the MYSQL module.
Frequently asked questions and troubleshooting for the Pigsty MySQL pilot module.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)