mariadb: Aktiviere slowlog in der globalen Konfigurationsdatei

This commit is contained in:
phil 2022-06-09 13:38:00 +02:00
parent 415a6055e8
commit 10da0a723e
6 changed files with 21 additions and 23 deletions

View file

@ -4,6 +4,3 @@ monit_sql_password: otV7krRQQJa7YIBoFZDLOTBibB3mfXLmwDTwITffiK
munin_sql_config_file: /etc/munin/plugin-conf.d/zzz-mariadb
munin_sql_user: munin
munin_sql_password: za8x5sECY6pP2GWdR36UKYP7tHFodvRLyr6f5wAt7D
mysql_server_config_file: /etc/mysql/mariadb.conf.d/50-server.cnf
mysql_socket: /run/mysqld/mysqld.sock

View file

@ -4,7 +4,7 @@
name: munin-node
state: restarted
- name: restart mysql
- name: restart mariadb
service:
name: mariadb
state: restarted

View file

@ -2,6 +2,9 @@
- import_tasks: packages.yml
tags: packages
- import_tasks: mariadb.yml
tags: mariadb
- name: "Munin"
include_tasks: munin.yml
when: "'munin' in ansible_facts.packages"

6
tasks/mariadb.yml Normal file
View file

@ -0,0 +1,6 @@
---
- name: "mariadb | Kopiere Serverkonfiguration"
template:
src: 90-sao.cnf.j2
dest: /etc/mysql/mariadb.conf.d/90-sao.cnf
notify: restart mariadb

View file

@ -20,22 +20,3 @@
# Ausgabe von fehlerhaften Plugins (exit 1) ignorieren
ignore_errors: yes
notify: restart munin-node
- name: "Munin: Aktiviere slowlog"
lineinfile:
path: "{{ mysql_server_config_file }}"
insertafter: ^# Enable the slow query
line: 'slow_query_log = 1'
notify: restart mysql
- name: "Munin: Konfiguriere slowlog"
lineinfile:
path: "{{ mysql_server_config_file }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- { regexp: '^#slow_query_log_file', line: 'slow_query_log_file = /var/log/mysql/mariadb-slow.log' }
- { regexp: '^#long_query_time', line: 'long_query_time = 10' }
- { regexp: '^#log_slow_rate_limit', line: 'log_slow_rate_limit = 1000' }
- { regexp: '^#log_slow_verbosity', line: 'log_slow_verbosity = query_plan' }
notify: restart mysql

11
templates/90-sao.cnf.j2 Normal file
View file

@ -0,0 +1,11 @@
# {{ ansible_managed }}
[mysqld]
bind_address={{ mariadb.bind_address|default("127.0.0.1") }}
# Slow-Log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
log_slow_rate_limit = 1000
log_slow_verbosity = query_plan