← RESEARCH
LAB / 2026 CLOUD RESEARCH

DBaaS Contextual

OpenNebula context scripts that bring up database engines through VM boot context and lifecycle hooks, for a database-as-a-service workflow. Redis verified; RDS pending.

OpenNebulaRedisMySQLPostgreSQLMariaDB

Why

A database-as-a-service workflow provisions database VMs from OpenNebula templates. At create time the backend injects a CONTEXT block of ONEAPP_* variables onto a CD-ROM ISO attached to the VM. On boot, the one-context service mounts that ISO, parses the variables, and exports them to /run/one-context/one_env, then runs the scripts in /etc/one-context.d/ in alphabetical order.

The base images already ship the database engines — multiple Redis builds under /opt/redis-*, plus MySQL, PostgreSQL, and MariaDB on Ubuntu 24.04. What they lack is any script that reads the injected context. The variables arrive correctly, but nothing consumes them. Every instance therefore requires an operator to SSH in and set the password, memory policy, bind address, and replication by hand.

This research designs the missing layer: OneApp context scripts that turn database provisioning into a property of the VM boot context. A VM boots, reads its ONEAPP_* variables, and configures its engine with no human in the loop — on first boot and again on recontextualize.

Scope

  • Engines: Redis (MDS), and MySQL, PostgreSQL, MariaDB (RDS) on Ubuntu 24.04.
  • Context scripts placed at net-91-* in /etc/one-context.d/, running after network and one_env generation so the engine can reach peers and read its variables.
  • Per-engine provisioning: password, remote bind address, pre-created database and admin user with grants, Redis memory policy, and Redis master/slave replication.
  • Lifecycle hooks following the OneApp pattern — service_install, service_configure, service_bootstrap, service_cleanup — with service_configure re-reading ONEAPP_* on every boot and recontextualize.
  • OS-level tuning applied before engine setup via a net-90 script.
  • Redis replication is verified end to end. SQL-engine scripts are designed; SQL replication (binary log / GTID, streaming + base backup) is deferred to a later phase.

Problems & Solutions

Boot-time config injection

The engine is running, context variables are present, but no script bridges them. The solution is a per-engine script at /etc/one-context.d/net-91-*-setup that sources one_env, exits early when its engine’s marker variable is absent, waits in a bounded loop until the engine answers (redis-cli ping, mysqladmin ping, pg_isready), then applies configuration. Each script is idempotent so first boot and recontextualize converge to the same state.

Per-engine provisioning

Each engine needs its own non-interactive command path. Redis sets requirepass and masterauth, memory policy, then CONFIG REWRITE to persist. MySQL and MariaDB flip root from socket auth to a password with ALTER USER, create the database and '%' admin user with grants, and rewrite bind-address to 0.0.0.0. PostgreSQL runs everything as the postgres system user, detects its version from /etc/postgresql/, guards CREATE USER/CREATE DATABASE with pg_roles/pg_database existence checks, and opens remote access through listen_addresses and a pg_hba.conf rule.

Redis replication

Replication needs two settings on the slave in the right order: CONFIG SET masterauth before REPLICAOF <master_ip> 6379, otherwise the slave connects but fails to authenticate. A two-node test (master 10.254.11.5, slave 10.254.11.6, Redis 7.4.2) confirmed context injection carried all ONEAPP_REDIS_* variables and that manual configuration produced master_link_status:up and connected_slaves:1. The script automates exactly that sequence and polls the link status.

OS tuning for database workloads

Ubuntu defaults target general-purpose workloads. A net-90-os-database-tuning script, running before engine setup, writes /etc/sysctl.d/99-database.conf with shared settings (vm.swappiness=1, net.core.somaxconn=65535, raised fs.file-max, lowered dirty ratios), then branches per engine — vm.overcommit_memory=1 for Redis, =2 with overcommit_ratio=80 for PostgreSQL. It disables Transparent Huge Pages, raises file-descriptor limits, sets the I/O scheduler to none for virtio disks, and remounts root noatime.

Architecture

G cluster_ctx one-context.d (alphabetical) backend Backend (create instance) template OpenNebula template + CONTEXT (ONEAPP_* vars) backend->template boot VM boot one-context.service template->boot attached as CD-ROM ISO parse mount ISO, parse context → /run/one-context/one_env boot->parse run run /etc/one-context.d/* (alphabetical) parse->run net loc-10-network network up run->net genenv loc-16-gen-env export ONEAPP_* run->genenv tuning net-90-os-database-tuning sysctl, THP, limits, I/O run->tuning redis net-91-redis-setup password, maxmem, REPLICAOF run->redis rds net-91-rds-setup root pw, db, admin user, bind run->rds configured Engine configured repeats on recontextualize rds->configured

OS tuning (net-90) runs before engine configuration (net-91) so the engine starts under the correct kernel parameters. Because scripts re-run on recontextualize, an admin can change config with onevm updateconf and trigger a reload without rebooting the VM.