skip to Main Content

On a server where is running a software which performs many database-queries (update/delete/insert), the MySQL-Server is running in a docker-compose setup.

version: '3.7'
services:
  database:
    image: registry.var-lab.com/mysql/mysql:8.0.27
    command:
      - '--default-authentication-plugin=mysql_native_password'
      - '--sql_mode='
      - '--max_allowed_packet=1073741824'
    ports:
      - '3306:3306'
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: db
      MYSQL_USER: user
      MYSQL_PASSWORD: iamsecure!11
    volumes:
      - ../database:/var/lib/mysql
      - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
    healthcheck:
      test: [ "CMD", "mysqladmin" ,"ping", "-h", "-u", "symfony", "-p", "symfony", "localhost" ]
      timeout: 20s
      retries: 10

After the software was running a few days, the disk space was full. After investigating that, I notized that MySQL is continuously is logging all data manipulation operations into binlog-files in the ../database folder which is mounted as a volume into the MySQL Docker container.

How can I disable this logging action in the docker-compose.yml file?

2

Answers


  1. In MySQL 8.0 set log-bin=OFF to disable the binary log. Read https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html#option_mysqld_log-bin for full details.

    You could alternatively make the binary logs expire on a short schedule. Use the option binlog-expire-logs-seconds=N where N means if the log file is older than N seconds, it is removed automatically at mysqld startup time, or when a logs roll over to a new log file, or when you execute FLUSH LOGS). Read https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html#sysvar_binlog_expire_logs_seconds for more details.

    Login or Signup to reply.
  2. Following the documentation already mentioned by Bill Karwin (https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html#option_mysqld_log-bin) I added the following command to my docker-compose.yml:

    command:
            - '--skip-log-bin'
    

    I built the container, ran it, entered a terminal, started the mysql client and checked via SHOW VARIABLES LIKE 'log_bin'; and it worked:

    mysql> SHOW VARIABLES LIKE 'log_bin';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | log_bin       | OFF   |
    +---------------+-------+
    1 row in set (0.01 sec)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search