universe docs source
browse docs
docs /configuration /database

Database

database.json points Universe at the relational store that holds durable cluster state such as API keys. The bundled H2 backend needs no setup; MySQL is built in, and PostgreSQL, MongoDB, and Redis arrive through extensions.

Universe keeps two kinds of state. Live instance state, which instance is ONLINE, on which Wrapper, on which port, lives in Hazelcast distributed maps and is rebuilt as the cluster runs. Durable state that must survive a full cluster restart, such as API keys, lives in a relational database described by ./database.json. The file is generated on first run with the bundled backend, so a default install already has a working database with nothing to provision.

What persists where

StateStoreWhy
Running instances (InstanceInfo)Hazelcast IMapShared live across members; reconciled by the cluster, not the DB.
Instance configurationsFiles in ./configuration/ + Hazelcast mapAuthored on disk, loaded into the cluster at startup.
API keys (api_keys table)DatabaseMust outlive any single node and a full restart.
i
note

The database is not where you look for what is running right now. Live instance state is held in the "instances" Hazelcast map and surfaced through GET /api/instances. The relational store is for the small set of records that have to be durable, with the core system managing only the api_keys table.

database.json

database.json sits in the same working directory as the JAR and is read at startup. The provider field selects the backend; the remaining fields are connection details, and any field a given provider does not use is ignored.

FieldTypeDefaultDescription
providerstringh2Backend selector: h2, mysql, postgres, mongodb, redis.
urlstringuniverse.dbH2 only. Database filename, created under ./data/.
hoststringlocalhostServer hostname for networked backends.
portint3306Server port. Override per backend (PostgreSQL defaults to 5432).
databasestringuniverseSchema or database name on the server.
usernamestringsaConnection user.
passwordstring""Connection password.

Backends

H2, the default

H2 is an embedded, file-based store bundled in the core JAR. It runs in MySQL-compatible mode and needs no external server: the database is a file under ./data/ named by url. This is the right choice for a single-machine deployment or a first run.

{
	"provider": "h2",
	"url": "universe.db",
	"host": "localhost",
	"port": 3306,
	"database": "universe",
	"username": "sa",
	"password": ""
}

MySQL, built in

MySQL support ships in the core JAR through the bundled MariaDB driver. Point host and port at your server and supply credentials. Use this when more than one node needs the same durable records and you already run MySQL.

{
	"provider": "mysql",
	"host": "db.example.com",
	"port": 3306,
	"database": "universe",
	"username": "universe",
	"password": "changeme"
}

PostgreSQL, MongoDB, and Redis via extensions

PostgreSQL, MongoDB, and Redis are not in the core JAR. Drop the matching database extension into ./extensions/, then set provider to postgres, mongodb, or redis. The extension registers the backend at load time, so it must be present before startup.

{
	"provider": "postgres",
	"host": "db.example.com",
	"port": 5432,
	"database": "universe",
	"username": "universe",
	"password": "changeme"
}
!
warning

Selecting an extension-backed provider without the extension Jar in ./extensions/ leaves the backend unregistered and the node cannot start. Install the extension first, then change provider.

When you need more than H2

Stay on the bundled H2 backend unless one of these applies:

  • Several Masters or tools must read the same durable records and you want one shared store rather than a file per node.
  • You already operate a managed MySQL or PostgreSQL instance and prefer your existing backups and access controls.
  • An extension you run expects a specific backend (for example a Redis-backed cache or a MongoDB document store).
tip

Because only durable records (chiefly api_keys) live in the database, the storage footprint stays small. Most clusters never outgrow H2, and moving to a networked backend is a matter of editing database.json and restarting.