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

VariableDefault valueFunction
mysql_version8.4.8MySQL version. Current public capabilities mainly target 5.7, 8.0, and 8.4
mysql_port3306Instance port and the baseline for several derived paths and service names
server_specsautoServer sizing. You can keep auto-detection or set a fixed value such as 4c8g
db_typemysqlDatabase type. Supports mysql, percona, and greatsql
mysql_packages_dir../downloads/Directory for MySQL installation packages
mysql_user / mysql_groupmysql / mysqlLinux runtime user and group for MySQL
mysql_data_dir_base/database/{{ db_type }}Base directory for MySQL data, logs, and configuration
mysql_service_namemysql{{ mysql_port }}systemd service name, derived from the MySQL port by default
mysql_admin_user / mysql_admin_passwordadmin / Dbbot_admin@8888Administrative account and password
mysql_rple_user / mysql_rple_passwordrepl / Dbbot_repl@8888Replication account and password
mysql_backup_user / mysql_backup_passwordbackup / Dbbot_backup@8888Backup account and password
mysql_monitor_user / mysql_monitor_passwordmonitor / Dbbot_monitor@8888Monitoring account used by mysqld_exporter
mysql_cluster_admin_user / mysql_cluster_admin_passwordclusteradmin / Dbbot_clusteradmin@8888mysqlshell management account for InnoDB Cluster
mysql_router_user / mysql_router_passwordmysqlrouter / Dbbot_mysqlrouter@8888Account used by MySQL Router to read metadata
mysql_character_set_serverutf8mb4Server character set
mysql_transaction_isolationREAD-COMMITTEDDefault transaction isolation level
mysql_default_time_zone+8:00Default MySQL time zone
mysql_max_connections1000Maximum number of connections
mysql_binlog_formatrowBinlog format. This is especially important for MGR and InnoDB Cluster
fcs_auto_download_packagestrueWhether the control node automatically downloads MySQL, Shell, Router, and Exporter packages
fcs_allow_dbbot_default_passwdfalseWhether execution is allowed to continue with dbbot public default passwords
fcs_create_mysql_fast_logintrueWhether to create shortcuts such as db3306 for the mysql user
fcs_backup_script_create_backup_usertrueWhether the backup playbook creates the backup account automatically
fcs_role_mysqld_exporter_create_monitor_usertrueWhether mysqld_exporter installation creates the monitor account automatically
fcs_mysql_use_jemallocfalseWhether to explicitly enable jemalloc preload
fcs_mysql_allow_bundled_jemalloc_fallbackfalseWhether dbbot is allowed to fall back to the bundled legacy RPM when the OS repo has no jemalloc
fcs_use_greatsql_hatrueWhether 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>@9999 convention. By default, fcs_allow_dbbot_default_passwd: false, so playbooks block those defaults in pre_tasks.
  • The current default for fcs_mysql_use_jemalloc is false, 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 set fcs_mysql_allow_bundled_jemalloc_fallback: true.
  • mysql_binlog_format is configurable in the common file, but mgr.yml still requires row.

2. Directory and package variables

File: playbooks/advanced_config.yml

VariableDefault valueFunction
mycnf_dir{{ mysql_data_dir_base }}/{{ mysql_port }}/etcDirectory that stores my.cnf
datadir{{ mysql_data_dir_base }}/{{ mysql_port }}/dataData directory
tmpdir{{ mysql_data_dir_base }}/{{ mysql_port }}/tmpTemporary directory
binlog_dir / relaylog_dir{{ mysql_data_dir_base }}/{{ mysql_port }}/logDirectories for binlog and relay log files
redolog_dir{{ datadir }}Redo log directory, which defaults back to datadir
socket / mysqlx_socketDerived from datadirMySQL and MySQL X socket paths
mysql_linux_glibc_tagAuto-calculated by version and OSglibc tag used in the MySQL package name
mysql_linux_archive_suffixAuto-calculated by version and OSArchive suffix used in the MySQL package name
mysql_packageDerived from the variables aboveFinal 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.yml also 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.yml
  • playbooks/vars/var_mha.yml
