Configuration
Declare the cluster in inventory. mysql.yml adjusts live state to match. This page covers topology and configuration blocks. See Parameters for the full reference.
Before You Deploy
- Manage nodes with
NODE. Install the shared CA at/etc/pki/ca.crtthroughnode_ca. MYSQL issues leaf certificates only. - Include
mysqlin repositories withnode_repo_modules: node,infra,mysql, or cache packages locally withrepo_extra_packages: [mysql]. - Use supported platforms:
x86_64EL 8/9/10, Debian 12/13, Ubuntu 22/24; oraarch64EL 9/10. - Set production
mysql_root_password,mysql_monitor_password, andmysql_cluster_password. Preflight rejectsCHANGE_MEplaceholders.
Identity
Each cluster is an inventory group with two required identity parameters:
| Parameter | Level | Description |
|---|---|---|
mysql_cluster | Cluster | Cluster name; must match the inventory group holding the members. Also the backup directory and the cls monitoring label |
mysql_seq | Instance | 1 for standalone; sequential 1..3 for HA; doubles as server_id |
One member selects standalone; three select InnoDB Cluster. Preflight rejects other counts. mysql_seq=1 coordinates bootstrap only; it does not set runtime PRIMARY.
Instances use {{ mysql_cluster }}-{{ mysql_seq }}, such as my-test-1. Inventory IP or resolvable hostname becomes the advertised MySQL/MGR address. Ordinary reruns cannot change it.
Standalone Instance
The minimal standalone declaration:
Standalone has no Router or 6446/6447 endpoints. Connect to 3306. TLS, monitoring, and backups otherwise behave as in HA.
Three-Node InnoDB Cluster
This creates one writable PRIMARY and two read-only SECONDARY members. It tolerates one node failure. Every member runs Router; any 6446 reaches the current primary.
Every mysql.yml run must select all members with -l, or omit it to select all MySQL clusters.
Preflight rejects partial selection to prevent topology divergence.
Databases
mysql_databases declares databases additively:
| Field | Default | Description |
|---|---|---|
name | required | Database name, [A-Za-z0-9_$-]; system schema names are rejected |
encoding | utf8mb4 | Character set |
collate | utf8mb4_0900_ai_ci | Collation |
Each entry accepts only these three fields; preflight validation rejects additional keys.
Convergence is additive. Reruns create missing databases. Removing an entry never drops a database; deletion is manual.
Default sql_require_primary_key=ON rejects tables without primary keys with ERROR 3750. Such tables become read-only under MGR and block AdminAPI disaster recovery.
Give every table a primary key, including an invisible-column key if needed. Override through mysql_parameters only if necessary.
Users
mysql_users declares users and grants additively:
Use 'db.table' grant scopes. Either part can be *, as in '*.*' and 'app.*'. Values are comma-separated privileges. Preflight rejects malformed users, hosts, scopes, or privilege names.
Semantics:
- Create missing users. Update existing passwords and connection limits.
- Apply
privgrants. Removing mappings does not REVOKE privileges. - Do not declare platform identities:
root,dbuser_monitor,dbuser_cluster, ordbuser_backup. - The server requires TLS.
PREFERREDnegotiates encryption;DISABLEDplaintext connections fail. Prefer explicitVERIFY_CA.
Parameter Overrides
mysql_parameters appends [mysqld] overrides at the end of managed configuration. The last value takes precedence:
Rules and safety:
- Start option names with a letter;
._-characters are permitted. Values must be single-line scalars. mysqld --validate-configchecks the rendered result. Invalid options stop deployment without changing the running service.- Reserved settings cannot be overridden. These include identity/protocol (
user,pid_file,server_id,datadir,socket,port,bind_address,mysqlx_bind_address,report_host,mysqlx, …). They also include replication/plugins (gtid_mode,enforce_gtid_consistency,log_bin,relay_log,plugin_load*,clone,plugin_clone,plugin_mysqlx,group_replication_*, …) and TLS (require_secure_transport,ssl_*). The role owns and rejects overrides for these keys. - Changes trigger rolling restarts: secondaries first, primary last.
Default buffer pool is 25% of node memory, at least 256MB. Redo capacity is half that size, limited to 128MB–4GB. Replica parallelism follows CPU count. Override innodb_buffer_pool_size and other keys through mysql_parameters when needed.
Backup Settings
The backup contract (details in Administration):
- Run a daily full physical XtraBackup backup and prepare it immediately. The result is directly restorable.
- Standalone backs up locally. Every HA timer runs, but only the current PRIMARY performs backup. Others skip.
- Use
<path>/<cluster>/<UTC timestamp>/, atomiclatestsymlinks, and retention-based pruning. - No incremental chains, binlog archiving, or PITR. Standalone recovery reaches the most recent backup.
After failover, backups use the new primary’s local disk. Compare latest timestamps on all members and select the newest.
For off-site protection, synchronize backups yourself, for example with scheduled rclone or rsync.
Platform Credentials
Credential lifecycle rules:
- Passwords must be single-line and cannot retain a
CHANGE_MEprefix. Preflight enforces this. - Ordinary HA reruns cannot rotate
mysql_cluster_password. Metadata and Router keyrings bind it, so implicit rotation fails. Standalone rotation works normally. mysql_root_passwordcannot reset silently. If the live value differs, the task fails instead of replacing it.
Root owns /etc/mysql/pigsty/, with directory mode 0700 and file mode 0600. It contains secrets and ready-to-use local client configuration:
Full Example
Standalone plus three-node HA, matching the four-node sandbox:
Use conf/demo/mysql.yml for the full template. conf/mysql.yml belongs to OpenHalo, a MySQL-compatible PostgreSQL kernel, and is unrelated to this module.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)