mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-09 19:30:18 +01:00
Fixes #17: Allow configuration of mysql slow query log.
This commit is contained in:
parent
fad419b63e
commit
2d178fe83a
4 changed files with 49 additions and 12 deletions
|
@ -53,10 +53,17 @@ The MySQL users and their privileges. A user has the values `name`, `host` (defa
|
|||
|
||||
Default MySQL connection configuration.
|
||||
|
||||
mysql_log: ""
|
||||
mysql_log_error: /var/log/mysqld.log
|
||||
mysql_syslog_tag: mysqld
|
||||
|
||||
MySQL logging configuration. Setting `mysql_log_error` to `syslog` will make MySQL log to syslog using the `mysql_syslog_tag`.
|
||||
MySQL logging configuration. Setting `mysql_log` (the general query log) or `mysql_log_error` to `syslog` will make MySQL log to syslog using the `mysql_syslog_tag`.
|
||||
|
||||
mysql_slow_query_log_enabled: no
|
||||
mysql_slow_query_log_file: /var/log/mysql-slow.log
|
||||
mysql_slow_query_time: 2
|
||||
|
||||
Slow query log settings. Note that the log file will be created by this role, but if you're running on a server with SELinux or AppArmor, you may need to add this path to the allowed paths for MySQL, or disable the mysql profile. For example, on Debian/Ubuntu, you can run `sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld && sudo service apparmor restart`.
|
||||
|
||||
mysql_key_buffer_size: "256M"
|
||||
mysql_max_allowed_packet: "64M"
|
||||
|
|
|
@ -24,6 +24,11 @@ mysql_port: "3306"
|
|||
mysql_bind_address: '0.0.0.0'
|
||||
mysql_datadir: /var/lib/mysql
|
||||
|
||||
# Slow query log settings.
|
||||
mysql_slow_query_log_enabled: no
|
||||
mysql_slow_query_log_file: /var/log/mysql-slow.log
|
||||
mysql_slow_query_time: 2
|
||||
|
||||
# Memory settings (default values optimized ~512MB RAM).
|
||||
mysql_key_buffer_size: "256M"
|
||||
mysql_max_allowed_packet: "64M"
|
||||
|
@ -56,8 +61,9 @@ mysql_innodb_lock_wait_timeout: 50
|
|||
mysql_mysqldump_max_allowed_packet: "64M"
|
||||
|
||||
# Logging settings.
|
||||
mysql_log_error: /var/log/mysqld.log
|
||||
mysql_syslog_tag: mysqld
|
||||
mysql_log: ""
|
||||
mysql_log_error: /var/log/mysql.err
|
||||
mysql_syslog_tag: mysql
|
||||
|
||||
# Databases.
|
||||
mysql_databases: []
|
||||
|
|
|
@ -9,5 +9,18 @@
|
|||
force: "{{ overwrite_global_mycnf }}"
|
||||
notify: restart mysql
|
||||
|
||||
- name: Create slow query log file (if configured).
|
||||
shell: "touch {{ mysql_slow_query_log_file }} creates={{ mysql_slow_query_log_file }}"
|
||||
when: mysql_slow_query_log_enabled
|
||||
|
||||
- name: Set ownership on slow query log file (if configured).
|
||||
file:
|
||||
path: "{{ mysql_slow_query_log_file }}"
|
||||
state: file
|
||||
owner: mysql
|
||||
group: mysql
|
||||
mode: 0644
|
||||
when: mysql_slow_query_log_enabled
|
||||
|
||||
- name: Ensure MySQL is started and enabled on boot.
|
||||
service: "name={{ mysql_daemon }} state=started enabled={{ mysql_enabled_on_startup }}"
|
||||
|
|
|
@ -9,6 +9,25 @@ bind-address = {{ mysql_bind_address }}
|
|||
datadir = {{ mysql_datadir }}
|
||||
socket = {{ mysql_socket }}
|
||||
|
||||
# Logging configuration.
|
||||
{% if mysql_log_error == 'syslog' or mysql_log == 'syslog' %}
|
||||
syslog
|
||||
syslog-tag = {{ mysql_syslog_tag }}
|
||||
{% else %}
|
||||
{% if mysql_log %}
|
||||
log = {{ mysql_log }}
|
||||
{% endif %}
|
||||
log-error = {{ mysql_log_error }}
|
||||
{% endif %}
|
||||
|
||||
{% if mysql_slow_query_log_enabled %}
|
||||
# Slow query log configuration.
|
||||
log_slow_queries = 1
|
||||
slow_query_log = 1
|
||||
slow_query_log_file = {{ mysql_slow_query_log_file }}
|
||||
long_query_time = {{ mysql_slow_query_time }}
|
||||
{% endif %}
|
||||
|
||||
{% if mysql_replication_master %}
|
||||
# Replication
|
||||
server-id = {{ mysql_server_id }}
|
||||
|
@ -38,7 +57,7 @@ relay-log-index = relay-bin.index
|
|||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
symbolic-links = 0
|
||||
|
||||
# User is ignored when systemd is used (fedora <= 15).
|
||||
# User is ignored when systemd is used (fedora >= 15).
|
||||
user = mysql
|
||||
|
||||
# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
|
||||
|
@ -57,7 +76,6 @@ query_cache_size = {{ mysql_query_cache_size }}
|
|||
|
||||
# Other settings.
|
||||
wait_timeout = {{ mysql_wait_timeout }}
|
||||
max_allowed_packet = {{ mysql_max_allowed_packet }}
|
||||
|
||||
# Try number of CPU's * 2 for thread_concurrency.
|
||||
thread_concurrency = {{ mysql_thread_concurrency }}
|
||||
|
@ -76,11 +94,4 @@ quick
|
|||
max_allowed_packet = {{ mysql_mysqldump_max_allowed_packet }}
|
||||
|
||||
[mysqld_safe]
|
||||
{% if mysql_log_error == 'syslog' %}
|
||||
syslog
|
||||
syslog-tag = {{ mysql_syslog_tag }}
|
||||
{% else %}
|
||||
skip-syslog
|
||||
log-error = {{ mysql_log_error }}
|
||||
{% endif %}
|
||||
pid-file = /var/run/mysqld/mysqld.pid
|
||||
|
|
Loading…
Reference in a new issue