skip to Main Content

My database won’t start after restarting the server.
it throws the following error;

[ERROR] InnoDB: Page [page id: space=1106, page number=4119] log sequence number 29970252505 is in the future! Current system log sequence number 29967893604.
[ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.

So my question is how do I start innodb in recovery mode using docker?

2

Answers


  1. To start innodb in recovery mode, you need to add the following line to the my.cnf file:

    [mysqld]
    innodb_force_recovery = 0 
    

    0 is normal use. You can read more about the different levels here:
    https://mariadb.com/kb/en/innodb-recovery-modes/

    Usually, the recommendation is to start from the lowest possible value (e.g. try 1), and if that doesn’t work, then increment up. Possible data corruption may occur the higher level you use.

    If you already have the my.cnf file mapping between your host and the container, then just make the modification on your host and start the Docker service.

    If you don’t have the my.cnf file, then you probably have the default variables defined. One of the easiest options is to:

    1. Start a new container with the same image while mapping the container’s /tmp folder to your local machine /path-on-host/tmp.
    2. Go into the container (e.g. docker exec -it container_name bash) and copy the my.cnf file to the tmp folder (cp /etc/my.cnf /tmp) and shut down the container. The location of the my.cnf file is either in /etc, or on some versions it can be in /etc/mysql.
    3. Modify the my.cnf file on your host machine by setting the innodb_force_recovery = x
    4. Add the my.cnf to the correct location on your original container, e.g. using Docker Compose:
    volumes:
          - '/path-on-host/tmp/my.cnf:/etc/my.cnf'
    

    or when using docker run

    --mount type=bind,src=/path-on-host/tmp/my.cnf,dst=/etc/my.cnf 
    
    Login or Signup to reply.
  2. Yo can add it in the ‘command’ line (temporally!) like any other init arguments

    services:
      mariadb:
        image: "mariadb:10.6.4"
        container_name: mariadb
        restart: 'always'
        volumes:
          - /data/mysql:/var/lib/mysql
        environment:
          MYSQL_ROOT_PASSWORD: **
          MYSQL_DATABASE: **
          MYSQL_USER: **
          MYSQL_PASSWORD: **
        command: -–innodb_force_recovery=4 --lower_case_table_names=1 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --innodb-flush-log-at-trx-commit=0 
    

    https://mariadb.com/kb/en/innodb-recovery-modes/#recovery-modes

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search