From 4445c819917d2ae9ebe6ad250b17cac6dfbb1b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 3 Feb 2016 16:55:45 +0100 Subject: [PATCH] Make Heka collect MariaDB logs Partially implements: blueprint heka Change-Id: Ib5e740683cee296bcac69228f525594850d62a27 --- ansible/roles/common/tasks/config.yml | 1 + ansible/roles/common/templates/heka-mariadb.toml.j2 | 10 ++++++++++ ansible/roles/common/templates/heka.json.j2 | 6 ++++++ ansible/roles/mariadb/tasks/bootstrap.yml | 1 + ansible/roles/mariadb/tasks/start.yml | 1 + ansible/roles/mariadb/templates/galera.cnf.j2 | 2 ++ docker/mariadb/extend_start.sh | 8 ++++++++ 7 files changed, 29 insertions(+) create mode 100644 ansible/roles/common/templates/heka-mariadb.toml.j2 diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 8493154320..50b46bf042 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -32,3 +32,4 @@ - "haproxy" - "rabbitmq" - "openstack" + - "mariadb" diff --git a/ansible/roles/common/templates/heka-mariadb.toml.j2 b/ansible/roles/common/templates/heka-mariadb.toml.j2 new file mode 100644 index 0000000000..85fad0d042 --- /dev/null +++ b/ansible/roles/common/templates/heka-mariadb.toml.j2 @@ -0,0 +1,10 @@ +[mariadb_log_decoder] +type = "SandboxDecoder" +filename = "lua_decoders/os_mysql_log.lua" + +[mariadb_logstreamer_input] +type = "LogstreamerInput" +decoder = "mariadb_log_decoder" +log_directory = "/var/log/kolla" +file_match = 'mariadb/mariadb\.log' +differentiator = ['mariadb'] diff --git a/ansible/roles/common/templates/heka.json.j2 b/ansible/roles/common/templates/heka.json.j2 index 11f9a17048..e33982cc04 100644 --- a/ansible/roles/common/templates/heka.json.j2 +++ b/ansible/roles/common/templates/heka.json.j2 @@ -24,6 +24,12 @@ "dest": "/etc/heka/heka-openstack.toml", "owner": "heka", "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/heka-mariadb.toml", + "dest": "/etc/heka/heka-mariadb.toml", + "owner": "heka", + "perm": "0600" } ] } diff --git a/ansible/roles/mariadb/tasks/bootstrap.yml b/ansible/roles/mariadb/tasks/bootstrap.yml index aef9392267..3180a33f9b 100644 --- a/ansible/roles/mariadb/tasks/bootstrap.yml +++ b/ansible/roles/mariadb/tasks/bootstrap.yml @@ -51,6 +51,7 @@ volumes: - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro" - "mariadb:/var/lib/mysql" + - "kolla_logs:/var/log/kolla/" when: - delegate_host == 'None' - inventory_hostname == groups['mariadb'][0] diff --git a/ansible/roles/mariadb/tasks/start.yml b/ansible/roles/mariadb/tasks/start.yml index 8216b5eb8b..57313a918a 100644 --- a/ansible/roles/mariadb/tasks/start.yml +++ b/ansible/roles/mariadb/tasks/start.yml @@ -8,6 +8,7 @@ volumes: - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro" - "mariadb:/var/lib/mysql" + - "kolla_logs:/var/log/kolla/" when: delegate_host != 'None' or ( groups['mariadb'] | length ) == 1 or ( delegate_host == 'None' and inventory_hostname != groups['mariadb'][0] ) diff --git a/ansible/roles/mariadb/templates/galera.cnf.j2 b/ansible/roles/mariadb/templates/galera.cnf.j2 index 9f9ed3ecd8..095652d847 100644 --- a/ansible/roles/mariadb/templates/galera.cnf.j2 +++ b/ansible/roles/mariadb/templates/galera.cnf.j2 @@ -3,6 +3,8 @@ bind-address={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} port={{ mariadb_port }} +log-error=/var/log/kolla/mariadb/mariadb.log + binlog_format=ROW default-storage-engine=innodb innodb_autoinc_lock_mode=2 diff --git a/docker/mariadb/extend_start.sh b/docker/mariadb/extend_start.sh index 55e9ae4c90..f6de85c362 100644 --- a/docker/mariadb/extend_start.sh +++ b/docker/mariadb/extend_start.sh @@ -23,6 +23,14 @@ if [[ $(stat -c %U:%G /var/lib/mysql) != "mysql:mysql" ]]; then sudo chown mysql: /var/lib/mysql fi +# Create log directory, with appropriate permissions +if [[ ! -d "/var/log/kolla/mariadb" ]]; then + mkdir -p /var/log/kolla/mariadb +fi +if [[ $(stat -c %a /var/log/kolla/mariadb) != "755" ]]; then + chmod 755 /var/log/kolla/mariadb +fi + # This catches all cases of the BOOTSTRAP variable being set, including empty if [[ "${!KOLLA_BOOTSTRAP[@]}" ]] && [[ ! -e /var/lib/mysql/cluster.exists ]]; then ARGS="--wsrep-new-cluster"