File tree 14 files changed +84
-29
lines changed
14 files changed +84
-29
lines changed Original file line number Diff line number Diff line change 21
21
fi && \
22
22
apk add --no-cache \
23
23
gnupg \
24
+ logrotate \
24
25
mariadb==${MARIADB_VERSION} \
25
26
mariadb-backup==${MARIADB_VERSION} \
26
27
mariadb-client==${MARIADB_VERSION} \
Original file line number Diff line number Diff line change 21
21
fi && \
22
22
apk add --no-cache \
23
23
gnupg \
24
+ logrotate \
24
25
mariadb==${MARIADB_VERSION} \
25
26
mariadb-backup==${MARIADB_VERSION} \
26
27
mariadb-client==${MARIADB_VERSION} \
Original file line number Diff line number Diff line change @@ -366,6 +366,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
366
366
367
367
# # Versions
368
368
369
+ * ** 11.01.25:** - Add log rotation, follow the instructions in the container log.
369
370
* ** 06.01.25:** - Rebase to Alpine 3.21.
370
371
* ** 31.05.24:** - Rebase to Alpine 3.20.
371
372
* ** 23.12.23:** - Rebase to Alpine 3.19.
Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ init_diagram: |
142
142
"mariadb:latest" <- Base Images
143
143
# changelog
144
144
changelogs :
145
+ - {date: "11.01.25:", desc: "Add log rotation, follow the instructions in the container log."}
145
146
- {date: "06.01.25:", desc: "Rebase to Alpine 3.21."}
146
147
- {date: "31.05.24:", desc: "Rebase to Alpine 3.20."}
147
148
- {date: "23.12.23:", desc: "Rebase to Alpine 3.19."}
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ console = 1
102
102
#
103
103
log_warnings = 2
104
104
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf
105
- # log_error = /config/log/mysql/mysql .log
105
+ log_error = /config/log/mysql/mariadb-error .log
106
106
#
107
107
# Enable the slow query log to see queries with especially long duration
108
108
slow_query_log = 1
Original file line number Diff line number Diff line change
1
+ /config/log/mysql/*.log /config/log/mysql/*.err {
2
+ firstaction
3
+ /usr/bin/mariadb-admin --local version 2> /dev/null
4
+ endscript
5
+ su abc abc
6
+ missingok
7
+ create 660 abc abc
8
+ notifempty
9
+ daily
10
+ minsize 1M
11
+ maxsize 100M
12
+ rotate 30
13
+ dateext
14
+ dateformat .%Y-%m-%d-%H-%M-%S
15
+ compress
16
+ delaycompress
17
+ sharedscripts
18
+ olddir archive/
19
+ createolddir 770 abc abc
20
+ postrotate
21
+ /usr/bin/mariadb-admin --local flush-error-log flush-engine-log flush-general-log flush-slow-log
22
+ endscript
23
+ }
Original file line number Diff line number Diff line change 57
57
cat >>"${tempSqlFile}" <<-EONEWSQL
58
58
$MYSQL_PASS
59
59
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
60
+ DROP USER 'root'@'localhost';
61
+ GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION ;
60
62
DROP DATABASE IF EXISTS test ;
61
63
$MYSQL_DB_SETUP
62
64
EONEWSQL
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/with-contenv bash
2
+ # shellcheck shell=bash
3
+
4
+ # check logrotate permissions
5
+ if mariadb-admin --local version 2> /dev/null; then
6
+ echo "Logrotate is enabled"
7
+ else
8
+ cat <<-EOFPASS
9
+
10
+
11
+
12
+ #####################################################################################
13
+ # #
14
+ # Logrotate requires the following permission: #
15
+ # GRANT ALL ON *.* TO root@localhost IDENTIFIED VIA unix_socket WITH GRANT OPTION ; #
16
+ # You can grant it via: #
17
+ # mariadb -uroot -p<PASSWORD> #
18
+ # #
19
+ # You can read more about it here: #
20
+ # https://mariadb.com/kb/en/authentication-from-mariadb-10-4/ #
21
+ # #
22
+ #####################################################################################
23
+
24
+
25
+
26
+ EOFPASS
27
+ fi
28
+
29
+ # check for upgrades
30
+ if [[ "${#MYSQL_ROOT_PASSWORD}" -gt "3" ]]; then
31
+ # display a message about upgrading database if needed
32
+ if mariadb-upgrade -u root -p"${MYSQL_ROOT_PASSWORD}" --check-if-upgrade-is-needed >/dev/null 2>&1; then
33
+ cat <<-EOF
34
+
35
+
36
+
37
+ #################################################################
38
+ # #
39
+ # An upgrade is required on your databases. #
40
+ # #
41
+ # Stop any services that are accessing databases #
42
+ # in this container, and then run the command #
43
+ # #
44
+ # mariadb-upgrade -u root #
45
+ # #
46
+ #################################################################
47
+
48
+
49
+
50
+ EOF
51
+ sleep 5s
52
+ fi
53
+ fi
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ /etc/s6-overlay/s6-rc.d/init-mariadb-poststart/run
Load Diff This file was deleted.
Load Diff This file was deleted.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments