2.2. Using containers to run multiple MariaDB and MySQL instances on a single host
If you install MariaDB or MySQL from packages, you can only run one of these services and only a single version of it on the same host. As an alternative, you can run the services in a container.
You can configure the following scenarios:
- You want to run multiple instances of MariaDB or MySQL on the same host.
- You want to run both MariaDB and MySQL on the same host.
Prerequisites
-
The
podmanpackage is installed.
Procedure
Authenticate to the
registry.redhat.ioregistry by using your Red Hat Customer Portal account:# podman login registry.redhat.ioSkip this step if you are already logged in to the container registry.
Start the containers you want to use:
MariaDB 10.11:
$ podman run -d --name <container_name_1> -e MYSQL_ROOT_PASSWORD=<password> -p <host_port_1>:3306 rhel10/mariadb-1011For more information about the usage of this container image, see the Red Hat Ecosystem Catalog.
MySQL 8.4:
$ podman run -d --name <container_name_2> -e MYSQL_ROOT_PASSWORD=<password> -p <host_port_2>:3306 rhel10/mysql-84For more information about the usage of this container image, see the Red Hat Ecosystem Catalog.
重要The container names and host ports of the two database servers must differ.
To ensure that clients can access the database server on the network, open the host ports in the firewall:
# firewall-cmd --permanent --add-port={<host_port_1>/tcp,<host_port_2>/tcp,...} # firewall-cmd --reload
Verification
Connect to the database server and log in as root:
# mysql -u root -p -h localhost -P <host_port> --protocol tcpOptional: Display information about the running containers:
$ podman ps