Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-22659: Create one single unified and optimal logrotate config (pending on RPM packaging changes) #1556

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ support-files/my-innodb-heavy-4G.cnf
support-files/my-large.cnf
support-files/my-medium.cnf
support-files/my-small.cnf
support-files/mysql-log-rotate
support-files/mariadb.logrotate
support-files/mysql.10.0.11.spec
support-files/mysql.server
support-files/mysql.service
Expand Down
1 change: 1 addition & 0 deletions debian/mariadb-server.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ debian/additions/mariadb.conf.d/50-mysqld_safe.cnf etc/mysql/mariadb.conf.d
debian/additions/mariadb.conf.d/50-server.cnf etc/mysql/mariadb.conf.d
debian/additions/source_mariadb.py usr/share/apport/package-hooks
etc/apparmor.d/usr.sbin.mariadbd
etc/logrotate.d/mariadb
etc/security/user_map.conf
lib/*/security/pam_user_map.so
lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf
Expand Down
20 changes: 0 additions & 20 deletions debian/mariadb-server.mysql-server.logrotate

This file was deleted.

7 changes: 7 additions & 0 deletions debian/mariadb-server.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ EOF
fi
fi

# The introduction of /etc/logrotate.d/mariadb has made the old config
# obsolete and it needs to be disabled to prevent logrotate running twice.
if [ -f /etc/logrotate.d/mysql-server ]
then
mv -vf /etc/logrotate.d/mysql-server /etc/logrotate.d/mysql-server.dpkg-bak
fi

# @TODO: Remove once buildbot.askmonty.org has been updated not to expect this file
mkdir -p /etc/systemd/system/mariadb.service.d/
# Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic
Expand Down
1 change: 0 additions & 1 deletion debian/not-installed
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ usr/share/man/man3/mysql_warning_count.3
usr/share/mysql/binary-configure
usr/share/mysql/magic
usr/share/mysql/maria_add_gis_sp.sql # mariadb-server-core.install has *_bootstrap.sql
usr/share/mysql/mysql-log-rotate # Debian packaging uses mariadb-server.mysql-server.logrotate
usr/share/mysql/mysql-test/asan.supp
usr/share/mysql/mysql-test/lsan.supp
usr/share/mysql/mysql-test/unstable-tests
Expand Down
3 changes: 0 additions & 3 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ endif
# Move test plugins that are only needed by the client to the libmariadb path
mv -v $(TMP)/usr/lib/mysql/plugin/qa_auth_client.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/

override_dh_installlogrotate-arch:
dh_installlogrotate --name mysql-server
ottok marked this conversation as resolved.
Show resolved Hide resolved

override_dh_systemd_enable:
dh_systemd_enable --name=mariadb
dh_systemd_enable --no-enable --name=mariadb mariadb.socket
Expand Down
14 changes: 11 additions & 3 deletions support-files/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ ELSE()
SET(MYSQLD_GROUP "mysql")
SET(ini_file_extension "cnf")
SET(HOSTNAME "uname -n")

# Define directly here, as cmake/install_layout.cmake has no LOGDIR to be inherited
IF(RPM)
SET(logdir "/var/log/mariadb")
ELSE()
SET(logdir "/var/log/mysql")
ENDIF()
ENDIF()

# XXX: shouldn't we just have variables for all this stuff and centralise
Expand All @@ -51,7 +58,7 @@ ENDIF()

IF(UNIX AND NOT WITHOUT_SERVER)
SET(prefix ${CMAKE_INSTALL_PREFIX})
FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure wsrep_notify mini-benchmark)
FOREACH(script mysqld_multi.server mariadb.logrotate binary-configure wsrep_notify mini-benchmark)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh
${CMAKE_CURRENT_BINARY_DIR}/${script} @ONLY )
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script}
Expand Down Expand Up @@ -199,8 +206,9 @@ IF(UNIX AND NOT WITHOUT_SERVER)
ENDIF()

IF (INSTALL_SYSCONFDIR)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
RENAME mysql COMPONENT SupportFiles)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.logrotate
DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
RENAME mariadb COMPONENT SupportFiles)
IF(NOT HAVE_SYSTEMD)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
DESTINATION ${INSTALL_SYSCONFDIR}/init.d
Expand Down
56 changes: 56 additions & 0 deletions support-files/mariadb.logrotate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This is the MariaDB configuration for the logrotate utility
#
# Note that on most Linux systems logs are written to journald, which has its
# own rotation scheme.
#
# Read https://mariadb.com/kb/en/error-log/ to learn more about logging and
# https://mariadb.com/kb/en/rotating-logs-on-unix-and-linux/ about rotating logs.

@localstatedir@/mysqld.log @localstatedir@/mariadb.log @logdir@/*.log {

# If any of the files listed above is missing, skip them silently without
# emitting any errors
missingok

# If file exists but is empty, don't rotate it
notifempty

# Run monthly
monthly

# Keep 6 months of logs
rotate 6

# If file is growing too big, rotate immediately
maxsize 500M

# If file size is too small, don't rotate at all
minsize 50M

# Compress logs, as they are text and compression will save a lot of disk space
compress

# Don't compress the log immediately to avoid errors about "file size changed while zipping"
delaycompress

# Don't run the postrotate script for each file configured in this file, but
# run it only once if one or more files were rotated
sharedscripts

# After each rotation, run this custom script to flush the logs. Note that
# this assumes that the mariadb-admin command has database access, which it
# has thanks to the default use of Unix socket authentication for the 'root'
# account used everywhere since MariaDB 10.4.
postrotate
if test -r /etc/mysql/debian.cnf
then
EXTRAPARAM='--defaults-file=/etc/mysql/debian.cnf'
fi

if test -x @bindir@/mariadb-admin
then
@bindir@/mariadb-admin $EXTRAPARAM --local flush-error-log \
flush-engine-log flush-general-log flush-slow-log
fi
endscript
}
38 changes: 0 additions & 38 deletions support-files/mysql-log-rotate.sh

This file was deleted.