Sign inSign up

alessmicro/mysql-percona

By alessmicro

Updated over 1 year ago

Image
Databases & storage
0

485

alessmicro/mysql-percona repository overview

This is a rebuild of the bitnami/percona-mysql container, the only updates they give is LTS. It's based on the Dockerfile and is intended for development or testing purposes. All the environment variables are setup the same way as official Bitnami Container.

Important: These are not sutiable or allowed for production Usage. Bitnami Does have some different tags and versions available, on enterprise support, please use those for regular updates also the official percona container from Percona is also nice, or else kindly use the Dockerfile and build your own as building is fun also.

  • This container is built from Scratch it uses same bitnami initialization scripts. The base was chosen as Oracle Linux 9 which is a derivative of RHEL with enterprise support. Rocky Linux and Almalinux is not chosen due to Oracle Linux having enterprise grade stability and support and RHEL base is not used due to lots of packages are under Subscription Repos which are needed to build and run MySQL server, Even if we built it with RHEL we would not be able to redistribute the containers and Build it yourself container is much complicated in non RHEL Hosts. So Oracle Linux stayed a strong Contender for Database Systems and Other Applications which need enterprise grade stability and larger non subscription package repositories and also redistributable when RHEL/RPM ABI/Binary Compatiblity is needed.

  • The Dockerfiles are build from base files. So you can modify the software version numbers as you want, They are used as Version Macros in Dockerfile, then maybe some minor changes needed in Dockerfile to build most versions of the software with ease and peace.

Testing Features: Now on Testing tag we have certain new features available at Dockerfile . New Docker Env Variables. The backups are non-blocking. These are full backups. If you have multi gigs of data. you will not be using this. We may make incremental backups available in future, but that is not in our timeline currently.

MYSQL_ENABLE_BACKUP  # default no if set yes it would enable auto backup everyday at 2 AM UTC via percona xtrabackup
MYSQL_BACKUP_USER #username for MySQL backup runner account
MYSQL_BACKUP_PASSWORD # password for MySQL backup runner account. Use a strong password on all passwords or it would have login errors

The backup Directory needs to be mounted at "/bitnami/backups". There are certain times where all rootless containers from bitnami show permission denied on directory write. To fix it use chmod 775 on mysql_data_dir and mysql_backup_dir if you are mounting a directory. Do not make the dirs first. Let the container exit after error then set permissions and run them again.

The backup format is xbstream with timestamps. if you want to restore the backup in this container. we have functionality to restore it also. Make a clean container and let it install the database then shell into the container

#check if you are 1001. to not have issues with permissions. don't restore as root.
whoami
     #shell in the container
supervisorctl stop mysql
     # remove the data in bitnami initialized dir
rm -rfv /bitnami/mysql/data/*
     #Go to your mounted backup dir then. restore path should be bitnami mysql official data dir
xbstream -xv -C /path/to/restore < /path/local/DB.xbstream
xtrabackup prepare --target-dir /path/to/restore
     #Then we start the mysql again
supervisorctl start mysql
     #exit the container and see the logs or you can shell into
     #mysql server with mysqlsh or mysql and check it.
     #I have not known any docker based environment that supports these
     #So we have these here.

On first run it creates the backup user automatically for new installations with environment variables enabled properly. if you migrated your server then you might want to create the backup user with Percona Official suggested guide.

   #as bitnami official container scripts do not resolve hostnames for mysql we need to create the user at '%' as opposed to official percona instuctions to create it in localhost. this has no real bad effect as you might in future want to have replication and have a seperate container for backups
mysql> CREATE USER 'yourbackupuser'@'%' IDENTIFIED BY 'yourbackupuserpass;
mysql> GRANT BACKUP_ADMIN, PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'yourbackupuser'@'%';
mysql> GRANT SELECT ON performance_schema.log_status TO 'yourbackupuser'@'%';
mysql> GRANT SELECT ON performance_schema.keyring_component_status TO 'yourbackupuser'@'%';
mysql> GRANT SELECT ON performance_schema.replication_group_members TO 'yourbackupuser'@'%';
mysql> FLUSH PRIVILEGES;

Then make sure to define the Environment variables in docker compose or in your container run command. IT IS NECCESSARY. cron job reads it from env variable to execute periodic backups. so if you change the password or user later. it would change the backup runner username and password.

MYSQL_ENABLE_BACKUP=yes
MYSQL_BACKUP_USER=your_newly_created_user
MYSQL_BACKUP_PASSWORD=your_newly_created_password

If you have enabled backups and set up everything but you don't want to run the backups anymore for any reason? or maybe you have everything set up then you choose to do manual backups. you can simply set

MYSQL_ENABLE_BACKUP=no

and it will not execute periodic backups . you can simply re enable by setting it to yes.

On first run you might want to test if the backups working or not by executing.

/opt/bitnami/scripts/backup.sh

it should create a backup like this

backup-20250506-034109.xbstream

in you backup directory.

Tag summary

Content type

Image

Digest

sha256:ae23dcb8e

Size

1.3 GB

Last updated

over 1 year ago

docker pull alessmicro/mysql-percona:84-ol9-arm64-testing