MySQL Custom Directory Layout

dbbot supports customizing the MySQL directory structure through advanced_config.yml.

1. Directory configuration entry

File path:

/usr/local/dbbot/mysql_ansible/playbooks/advanced_config.yml

Examples of typical directory parameters:

mycnf_dir: "{{ mysql_data_dir_base }}/{{ mysql_port }}/etc"
datadir: "{{ mysql_data_dir_base }}/{{ mysql_port }}/data"
tmpdir: "{{ mysql_data_dir_base }}/{{ mysql_port }}/tmp"
binlog_dir: "{{ mysql_data_dir_base }}/{{ mysql_port }}/log"
relaylog_dir: "{{ mysql_data_dir_base }}/{{ mysql_port }}/log"
redolog_dir: "{{ datadir }}"
socket_dir: "{{ datadir }}"
mysqlx_socket_dir: "{{ datadir }}"
slowlog_dir: "{{ mysql_data_dir_base }}/{{ mysql_port }}/log"
errlog_dir: "{{ mysql_data_dir_base }}/{{ mysql_port }}/log"

2. Modify the log file name

If you want to modify the log file name (not just the directory), you need to change the template file:

/usr/local/dbbot/mysql_ansible/roles/mysql_server/templates/8.4/my.cnf.j2

Example:

slow_query_log_file = {{ slowlog_dir }}/slow.log

Can be changed to: slow_query.log.

3. Design description

  • The directory needs to be created by dbbot and handle permissions.
  • Physical files are usually created by MySQL itself when it is initialized.
  • The default layout groups the common paths for each instance under {{ mysql_data_dir_base }}/{{ mysql_port }}/..., which makes per-instance inspection and cleanup clearer.
  • It is recommended to verify it in a test environment before using it in production.