diff --git a/helpers/TESTING_service_images_dockercompose.md b/helpers/TESTING_service_images_dockercompose.md index 9a04b043b..bcfd15092 100644 --- a/helpers/TESTING_service_images_dockercompose.md +++ b/helpers/TESTING_service_images_dockercompose.md @@ -163,6 +163,12 @@ docker-compose exec -T mariadb-10-6 sh -c "mysql -V" | grep "10.6" # mariadb-10-6 should be version 10.6 server docker-compose exec -T mariadb-10-6 sh -c "mysql -e \'SHOW variables;\'" | grep "version" | grep "10.6" +# mariadb-10-6 should have performance schema and slow logging disabled +docker-compose exec -T mariadb-10-6 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "performance_schema" | grep "OFF" +docker-compose exec -T mariadb-10-6 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "slow_query_log" | grep "OFF" +docker-compose exec -T mariadb-10-6 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "long_query_time" | grep "10" +docker-compose exec -T mariadb-10-6 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "log_slow_rate_limit" | grep "1" + # mariadb-10-6 should use default credentials docker-compose exec -T mariadb-10-6 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW databases;\'" | grep lagoon @@ -176,6 +182,12 @@ docker-compose exec -T mariadb-10-11 sh -c "mysql -V" | grep "10.11" # mariadb-10-11 should be version 10.11 server docker-compose exec -T mariadb-10-11 sh -c "mysql -e \'SHOW variables;\'" | grep "version" | grep "10.11" +# mariadb-10-11 should have performance schema and slow logging enabled +docker-compose exec -T mariadb-10-11 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "performance_schema" | grep "ON" +docker-compose exec -T mariadb-10-11 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "slow_query_log" | grep "ON" +docker-compose exec -T mariadb-10-11 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "long_query_time" | grep "30" +docker-compose exec -T mariadb-10-11 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW GLOBAL VARIABLES;\'" | grep "log_slow_rate_limit" | grep "5" + # mariadb-10-11 should use default credentials docker-compose exec -T mariadb-10-11 sh -c "mysql -D lagoon -u lagoon --password=lagoon -e \'SHOW databases;\'" | grep lagoon diff --git a/helpers/services-docker-compose.yml b/helpers/services-docker-compose.yml index 4b5d70958..ec66981dc 100644 --- a/helpers/services-docker-compose.yml +++ b/helpers/services-docker-compose.yml @@ -32,6 +32,11 @@ services: image: uselagoon/mariadb-10.11:latest ports: - "3306" + environment: + - MARIADB_PERFORMANCE_SCHEMA=true + - MARIADB_LOG_SLOW=true + - MARIADB_LONG_QUERY_TIME=30 + - MARIADB_LOG_SLOW_RATE_LIMIT=5 << : *default-user # uses the defined user from top mongo-4: diff --git a/images/mariadb/10.11.Dockerfile b/images/mariadb/10.11.Dockerfile index 46c61836b..ad622c19b 100644 --- a/images/mariadb/10.11.Dockerfile +++ b/images/mariadb/10.11.Dockerfile @@ -43,6 +43,7 @@ RUN apk update \ mariadb=~10.11 \ mariadb-connector-c \ net-tools \ + perl-doc \ pwgen \ rsync \ tar \ diff --git a/images/mariadb/10.4.Dockerfile b/images/mariadb/10.4.Dockerfile index bd695f20e..310a47c3f 100644 --- a/images/mariadb/10.4.Dockerfile +++ b/images/mariadb/10.4.Dockerfile @@ -43,6 +43,7 @@ RUN apk update \ mariadb=~10.4 \ mariadb-connector-c \ net-tools \ + perl-doc \ pwgen \ rsync \ tar \ diff --git a/images/mariadb/10.5.Dockerfile b/images/mariadb/10.5.Dockerfile index e4b491337..7cc7a62cd 100644 --- a/images/mariadb/10.5.Dockerfile +++ b/images/mariadb/10.5.Dockerfile @@ -43,6 +43,7 @@ RUN apk update \ mariadb=~10.5 \ mariadb-connector-c \ net-tools \ + perl-doc \ pwgen \ rsync \ tar \ diff --git a/images/mariadb/10.6.Dockerfile b/images/mariadb/10.6.Dockerfile index 8429b0124..5223d7a04 100644 --- a/images/mariadb/10.6.Dockerfile +++ b/images/mariadb/10.6.Dockerfile @@ -43,6 +43,7 @@ RUN apk update \ mariadb=~10.6 \ mariadb-connector-c \ net-tools \ + perl-doc \ pwgen \ rsync \ tar \ diff --git a/images/mariadb/entrypoints/100-mariadb-logging.bash b/images/mariadb/entrypoints/100-mariadb-logging.bash index 976d9218a..37bdfbb17 100755 --- a/images/mariadb/entrypoints/100-mariadb-logging.bash +++ b/images/mariadb/entrypoints/100-mariadb-logging.bash @@ -3,17 +3,20 @@ set -eo pipefail if [ -n "$MARIADB_LOG_SLOW" ]; then - echo "MARIADB_LOG_SLOW set, logging to /etc/mysql/conf.d/log-slow.cnf" + echo "MARIADB_LOG_SLOW set, logging to /var/log/mariadb-slow.log" cat < /etc/mysql/conf.d/log-slow.cnf [mysqld] +log-output=file slow_query_log = 1 slow_query_log_file = /var/log/mariadb-slow.log +long_query_time = ${MARIADB_LONG_QUERY_TIME:-10} +log_slow_rate_limit = ${MARIADB_LOG_SLOW_RATE_LIMIT:-1} EOF fi if [ -n "$MARIADB_LOG_QUERIES" ]; then - echo "MARIADB_LOG_QUERIES set, logging to /etc/mysql/conf.d/log-queries.cnf" + echo "MARIADB_LOG_QUERIES set, logging to /var/log/mariadb-queries.log" cat < /etc/mysql/conf.d/log-queries.cnf [mysqld] diff --git a/images/mariadb/entrypoints/150-mariadb-performance.bash b/images/mariadb/entrypoints/150-mariadb-performance.bash index c8b73b2d4..eb9835cb7 100755 --- a/images/mariadb/entrypoints/150-mariadb-performance.bash +++ b/images/mariadb/entrypoints/150-mariadb-performance.bash @@ -10,4 +10,17 @@ if [ "$LAGOON_ENVIRONMENT_TYPE" == "production" ]; then if [ -z ${MARIADB_INNODB_LOG_FILE_SIZE+x} ]; then export MARIADB_INNODB_LOG_FILE_SIZE=256M fi -fi \ No newline at end of file +fi + +if [ -n "$MARIADB_PERFORMANCE_SCHEMA" ]; then + echo "Enabling performance schema" + cat < /etc/mysql/conf.d/performance-schema.cnf +[mysqld] +performance_schema=ON +performance-schema-instrument='stage/%=ON' +performance-schema-consumer-events-stages-current=ON +performance-schema-consumer-events-stages-history=ON +performance-schema-consumer-events-stages-history-long=ON +EOF + +fi