Add an option to allow MySQL service to log to syslog.

This patch provides one of the alternative solution to address the
problem that the error log might grow too large.

Closes-bug: #1812950
Change-Id: If7c0c71492eb30f24cbcc03ca05a67e6ea571f4e
This commit is contained in:
Chi Wai, Chan 2022-06-27 10:35:23 +08:00
parent 6e42563bf4
commit 66f004c2ba
4 changed files with 18 additions and 0 deletions

View File

@ -177,6 +177,12 @@ options:
description: |
Default multicast port number that will be used to communicate between HA
Cluster nodes.
use-syslog:
type: boolean
default: False
description: |
Uses syslog instead of the default error log file (/var/log/mysql/error.log).
Setting this to True will allow MySQL service to log to syslog.
enable-binlogs:
type: boolean
default: False

View File

@ -268,6 +268,7 @@ def render_config(hosts=None):
'sst_password': sst_password(),
'innodb_file_per_table': config('innodb-file-per-table'),
'table_open_cache': config('table-open-cache'),
'use_syslog': config('use-syslog'),
'binlogs_path': config('binlogs-path'),
'enable_binlogs': config('enable-binlogs'),
'binlogs_max_size': config('binlogs-max-size'),

View File

@ -70,7 +70,13 @@ query_cache_size = 16M
#
# Error log - should be very few entries.
#
# Optionally enable syslog instead, addressing bug:
# https://bugs.launchpad.net/charm-percona-cluster/+bug/1812950
{% if use_syslog -%}
log_syslog = {{ use_syslog }}
{% else -%}
log_error = /var/log/mysql/error.log
{% endif %}
#
# The following can be used as easy to replay backup logs or for replication.

View File

@ -918,6 +918,7 @@ class TestConfigs(CharmTestCase):
'series_upgrade': hooks.is_unit_upgrading_set(),
'private_address': '10.1.1.1',
'cluster_hosts': '',
'use_syslog': self.default_config['use-syslog'],
'enable_binlogs': self.default_config['enable-binlogs'],
'sst_password': 'sstpassword',
'myisam_recover': 'BACKUP',
@ -976,6 +977,7 @@ class TestConfigs(CharmTestCase):
'private_address': '10.1.1.1',
'innodb_autoinc_lock_mode': '2',
'cluster_hosts': '',
'use_syslog': self.default_config['use-syslog'],
'enable_binlogs': self.default_config['enable-binlogs'],
'sst_password': 'sstpassword',
'sst_method': self.default_config['sst-method'],
@ -1042,6 +1044,7 @@ class TestConfigs(CharmTestCase):
'private_address': '10.1.1.1',
'innodb_autoinc_lock_mode': '2',
'cluster_hosts': '',
'use_syslog': self.default_config['use-syslog'],
'enable_binlogs': self.default_config['enable-binlogs'],
'sst_password': 'sstpassword',
'sst_method': self.default_config['sst-method'],
@ -1121,6 +1124,7 @@ class TestConfigs(CharmTestCase):
'private_address': '10.1.1.1',
'innodb_autoinc_lock_mode': '2',
'cluster_hosts': '',
'use_syslog': self.default_config['use-syslog'],
'enable_binlogs': self.default_config['enable-binlogs'],
'sst_password': 'sstpassword',
'sst_method': self.default_config['sst-method'],
@ -1184,6 +1188,7 @@ class TestConfigs(CharmTestCase):
'private_address': '10.1.1.1',
'innodb_autoinc_lock_mode': '2',
'cluster_hosts': '',
'use_syslog': self.default_config['use-syslog'],
'enable_binlogs': self.default_config['enable-binlogs'],
'sst_password': 'sstpassword',
'sst_method': self.default_config['sst-method'],