VariableDefault valueFunction
master_ip192.0.2.131Primary server IP
slave_ips['192.0.2.132', '192.0.2.133']Replica IP list
sub_nets1%Trusted subnet, domain, or IP range for MySQL
manager_ip192.0.2.133Node used by the MHA manager
net_work_interfaceens33NIC used to bind the MHA VIP
vip192.0.2.130MHA VIP
vip_netmask32MHA VIP netmask

Notes:

  • master_ip and slave_ips must match the hosts in the inventory.
  • manager_ip must not be the same as master_ip; it is usually placed on a replica node.
  • The actual variable name is slave_ips, not replica_ips.

4. MGR variables

File: playbooks/vars/var_mgr.yml

VariableDefault valueFunction
mysql_binlog_formatrowOverrides the common setting so MGR uses row
mysql_mgr_portAuto-calculated, for example 33061 when mysql_port=3306Group Replication communication port
mysql_mgr_hosts['192.0.2.131', '192.0.2.132', '192.0.2.133']List of MGR members
sub_nets1%Trusted source range
greatsql_vip192.0.2.134VIP for GreatSQL HA scenarios
greatsql_net_work_interfaceens33NIC used by the GreatSQL HA VIP
greatsql_netmask255.255.255.255Netmask used by GreatSQL HA
greatsql_group_replication_arbitratorfalseWhether to enable an arbitrator node
greatsql_group_replication_arbitrator_hosts['192.0.2.133']Arbitrator node list

Notes:

  • greatsql_* variables only apply when db_type: greatsql.
  • mgr.yml deploys single-primary mode by default.

5. InnoDB Cluster and Router variables

Files:

  • playbooks/vars/var_innodb_cluster.yml
  • playbooks/vars/var_innodb_cluster_router.yml

InnoDB Cluster variables:

VariableDefault valueFunction
innodb_cluster_namemyCluster{{ mysql_port }}Cluster name
innodb_cluster_primary192.0.2.131Initial primary node
innodb_cluster_members['192.0.2.131', '192.0.2.132', '192.0.2.133']Cluster member list
mysql_mgr_portAuto-calculated, for example 33061 when mysql_port=3306InnoDB 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_passwordclusteradmin / Dbbot_clusteradmin@8888mysqlshell management account

Router variables:

VariableDefault valueFunction
router_enable_hatrueWhether Router HA is enabled with keepalived
router_bootstrap_server192.0.2.131Cluster node used for Router bootstrap
router_vip198.51.100.150Router HA VIP
router_net_work_interfaceens33NIC used by the VIP
router_ha_nodesTwo-node exampleRouter HA nodes, roles, and priorities
router_vip_netmask32Router VIP netmask
router_portsrw/ro/http... dictionaryRouter ports, enable flags, and health-check participation
max_total_connections1000Global Router connection limit
router_rest_api_bind_address127.0.0.1REST API bind address
router_rest_api_auth_modefileREST API authentication mode
router_rest_api_file_user / router_rest_api_file_passwordrouter_api_user / Dbbot_router_api_user@8888File-based REST API credentials

Notes:

  • router_ha_nodes only matters when router_enable_ha: true.
  • By default, router_ports.http.port is 8443, and mysqlrouter_exporter reads Router metrics from this REST API endpoint.

6. Exporter variables

Files:

  • playbooks/vars/var_exporter_install.yml
  • playbooks/vars/var_router_exporter_install.yml
VariableDefault valueFunction
node_exporter_installtrueWhether to install node_exporter
node_exporter_port9100Listening port for node_exporter
node_exporter_install_typedbbotInstallation mode: dbbot, pmm, or package
mysqld_exporter_installtrueWhether to install mysqld_exporter
mysqld_exporter_topologymsTopology type: ms or mgr
mysqld_exporter_portautoExporter port. Can be auto-calculated or explicitly set
mysqld_exporter_port_auto_base9104Start of the auto-generated exporter port range
mysqld_exporter_port_auto_mysql_base3306MySQL baseline port used in the auto port calculation
mysqld_exporter_install_typedbbotInstallation mode: dbbot, pmm, or package
mysqlrouter_exporter_installtrueWhether to install mysqlrouter_exporter
mysqlrouter_exporter_port9165Listening port for mysqlrouter_exporter
mysqlrouter_exporter_api_base_urlhttps://127.0.0.1:8443/api/20190715Router REST API endpoint
mysqlrouter_exporter_api_user / mysqlrouter_exporter_api_passwordrouter_api_user / Dbbot_router_api_user@8888Router API credentials
mysqlrouter_exporter_insecure_skip_verifytrueWhether to skip HTTPS certificate verification

