NEW RasterizedDB 1.1.0 is out: sharding and the gateway, the message broker, roles and row-level security, compression, .NET on NuGet, and the enterprise edition. What's new ›
DOCS / ENTERPRISE / ENTERPRISE CONFIGURATION

Enterprise configuration

This is the reference for the enterprise server's configuration file (--enterprise-config), the files it keeps, the enterprise gateway's flags, and the gateway's routes file. Use it when you write or check a configuration; the task pages (Tenants, Data segregation, Per-user shards) show the settings in use.

The enterprise server's file

The server reads the file named by --enterprise-config FILE once, at start, before it accepts a connection. A change needs a restart.

Format

  • One setting per line: a directive, then its arguments, separated by spaces or tabs.
  • # starts a comment, anywhere on a line. A value can therefore never contain #.
  • Blank lines are ignored.
  • Directive names and fixed words (strict, require, exclusive, the limit names) are lower case and matched exactly.
  • An unknown directive, a wrong number of arguments or a bad value stops the server with exit code 2: --enterprise-config: <file>: line <n>: <reason>: "<line>".

Directives

DirectiveArgumentsDefaultWhat it does
tenant_modestrict or offoffstrict turns on strict tenant mode (Tenants). The later of two lines wins.
operator_databasea database namerasterizeddbUnder strict tenant mode, the database whose superusers administer the whole server. Set it to the server's default database (--pg-default-db, postgres unless you changed it): see the note below.
limit<database> connections <n>noneUnder strict tenant mode, at most n open sessions in that database. Checked when a PostgreSQL-protocol connection logs in.
limit<database> statement_timeout_ms <n>noneUnder strict tenant mode, the statement timeout a PostgreSQL-protocol session of that database starts with, in milliseconds.
limit<database> max_bytes <n>noneUnder strict tenant mode, a storage limit in bytes. Recorded and shown by SHOW TENANTS when set there, but not enforced.
tenants_filea file pathnoneWhere CREATE TENANT keeps the tenant directory. Without it, CREATE TENANT, ALTER TENANT and DROP TENANT are refused.
outbound_hostsone or more hostsnone (no restriction)Under strict tenant mode, the only hosts the server connects out to. Each entry is host, host:port or *.suffix. Several lines add up.
shard_labels<shard id> <key=value> …noneThe labels shard <shard id> carries, for placement policies. A second line for the same shard replaces the first.
policy<name> <lo> <hi> require <key=value> … [exclusive]noneA placement policy over the blocks [lo, hi) (Data segregation).
pinned_role<database> <role>noneA per-user-shard role this shard hosts, fixed for the run (Per-user shards). Repeat the line for more.
pinned_roles_filea file pathnoneA list of hosted per-user-shard roles that SHARD HOST ROLE and SHARD UNHOST ROLE change at run time. Without it those statements are refused.

Which settings act when:

  • operator_database, limit, tenants_file and outbound_hosts take effect only with tenant_mode strict. Without it they are read and checked but do nothing.
  • shard_labels and policy take effect whenever the file is given, on a server started as a shard (--role shard). On a server that is not a shard they do nothing.
  • pinned_role and pinned_roles_file take effect whenever the file is given.

Set operator_database explicitly. Its default, rasterizeddb, is not the server's default database (postgres). Left at the default, no session is a process administrator under strict tenant mode, so nobody can create databases or tenants, change settings or run SHARD statements, and the Redis-compatible port (which serves the default database) refuses everyone. The enterprise gateway's configuration API also runs its statements in postgres.

