How to upgrade MariaDB running as a docker container

Viewed 2956

I have MariaDB 10.1 running in a Docker container and I want to upgrade to 10.2. My data is persisted in a volume which /var/lib/mysql is mapped to, my.cnf, is not mapped and unchanged. What is the correct procedure to end up with a Maria 10.2 container with my data intact?

The procedure I considering is as follows:

  1. Stop the 10.1 container
  2. Duplicate the data volume
  3. Create a new 10.3 container, mapping the data directory to the duplicated volume
  4. Start the new container

My concern in this is step 3. During a 'standard' (non-Docker) upgrade, might the upgrade process not alter the data directory in some way? And if so, any changes that should be made to the /var/lib/mysql directory during upgrade would not be made to the volume, as its outside Docker.

Is my procedure correct? Is my concern justified?

1 Answers

MariaDB documentation does have an upgrade from 10.1 -> 10.2 documentation that is worth reading.

Although most of it is around package upgrades however there are some notes around an optional SET GLOBAL innodb_fast_shutdown=0 and finishing with mysql_upgrade.

A docker volume inspect to look at the mountpoint and take a copy of the datadir is prudent, especially if you don't have recent backups or have a quick restoration business requirement (though if this is the case you should test the later version with a restore from backup and the inplace upgrade procedure).

An inplace upgrade without SET GLOBAL innodb_fast_shutdown=0 prior to shutdown will cause the innodb to begin recovery and apply the redo log to the datadir. There is small risk that this could be doing something differently to what it was doing before.

With the new container started you can test the data exists. When you are ready, run the mysql_upgrade (I'd normally do docker exec -i {container} mysql_upgrade). This will hopefully be automated (gh#350, MDEV-25670) when I think of a reliable way to do this.

As Monty says "You should be able to trivially upgrade from ANY earlier MariaDB version to the latest one" (or any intermediate one), so don't feel as though you have to 10.1 -> 10.2 and eventually 10.3.

Related