mirror of
https://github.com/linuxserver/docker-mariadb.git
synced 2026-02-20 01:01:44 +08:00
Add logrotate
This commit is contained in:
parent
fb00241c4f
commit
bb28a9ddc1
@ -21,6 +21,7 @@ RUN \
|
||||
fi && \
|
||||
apk add --no-cache \
|
||||
gnupg \
|
||||
logrotate \
|
||||
mariadb==${MARIADB_VERSION} \
|
||||
mariadb-backup==${MARIADB_VERSION} \
|
||||
mariadb-client==${MARIADB_VERSION} \
|
||||
|
||||
@ -21,6 +21,7 @@ RUN \
|
||||
fi && \
|
||||
apk add --no-cache \
|
||||
gnupg \
|
||||
logrotate \
|
||||
mariadb==${MARIADB_VERSION} \
|
||||
mariadb-backup==${MARIADB_VERSION} \
|
||||
mariadb-client==${MARIADB_VERSION} \
|
||||
|
||||
@ -366,6 +366,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
|
||||
|
||||
## Versions
|
||||
|
||||
* **11.01.25:** - Add log rotation, follow the instructions in the container log.
|
||||
* **06.01.25:** - Rebase to Alpine 3.21.
|
||||
* **31.05.24:** - Rebase to Alpine 3.20.
|
||||
* **23.12.23:** - Rebase to Alpine 3.19.
|
||||
|
||||
@ -142,6 +142,7 @@ init_diagram: |
|
||||
"mariadb:latest" <- Base Images
|
||||
# changelog
|
||||
changelogs:
|
||||
- {date: "11.01.25:", desc: "Add log rotation, follow the instructions in the container log."}
|
||||
- {date: "06.01.25:", desc: "Rebase to Alpine 3.21."}
|
||||
- {date: "31.05.24:", desc: "Rebase to Alpine 3.20."}
|
||||
- {date: "23.12.23:", desc: "Rebase to Alpine 3.19."}
|
||||
|
||||
@ -102,7 +102,7 @@ console = 1
|
||||
#
|
||||
log_warnings = 2
|
||||
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf
|
||||
#log_error = /config/log/mysql/mysql.log
|
||||
log_error = /config/log/mysql/mariadb-error.log
|
||||
#
|
||||
# Enable the slow query log to see queries with especially long duration
|
||||
slow_query_log = 1
|
||||
|
||||
23
root/etc/logrotate.d/mariadb
Normal file
23
root/etc/logrotate.d/mariadb
Normal file
@ -0,0 +1,23 @@
|
||||
/config/log/mysql/*.log /config/log/mysql/*.err {
|
||||
firstaction
|
||||
/usr/bin/mariadb-admin --local version 2> /dev/null
|
||||
endscript
|
||||
su abc abc
|
||||
missingok
|
||||
create 660 abc abc
|
||||
notifempty
|
||||
daily
|
||||
minsize 1M
|
||||
maxsize 100M
|
||||
rotate 30
|
||||
dateext
|
||||
dateformat .%Y-%m-%d-%H-%M-%S
|
||||
compress
|
||||
delaycompress
|
||||
sharedscripts
|
||||
olddir archive/
|
||||
createolddir 770 abc abc
|
||||
postrotate
|
||||
/usr/bin/mariadb-admin --local flush-error-log flush-engine-log flush-general-log flush-slow-log
|
||||
endscript
|
||||
}
|
||||
@ -57,6 +57,8 @@ EOM
|
||||
cat >>"${tempSqlFile}" <<-EONEWSQL
|
||||
$MYSQL_PASS
|
||||
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
|
||||
DROP USER 'root'@'localhost';
|
||||
GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION ;
|
||||
DROP DATABASE IF EXISTS test ;
|
||||
$MYSQL_DB_SETUP
|
||||
EONEWSQL
|
||||
|
||||
53
root/etc/s6-overlay/s6-rc.d/init-mariadb-poststart/run
Executable file
53
root/etc/s6-overlay/s6-rc.d/init-mariadb-poststart/run
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
# check logrotate permissions
|
||||
if mariadb-admin --local version 2> /dev/null; then
|
||||
echo "Logrotate is enabled"
|
||||
else
|
||||
cat <<-EOFPASS
|
||||
|
||||
|
||||
|
||||
#####################################################################################
|
||||
# #
|
||||
# Logrotate requires the following permission: #
|
||||
# GRANT ALL ON *.* TO root@localhost IDENTIFIED VIA unix_socket WITH GRANT OPTION ; #
|
||||
# You can grant it via: #
|
||||
# mariadb -uroot -p<PASSWORD> #
|
||||
# #
|
||||
# You can read more about it here: #
|
||||
# https://mariadb.com/kb/en/authentication-from-mariadb-10-4/ #
|
||||
# #
|
||||
#####################################################################################
|
||||
|
||||
|
||||
|
||||
EOFPASS
|
||||
fi
|
||||
|
||||
# check for upgrades
|
||||
if [[ "${#MYSQL_ROOT_PASSWORD}" -gt "3" ]]; then
|
||||
# display a message about upgrading database if needed
|
||||
if mariadb-upgrade -u root -p"${MYSQL_ROOT_PASSWORD}" --check-if-upgrade-is-needed >/dev/null 2>&1; then
|
||||
cat <<-EOF
|
||||
|
||||
|
||||
|
||||
#################################################################
|
||||
# #
|
||||
# An upgrade is required on your databases. #
|
||||
# #
|
||||
# Stop any services that are accessing databases #
|
||||
# in this container, and then run the command #
|
||||
# #
|
||||
# mariadb-upgrade -u root #
|
||||
# #
|
||||
#################################################################
|
||||
|
||||
|
||||
|
||||
EOF
|
||||
sleep 5s
|
||||
fi
|
||||
fi
|
||||
1
root/etc/s6-overlay/s6-rc.d/init-mariadb-poststart/up
Normal file
1
root/etc/s6-overlay/s6-rc.d/init-mariadb-poststart/up
Normal file
@ -0,0 +1 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-mariadb-poststart/run
|
||||
@ -1,27 +0,0 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
if [[ "${#MYSQL_ROOT_PASSWORD}" -gt "3" ]]; then
|
||||
# display a message about upgrading database if needed
|
||||
if mariadb-upgrade -u root -p"${MYSQL_ROOT_PASSWORD}" --check-if-upgrade-is-needed >/dev/null 2>&1; then
|
||||
cat <<-EOF
|
||||
|
||||
|
||||
|
||||
#################################################################
|
||||
# #
|
||||
# An upgrade is required on your databases. #
|
||||
# #
|
||||
# Stop any services that are accessing databases #
|
||||
# in this container, and then run the command #
|
||||
# #
|
||||
# mariadb-upgrade -u root -p<PASSWORD> #
|
||||
# #
|
||||
#################################################################
|
||||
|
||||
|
||||
|
||||
EOF
|
||||
sleep 5s
|
||||
fi
|
||||
fi
|
||||
@ -1 +0,0 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-mariadb-upgrade/run
|
||||
Loading…
x
Reference in New Issue
Block a user