Migrating MariaDB MySQL Server Plugin to MariaDB Docker Container
In the new version of OMV 5.x, the MariaDB Plugin will most likely not exist and if you are currently using this Plugin,
you will have to take a different approach to installing MySQL server and migrating your databases.
One option is to manually install it like any other Debian package directly onto the OS.
Other option is use a new (relatively to OMV) technology of Docker Container to run MySQL service.
To learn more about what is Docker, there are many resources on the net.
Docker needs to be installed on the Host operating system (Linux, Windows, Mac OS, etc).
For OMV, there is Docker Plugin that provides a GUI to install and manage Docker Images & Containers for App/Services .
The objective of this tutorial is to show you how to migrate a working MySQL OMV Plugin to a MariaDB Docker Container - a MySQL Server.
As a follow up in Part 2, I will add Nextcloud Docker service that uses the same MariaDB Container.
In this example, I will show how I migrated my Kodi databases running under MySQL Plugin to a Docker Container.
What you will need (pre-requisites):
- Access to OMV SSH Shell (using your favourite method - Terminal, Putty, Shellinabox, etc).
- Docker Plugin already installed
- A folder called /sharedfolders/docker
- An OMV User ID already set up
- Working Kodi system with MySQL based Library hosted on your OMV Server
Summary of steps
Step 1. Backup the exiting Kodi databases
Step 2. Uninstall MySQL Plugin
Step 3. Prepare Docker environment setup for MariaDB
Step 4. Install MariaDB Docker
Step 5. Import the Kodi databases into the new MySQL server
Step 6. Test the configuration
Kodi has many versions of databases that it creates for your Media depending on the version of Kodi you are running.
If you are like me, and have grown with Kodi (from Version 14 to the current version 18) and kept your media metadata on
the MySQL server, then you will have several databases on your server for each different versions of Kodi.
Additionally, you may have used the same MySQL server for other Applications too.
So the first step is to back up all your databases so that we can import them back into the new MySQL MariaDB Docker Container.
If you have not setup Kodi databases or any other databases, then there's nothing for you backup and can skip this step.
Otherwise, start a shell on OMV (via Terminal on your desktop, Putty, or Shellinabox, etc).
Enter the following command to backup your MySQL databases:
If you had setup a root password, you will be prompted enter it.
All your Databases, their User ID's & passwords will be saved to the compressed file alldb.sql.gz.
Copy that file somewhere (e.g. in one of your /sharedfolders)
BTW, it's a good practise to do this regularly.
Uninstall MySQL Plugin. Since this service will be listening on TCP Port 3306, it needs to be either stopped or uninstalled.
Follow these steps to uninstall the MySQL Plugin.
On the OMV GUI, navigate to the Plugins screen and find the MySQL Plugin for OpenMediaVault.
Click the Checkbox and then click Uninstall button:
Just to be sure that MySQL was removed, go to the terminal and run the following commands
This may take a while as it searches your system for anything with 'mysql*' so you may want to skip this command 5 above.
Just for good measure, reboot the OMV server though it is strictly not necessary.
Prepare Docker environment setup.
Before we install MariaDB Docker, first we need to setup a couple of environmental elements for
MariaDB Docker (and for future Containers that would connect to it):
1. Host (OMV OS) folders that the MariaDB Container will access
2. A User-defined Docker Network Bridge for connecting Containers together.
Docker Containers have their own file system and they are not accessible to the Host OS.
However, Containers allows parts of their file systems to be mapped to the Host OS folders.
First create folders which the MariaDB Container will access on your OMV file system.
MariaDB Container requires one folders on the Host OS (e.g. in /sharedfolders) for the MariaDB config files and for the actual databases.
The latest MariaDB Docker Image creates database folder within the Config files for you so there's no need for us to create it.
Go to terminal and enter the following command:
I use the folder /sharedfolders/docker as a base for storing all Docker Container related data.
If this does not exist on your system, create it. I called it docker but you can call it whatever you wish (e.g. AppData).
This Docker folder helps in managing all the various current and future Container data in one place.
Make a note of the path to the MariaDB folder since this will be needed in STEP 4 where we map this Host OS path to the Container folder paths like so:
/sharedfolders/docker/mariadb -> /config
This mapping is a portal into the Container's filesystem.
Next create a user-defined Docker Network bridge to which the MariaDB Container will be attached.
The reason for setting up this network will be become apparent in Part 2.
But basically, attaching MariaDB Container to this user-defined network will allow other Apps/Services (connected to
this network) to use the same MariaDB Container.
You can then refer this Container by its name instead of the IP address as Docker's DNS will resolve the name-to-address.
Any Container you create on this network can immediately connect to other Containers on the same network.
This network isolates Containers from other networks (including external) .
However, you can expose and publish certain Container TCP ports on the network, allowing portions of your bridge access to an
outside network (as we will see in the next step).
Go to the terminal and enter the following command:
Docker will create a user-defined called 'my-docker-net' and we will need this name in the next step.
I named the network 'my-docker-net' but you can name it whatever you wish.
STEP 4 in the next post.