Auto port rule:

  • When mysqld_exporter_port: auto, the port is calculated as 9104 + mysql_port - 3306.
  • mysqlrouter_exporter depends 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

VariableDefault valueFunction
backup_topologyautoTopology detection mode. Supports auto, ms, mgr, mic, and single
backup_scopeprimary_onlyBackup target scope. Supports primary_only, replica_one, replica_all, all, and selected
backup_preferred_host""Required when backup_scope=selected
backup_base_dir/backupBase backup directory
backup_script_dir{{ mysql_data_dir_base }}/scriptsDirectory that stores backup scripts
backup_script_path{{ backup_script_dir }}/backup_clone{{ mysql_port }}.shClone backup script path
backup_schedule_script_path{{ backup_script_dir }}/backup_schedule{{ mysql_port }}.shScheduler script path
backup_purge_script_path{{ backup_script_dir }}/backup_purge{{ mysql_port }}.shPurge script path
backup_config_path{{ backup_script_dir }}/backup_clone{{ mysql_port }}.confBackup configuration file path
backup_keep_full2Number of full snapshots to retain
backup_keep_binlog_days7Number of days to retain binlogs
backup_cron0 2 * * *Cron expression used by the scheduled backup

Notes:

  • When backup_scope=selected, backup_preferred_host must be set explicitly.
  • backup_cron is validated as a five-field cron expression in pre_tasks.

8. MySQL 8.4 PITR restore variables

File: playbooks/vars/var_restore_pitr_8.4.yml

VariableDefault valueFunction
restore_modenew_instanceRestore mode: new_instance or existing_instance
backup_snapshot_id""Backup snapshot identifier. Required
backup_source_mysql_port3306Source MySQL port used by the backup
restore_target_mysql_port3388Target MySQL port for the restored instance
backup_root_dir/backupBase backup directory on the restore host
backup_dir{{ backup_root_dir }}/mysql{{ backup_source_mysql_port }}/{{ backup_snapshot_id }}Resolved backup directory
enable_pitrtrueWhether 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_inclusivefalseWhether the target GTID itself is included
restore_mysql_host / restore_mysql_user / restore_mysql_password127.0.0.1 / {{ mysql_admin_user }} / {{ mysql_admin_127_password }}Connection settings used when replaying binlogs
restore_allow_nonempty_datadirfalseWhether restore is allowed when the target datadir already contains data
restore_mysql_start_timeout300Timeout 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:

  1. When enable_pitr: true, set exactly one of pitr_target_time or pitr_target_gtid.
  2. restore_pitr_8.4.yml only supports db_type: mysql and mysql_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.yml and advanced_config.yml
  • Whether the backup user is created automatically is controlled by fcs_backup_script_create_backup_user
  • The delete scope of unsafe_uninstall.yml follows datadir, tmpdir, binlog_dir, relaylog_dir, and redolog_dir from advanced_config.yml

Additional notes:

  • backup_script.yml is currently for MySQL 5.7, and its retention behavior is mainly defined inside the role template rather than a public variable file.
  • unsafe_uninstall.yml keeps the software base directory, Linux user, and my.cnf, but its delete scope still follows advanced_config.yml. With the current default layout, it removes both the instance data and log directories. It still requires manual confirmation before execution.
  1. MySQL Primary-Replica Deployment Quick Start
  2. MySQL Custom Directory Layout
  3. MySQL 8.4 Backup and Restore
  4. MySQL InnoDB Cluster Deployment Guide
  5. MySQL MHA Deployment Guide