MySQL Variables and Parameters
This article summarizes the variables that are most frequently changed and most likely to affect results in the public mysql_ansible entry playbooks, so you can quickly locate the right configuration entry before deployment, backup, restore, and monitoring integration.
1. General variables
File: playbooks/common_config.yml
| Variable | Default value | Function |
|---|---|---|
mysql_version | 8.4.8 | MySQL version. Current public capabilities mainly target 5.7, 8.0, and 8.4 |
mysql_port | 3306 | Instance port and the baseline for several derived paths and service names |
server_specs | auto | Server sizing. You can keep auto-detection or set a fixed value such as 4c8g |
db_type | mysql | Database type. Supports mysql, percona, and greatsql |
mysql_packages_dir | ../downloads/ | Directory for MySQL installation packages |
mysql_user / mysql_group | mysql / mysql | Linux runtime user and group for MySQL |
mysql_data_dir_base | /database/{{ db_type }} | Base directory for MySQL data, logs, and configuration |
mysql_service_name | mysql{{ mysql_port }} | systemd service name, derived from the MySQL port by default |
mysql_admin_user / mysql_admin_password | admin / Dbbot_admin@8888 | Administrative account and password |
mysql_rple_user / mysql_rple_password | repl / Dbbot_repl@8888 | Replication account and password |
mysql_backup_user / mysql_backup_password | backup / Dbbot_backup@8888 | Backup account and password |
mysql_monitor_user / mysql_monitor_password | monitor / Dbbot_monitor@8888 | Monitoring account used by mysqld_exporter |
mysql_cluster_admin_user / mysql_cluster_admin_password | clusteradmin / Dbbot_clusteradmin@8888 | mysqlshell management account for InnoDB Cluster |
mysql_router_user / mysql_router_password | mysqlrouter / Dbbot_mysqlrouter@8888 | Account used by MySQL Router to read metadata |
mysql_character_set_server | utf8mb4 | Server character set |
mysql_transaction_isolation | READ-COMMITTED | Default transaction isolation level |
mysql_default_time_zone | +8:00 | Default MySQL time zone |
mysql_max_connections | 1000 | Maximum number of connections |
mysql_binlog_format | row | Binlog format. This is especially important for MGR and InnoDB Cluster |
fcs_auto_download_packages | true | Whether the control node automatically downloads MySQL, Shell, Router, and Exporter packages |
fcs_allow_dbbot_default_passwd | false | Whether execution is allowed to continue with dbbot public default passwords |
fcs_create_mysql_fast_login | true | Whether to create shortcuts such as db3306 for the mysql user |
fcs_backup_script_create_backup_user | true | Whether the backup playbook creates the backup account automatically |
fcs_role_mysqld_exporter_create_monitor_user | true | Whether mysqld_exporter installation creates the monitor account automatically |
fcs_mysql_use_jemalloc | false | Whether to explicitly enable jemalloc preload |
fcs_mysql_allow_bundled_jemalloc_fallback | false | Whether dbbot is allowed to fall back to the bundled legacy RPM when the OS repo has no jemalloc |
fcs_use_greatsql_ha | true | Whether GreatSQL HA related capabilities are enabled |
dbbot_confirmation_input | "" | In automation you can set this to confirm; for manual runs, keeping it empty is safer |
Notes:
- Public default passwords follow the
Dbbot_<user>@8888/Dbbot_<linux_user>@9999convention. By default,fcs_allow_dbbot_default_passwd: false, so playbooks block those defaults inpre_tasks. - The current default for
fcs_mysql_use_jemallocisfalse, which means the system allocator remains the default behavior. - When
fcs_mysql_use_jemalloc: true, dbbot first tries the OS repository package. It only falls back to the bundled legacy RPM if you explicitly setfcs_mysql_allow_bundled_jemalloc_fallback: true. mysql_binlog_formatis configurable in the common file, butmgr.ymlstill requiresrow.
2. Directory and package variables
File: playbooks/advanced_config.yml
| Variable | Default value | Function |
|---|---|---|
mycnf_dir | {{ mysql_data_dir_base }}/{{ mysql_port }}/etc | Directory that stores my.cnf |
datadir | {{ mysql_data_dir_base }}/{{ mysql_port }}/data | Data directory |
tmpdir | {{ mysql_data_dir_base }}/{{ mysql_port }}/tmp | Temporary directory |
binlog_dir / relaylog_dir | {{ mysql_data_dir_base }}/{{ mysql_port }}/log | Directories for binlog and relay log files |
redolog_dir | {{ datadir }} | Redo log directory, which defaults back to datadir |
socket / mysqlx_socket | Derived from datadir | MySQL and MySQL X socket paths |
mysql_linux_glibc_tag | Auto-calculated by version and OS | glibc tag used in the MySQL package name |
mysql_linux_archive_suffix | Auto-calculated by version and OS | Archive suffix used in the MySQL package name |
mysql_package | Derived from the variables above | Final MySQL package file name expected by the playbook |
Recommendations:
- Only change these variables when you need a custom directory layout, custom offline package naming, or a special restore path.
- The cleanup scope of
unsafe_uninstall.ymlalso depends on these directory variables. With the current default layout, it removes both the instance data and log directories.
3. Primary-replica and MHA variables
Files:
playbooks/vars/var_master_slave.ymlplaybooks/vars/var_mha.yml
| Variable | Default value | Function |
|---|---|---|
master_ip | 192.0.2.131 | Primary server IP |
slave_ips | ['192.0.2.132', '192.0.2.133'] | Replica IP list |
sub_nets | 1% | Trusted subnet, domain, or IP range for MySQL |
manager_ip | 192.0.2.133 | Node used by the MHA manager |
net_work_interface | ens33 | NIC used to bind the MHA VIP |
vip | 192.0.2.130 | MHA VIP |
vip_netmask | 32 | MHA VIP netmask |
Notes:
master_ipandslave_ipsmust match the hosts in the inventory.manager_ipmust not be the same asmaster_ip; it is usually placed on a replica node.- The actual variable name is
slave_ips, notreplica_ips.
4. MGR variables
File: playbooks/vars/var_mgr.yml
| Variable | Default value | Function |
|---|---|---|
mysql_binlog_format | row | Overrides the common setting so MGR uses row |
mysql_mgr_port | Auto-calculated, for example 33061 when mysql_port=3306 | Group Replication communication port |
mysql_mgr_hosts | ['192.0.2.131', '192.0.2.132', '192.0.2.133'] | List of MGR members |
sub_nets | 1% | Trusted source range |
greatsql_vip | 192.0.2.134 | VIP for GreatSQL HA scenarios |
greatsql_net_work_interface | ens33 | NIC used by the GreatSQL HA VIP |
greatsql_netmask | 255.255.255.255 | Netmask used by GreatSQL HA |
greatsql_group_replication_arbitrator | false | Whether to enable an arbitrator node |
greatsql_group_replication_arbitrator_hosts | ['192.0.2.133'] | Arbitrator node list |
Notes:
greatsql_*variables only apply whendb_type: greatsql.mgr.ymldeploys single-primary mode by default.
5. InnoDB Cluster and Router variables
Files:
playbooks/vars/var_innodb_cluster.ymlplaybooks/vars/var_innodb_cluster_router.yml
InnoDB Cluster variables:
| Variable | Default value | Function |
|---|---|---|
innodb_cluster_name | myCluster{{ mysql_port }} | Cluster name |
innodb_cluster_primary | 192.0.2.131 | Initial primary node |
innodb_cluster_members | ['192.0.2.131', '192.0.2.132', '192.0.2.133'] | Cluster member list |
mysql_mgr_port | Auto-calculated, for example 33061 when mysql_port=3306 | InnoDB Cluster still relies on the underlying MGR port |
mysql_mgr_hosts | {{ innodb_cluster_members }} | Underlying MGR member list |
mysql_cluster_admin_user / mysql_cluster_admin_password | clusteradmin / Dbbot_clusteradmin@8888 | mysqlshell management account |
Router variables:
| Variable | Default value | Function |
|---|---|---|
router_enable_ha | true | Whether Router HA is enabled with keepalived |
router_bootstrap_server | 192.0.2.131 | Cluster node used for Router bootstrap |
router_vip | 198.51.100.150 | Router HA VIP |
router_net_work_interface | ens33 | NIC used by the VIP |
router_ha_nodes | Two-node example | Router HA nodes, roles, and priorities |
router_vip_netmask | 32 | Router VIP netmask |
router_ports | rw/ro/http... dictionary | Router ports, enable flags, and health-check participation |
max_total_connections | 1000 | Global Router connection limit |
router_rest_api_bind_address | 127.0.0.1 | REST API bind address |
router_rest_api_auth_mode | file | REST API authentication mode |
router_rest_api_file_user / router_rest_api_file_password | router_api_user / Dbbot_router_api_user@8888 | File-based REST API credentials |
Notes:
router_ha_nodesonly matters whenrouter_enable_ha: true.- By default,
router_ports.http.portis8443, andmysqlrouter_exporterreads Router metrics from this REST API endpoint.
6. Exporter variables
Files:
playbooks/vars/var_exporter_install.ymlplaybooks/vars/var_router_exporter_install.yml
| Variable | Default value | Function |
|---|---|---|
node_exporter_install | true | Whether to install node_exporter |
node_exporter_port | 9100 | Listening port for node_exporter |
node_exporter_install_type | dbbot | Installation mode: dbbot, pmm, or package |
mysqld_exporter_install | true | Whether to install mysqld_exporter |
mysqld_exporter_topology | ms | Topology type: ms or mgr |
mysqld_exporter_port | auto | Exporter port. Can be auto-calculated or explicitly set |
mysqld_exporter_port_auto_base | 9104 | Start of the auto-generated exporter port range |
mysqld_exporter_port_auto_mysql_base | 3306 | MySQL baseline port used in the auto port calculation |
mysqld_exporter_install_type | dbbot | Installation mode: dbbot, pmm, or package |
mysqlrouter_exporter_install | true | Whether to install mysqlrouter_exporter |
mysqlrouter_exporter_port | 9165 | Listening port for mysqlrouter_exporter |
mysqlrouter_exporter_api_base_url | https://127.0.0.1:8443/api/20190715 | Router REST API endpoint |
mysqlrouter_exporter_api_user / mysqlrouter_exporter_api_password | router_api_user / Dbbot_router_api_user@8888 | Router API credentials |
mysqlrouter_exporter_insecure_skip_verify | true | Whether to skip HTTPS certificate verification |
Auto port rule:
- When
mysqld_exporter_port: auto, the port is calculated as9104 + mysql_port - 3306. mysqlrouter_exporterdepends on the Router REST API by default, so if you change the Router HTTP port or bind address, update the exporter settings as well.
7. MySQL 8.4 clone backup variables
File: playbooks/vars/var_backup_script_8.4.yml
| Variable | Default value | Function |
|---|---|---|
backup_topology | auto | Topology detection mode. Supports auto, ms, mgr, mic, and single |
backup_scope | primary_only | Backup target scope. Supports primary_only, replica_one, replica_all, all, and selected |
backup_preferred_host | "" | Required when backup_scope=selected |
backup_base_dir | /backup | Base backup directory |
backup_script_dir | {{ mysql_data_dir_base }}/scripts | Directory that stores backup scripts |
backup_script_path | {{ backup_script_dir }}/backup_clone{{ mysql_port }}.sh | Clone backup script path |
backup_schedule_script_path | {{ backup_script_dir }}/backup_schedule{{ mysql_port }}.sh | Scheduler script path |
backup_purge_script_path | {{ backup_script_dir }}/backup_purge{{ mysql_port }}.sh | Purge script path |
backup_config_path | {{ backup_script_dir }}/backup_clone{{ mysql_port }}.conf | Backup configuration file path |
backup_keep_full | 2 | Number of full snapshots to retain |
backup_keep_binlog_days | 7 | Number of days to retain binlogs |
backup_cron | 0 2 * * * | Cron expression used by the scheduled backup |
Notes:
- When
backup_scope=selected,backup_preferred_hostmust be set explicitly. backup_cronis validated as a five-field cron expression inpre_tasks.
8. MySQL 8.4 PITR restore variables
File: playbooks/vars/var_restore_pitr_8.4.yml
| Variable | Default value | Function |
|---|---|---|
restore_mode | new_instance | Restore mode: new_instance or existing_instance |
backup_snapshot_id | "" | Backup snapshot identifier. Required |
backup_source_mysql_port | 3306 | Source MySQL port used by the backup |
restore_target_mysql_port | 3388 | Target MySQL port for the restored instance |
backup_root_dir | /backup | Base backup directory on the restore host |
backup_dir | {{ backup_root_dir }}/mysql{{ backup_source_mysql_port }}/{{ backup_snapshot_id }} | Resolved backup directory |
enable_pitr | true | Whether to apply binlogs after the clone restore |
pitr_target_time | "" | Stop point based on wall-clock time, format YYYY-MM-DD HH:MM:SS |
pitr_target_gtid | "" | Stop point based on a single GTID, format uuid:seq |
pitr_target_gtid_inclusive | false | Whether the target GTID itself is included |
restore_mysql_host / restore_mysql_user / restore_mysql_password | 127.0.0.1 / {{ mysql_admin_user }} / {{ mysql_admin_127_password }} | Connection settings used when replaying binlogs |
restore_allow_nonempty_datadir | false | Whether restore is allowed when the target datadir already contains data |
restore_mysql_start_timeout | 300 | Timeout in seconds when waiting for MySQL to start |
mysql_port | {{ restore_target_mysql_port }} | Keeps the restore flow aligned with the target MySQL port |
Restore constraints:
- When
enable_pitr: true, set exactly one ofpitr_target_timeorpitr_target_gtid. restore_pitr_8.4.ymlonly supportsdb_type: mysqlandmysql_version: 8.4.x.
9. Notes for the 5.7 backup script and uninstall
backup_script.yml and unsafe_uninstall.yml do not have dedicated vars/*.yml files. They mainly depend on the following configuration sources:
- The MySQL 5.7 backup script relies on
common_config.ymlandadvanced_config.yml - Whether the backup user is created automatically is controlled by
fcs_backup_script_create_backup_user - The delete scope of
unsafe_uninstall.ymlfollowsdatadir,tmpdir,binlog_dir,relaylog_dir, andredolog_dirfromadvanced_config.yml
Additional notes:
backup_script.ymlis currently for MySQL5.7, and its retention behavior is mainly defined inside the role template rather than a public variable file.unsafe_uninstall.ymlkeeps the software base directory, Linux user, andmy.cnf, but its delete scope still followsadvanced_config.yml. With the current default layout, it removes both the instance data and log directories. It still requires manual confirmation before execution.