Values

  • Block numbers (policy's lo and hi): decimal (140737488355328) or hexadecimal with 0x (0x800000000000). lo must be less than hi. The key space is [0, 0x1000000000000).
  • Labels: key=value, with no spaces. A shard carries a policy's label only when its shard_labels line lists exactly that key=value.
  • exclusive counts only as the last word of a policy line.
  • limit numbers: whole numbers. connections must fit in 32 bits.
  • outbound_hosts entries are compared without case and without a trailing dot. host allows every port, host:port only that port, and *.example.com any name ending in .example.com (not example.com itself). An IP address is written as a host.
  • Paths are used as written; a relative path is relative to the server's working directory.

An annotated example

This file is for shard 1 of a three-shard cluster that runs a database-as-a-service platform. Every shard can share the same file; only the labels of its own shard id matter to a shard.

text
# --- strict tenant mode -------------------------------------------------
tenant_mode strict
# The server's default database (--pg-default-db). Only its superusers
# administer the process.
operator_database postgres
# CREATE TENANT keeps its directory here.
tenants_file /var/lib/rasterizeddb/rdb_tenants

# Limits for databases made without CREATE TENANT (a tenant's own limits,
# set by CREATE/ALTER TENANT, replace these for that database).
limit acme connections 50
limit acme statement_timeout_ms 60000
limit acme max_bytes 21474836480

# The server may connect out only to these: the PostgreSQL server imports
# come from, the S3 endpoint on port 9000, and any AWS host.
outbound_hosts pg-legacy.internal
outbound_hosts s3.internal:9000 *.amazonaws.com

# --- placement ----------------------------------------------------------
# Each shard's labels.
shard_labels 0 region=us-east
shard_labels 1 region=eu-west tier=dedicated
shard_labels 2 region=eu-west

# Blocks [0, 0x800000000000) only on shards in eu-west, and those shards
# hold no range that no policy covers.
policy eu_only 0x0 0x800000000000 require region=eu-west exclusive

# --- per-user shards ----------------------------------------------------
# A role hosted on this shard for good.
pinned_role acme alice
# Roles added and removed at run time by SHARD HOST ROLE / SHARD UNHOST ROLE.
pinned_roles_file /var/lib/rasterizeddb/rdb_pinned_roles

Files the server keeps

The tenant directory (tenants_file)

One line per tenant, five fields separated by spaces:

text
acme acme_admin 50 21474836480 60000
globex globex_admin - - 30000

The fields are the tenant (its database name), its owner role, the connection limit, the storage limit in bytes and the statement timeout in milliseconds. - means no limit. The server reads the file at start, and rewrites it whole (written to <file>.tmp, synced, renamed into place) on every CREATE TENANT, ALTER TENANT and DROP TENANT. A missing file is an empty directory. Change it with those statements rather than by hand; a malformed line stops the server at start.

The file is not part of any database: back it up with the configuration file.

The hosted roles (pinned_roles_file)

One database role pair per line; # starts a comment:

text
# per-user-shard roles this shard hosts (SHARD HOST ROLE); database role
acme app
globex svc

SHARD HOST ROLE and SHARD UNHOST ROLE rewrite it whole (to <file>.tmp, synced, renamed, then the directory synced) before the change takes effect, so a restart never admits less or more than the server did before it. A missing file is an empty list. The roles of pinned_role lines are hosted as well and are not written to the file.

The enterprise gateway

The enterprise gateway takes the GPL gateway's whole configuration: --config FILE with key = value lines, and --key=value flags over it. See Gateway configuration for every key. The keys that matter most to the enterprise features are:

Gateway keyDefaultEnterprise use
user_routingoffprefer or require turns per-user routes on. With off every route is ignored.
adminoffhost:port of the metrics endpoint, which gains a line per client and measure.
api_listen, api_token_file, config_diroffThe configuration API, which gains the routes, customers and clients paths (Per-user shards). With config_dir and no --user-routes, routes are kept in the configuration store.

Enterprise flags

These are read by the enterprise gateway itself. Each takes its value as the next argument (--user-routes FILE, never --user-routes=FILE). Everything else on the command line goes to the gateway.

FlagDefaultWhat it does
--user-routes FILEnonePer-user routes from this file (below). Checked every 5 seconds; a change applies at each role's next login.
--user-routes-requireoffA login with no route is refused. Needs --user-routes or config_dir.
--client-stats on|offonKeep per-client statistics.
--client-stats-roles ROLE[,ROLE…]noneThe roles that may run SHOW CLIENT STATS, SHOW CLIENT STATS HISTORY and RESET CLIENT STATS. With none, nobody may (a warning is logged at start).
--client-stats-max-clients N4096How many clients are tracked apart. Past it, new clients are counted together as one (other) row.
--client-stats-dir DIRnoneKeep the statistics' history in an embedded RasterizedDB in DIR. Needs the statistics on. Ignored (with a warning) when config_dir is set: the history is then kept in the configuration store.
--client-stats-flush-secs N60How often an interval of the history is written, in seconds.
--client-stats-retention-hours N168How long the history keeps intervals, in hours.
--api-shard-role ROLErasterizedThe role the configuration API's customer provisioning runs as on a shard. It must be a superuser of each shard's operator database.

The history (from --client-stats-dir or the configuration store) is kept automatically whenever the statistics are on and one of the two is set.

The routes file

One route per line: a database, a role and a shard id, or the word refuse in place of the shard. # starts a comment.

text
# database  role        shard
acme        acme_app    1
acme        acme_admin  1
globex      globex_app  2
# This login may not use the gateway at all.
globex      intern      refuse
  • A login is the database and role a client names at connection. Both are compared exactly as written.
  • refuse turns the login away after its password is checked, with 28000 and role "<role>" may not log in to "<database>" through this gateway.
  • A line that does not have exactly three fields, or whose shard is not a number, makes the file invalid. At start the gateway stops; on a later change it logs user routes not reloaded, the old ones stay and keeps the routes it had.
  • The shard ids should be in the shard map. The file is not checked against the map.
  • The gateway checks the file's modification time every 5 seconds and rereads it when it changed. Open sessions keep the shard they logged in to; a changed route applies at that role's next login.

Limits

  • The server's file is read only at start; there is no reload.
  • max_bytes (and storage in CREATE TENANT) is not enforced.
  • outbound_hosts applies to every outbound connection the server makes for imports and S3, the operator's own included.
✓ page rendered in 125 µs axum + tera + htmx · no other javascript