Databases¶
The database service runs MySQL, MariaDB and PostgreSQL for you. Each database is a VM with its own volumes; you connect to it like any other database server. Open Database in the Console menu.
Supported versions are listed in Datastores.
Create a database¶
- Open Database > Database Instances > Create Database Instance.
- Choose the datastore and version.
- Choose a flavor and the data volume size. See limits: the maximum data volume is 15 GB.
- Choose the network, and optionally a configuration group in the Advanced step.
- Enter the initial admin user and password, and the initial databases if asked, then confirm.
Each database has a 5 GB root volume plus the data volume you choose, both counted against your volume quota.
Important
Pick enough memory. MySQL 8.4 needs at least a t2.small (2 GiB), and a t2.medium (4 GiB) to be comfortable. On a 1 GiB flavor it can run out of memory, and backups hang.
Connect¶
Open the database instance from Database > Database Instances to see its address. Connect from a VM on the same network, or associate a floating IP with the database and allow the port in a security group:
psql -h <address> -U app appdb # PostgreSQL, port 5432
mysql -h <address> -u app -p appdb # MySQL / MariaDB, port 3306
Users and databases¶
The initial user and databases come from the create form. To add more, open the instance from Database > Database Instances:
- Databases tab: Create Database and enter a name. Delete one from its row menu.
- Users tab: Create User and enter the name, password and the database the user may access. The list shows each user's Allowed Host and Databases.
- To give an existing user access to more databases, choose Grant Databases Access in the user's row menu and pick the databases.
The instance must be ACTIVE for these tabs to work.
Status¶
| Status | Meaning |
|---|---|
BUILD | Being created |
ACTIVE | Running |
SHUTDOWN | The database service was stopped. Shown even though the VM itself is up |
BACKUP | A backup is running |
ERROR / FAILED | Something went wrong. See below |
Backups¶
Database backups are stored in object storage, separate from volume backups.
- Open Database > Backups > Create Database Backup and choose the instance.
- To restore, use Restore in the backup's row menu. It creates a new instance.
A running backup cannot be deleted normally. If one is stuck, use Force Delete from the backup's More menu. It needs a role that can use management actions. It does not stop a backup process stuck inside the VM; reboot the database in that case.
Configuration groups¶
A configuration group is a named set of database parameters you can apply to one or more instances.
- Open Database > Configuration Groups > Create Configurations. Pick the datastore and version, give a name and a description (required), and add parameters as key/value pairs.
- Attach it to an existing database: open Database > Database Instances, and in the instance's Configuration Update menu choose Manage Configuration. Only groups matching the instance's datastore and version are listed. The same menu can detach it.
Parameter names must be valid for the datastore version; a wrong name is rejected with an error. Some parameters need a restart to take effect.
Resize¶
In the Configuration Update menu of an ACTIVE instance:
- Resize Volume grows the data volume (up to the maximum). It cannot shrink.
- Resize Flavor changes CPU and memory. The database restarts during the change.
Both are hidden while a backup runs.
If a database is stuck¶
If an instance stays in a task such as Resizing the instance and the normal Restart or Stop actions are unavailable, use Force Reboot (in the Database Instance Status menu). It clears the stuck task and hard reboots the VM. It is available in every status, and needs a role that can use management actions.
Anything else, contact the DiscoCloud team with the instance name.