Managed MariaDB Service

The Managed MariaDB Service offers a powerful and widely used relational database solution. This service allows you to create and manage a replicated MariaDB cluster seamlessly.

Deployment Details

This managed service is controlled by mariadb-operator, ensuring efficient management and seamless operation.

HowTos

How to switch master/slave replica

kubectl edit mariadb <instnace>

update:

spec:
  replication:
    primary:
      podIndex: 1

check status:

NAME        READY   STATUS    PRIMARY POD   AGE
<instance>  True    Running   app-db1-1     41d

How to restore backup:

find snapshot:

restic -r s3:s3.example.org/mariadb-backups/database_name snapshots

restore:

restic -r s3:s3.example.org/mariadb-backups/database_name restore latest --target /tmp/

more details:

Known issues

  • Replication can’t be finished with various errors

  • Replication can’t be finished in case if binlog purged

    Until mariadbbackup is not used to bootstrap a node by mariadb-operator (this feature is not inmplemented yet), follow these manual steps to fix it: https://github.com/mariadb-operator/mariadb-operator/issues/141#issuecomment-1804760231

  • Corrupted indicies Sometimes some indecies can be corrupted on master replica, you can recover them from slave:

    mysqldump -h <slave> -P 3306 -u<user> -p<password> --column-statistics=0 <database> <table> ~/tmp/fix-table.sql
    mysql -h <master> -P 3306 -u<user> -p<password> <database> < ~/tmp/fix-table.sql
    

Parameters

Common parameters

NameDescriptionTypeValue
replicasNumber of MariaDB replicasint2
resourcesExplicit CPU and memory configuration for each MariaDB replica. When left empty, the preset defined in resourcesPreset is applied.*object{}
resources.cpuCPU available to each replica*quantitynull
resources.memoryMemory (RAM) available to each replica*quantitynull
resourcesPresetDefault sizing preset used when resources is omitted. Allowed values: nano, micro, small, medium, large, xlarge, 2xlarge.stringnano
sizePersistent Volume Claim size, available for application dataquantity10Gi
storageClassStorageClass used to store the datastring""
externalEnable external access from outside the clusterboolfalse

Application-specific parameters

NameDescriptionTypeValue
usersUsers configurationmap[string]object{...}
users[name].passwordPassword for the userstring""
users[name].maxUserConnectionsMaximum amount of connectionsint0
databasesDatabases configurationmap[string]object{...}
databases[name].rolesRoles for the database*objectnull
databases[name].roles.adminList of users with admin privileges[]string[]
databases[name].roles.readonlyList of users with read-only privileges[]string[]

Backup parameters

NameDescriptionTypeValue
backupBackup configurationobject{}
backup.enabledEnable regular backups, default is false.boolfalse
backup.s3RegionAWS S3 region where backups are storedstringus-east-1
backup.s3BucketS3 bucket used for storing backupsstrings3.example.org/mysql-backups
backup.scheduleCron schedule for automated backupsstring0 2 * * *
backup.cleanupStrategyRetention strategy for cleaning up old backupsstring--keep-last=3 --keep-daily=3 --keep-within-weekly=1m
backup.s3AccessKeyAccess key for S3, used for authenticationstring<your-access-key>
backup.s3SecretKeySecret key for S3, used for authenticationstring<your-secret-key>
backup.resticPasswordPassword for Restic backup encryptionstring<password>

Parameter examples and reference

resources and resourcesPreset

resources sets explicit CPU and memory configurations for each replica. When left empty, the preset defined in resourcesPreset is applied.

resources:
  cpu: 4000m
  memory: 4Gi

resourcesPreset sets named CPU and memory configurations for each replica. This setting is ignored if the corresponding resources value is set.

Preset nameCPUmemory
nano250m128Mi
micro500m256Mi
small1512Mi
medium11Gi
large22Gi
xlarge44Gi
2xlarge88Gi

users

users:
  user1:
    maxUserConnections: 1000
    password: hackme
  user2:
    maxUserConnections: 1000
    password: hackme

databases

databases:
  myapp1:
    roles:
      admin:
      - user1
      readonly:
      - user2