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
| Directive | Arguments | Default | What it does |
|---|---|---|---|
tenant_mode | strict or off | off | strict turns on strict tenant mode (Tenants). The later of two lines wins. |
operator_database | a database name | rasterizeddb | Under 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> | none | Under 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> | none | Under strict tenant mode, the statement timeout a PostgreSQL-protocol session of that database starts with, in milliseconds. |
limit | <database> max_bytes <n> | none | Under strict tenant mode, a storage limit in bytes. Recorded and shown by SHOW TENANTS when set there, but not enforced. |
tenants_file | a file path | none | Where CREATE TENANT keeps the tenant directory. Without it, CREATE TENANT, ALTER TENANT and DROP TENANT are refused. |
outbound_hosts | one or more hosts | none (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> … | none | The 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] | none | A placement policy over the blocks [lo, hi) (Data segregation). |
pinned_role | <database> <role> | none | A per-user-shard role this shard hosts, fixed for the run (Per-user shards). Repeat the line for more. |
pinned_roles_file | a file path | none | A 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_fileandoutbound_hoststake effect only withtenant_mode strict. Without it they are read and checked but do nothing.shard_labelsandpolicytake 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_roleandpinned_roles_filetake 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'sloandhi): decimal (140737488355328) or hexadecimal with0x(0x800000000000).lomust be less thanhi. The key space is[0, 0x1000000000000). - Labels:
key=value, with no spaces. A shard carries a policy's label only when itsshard_labelsline lists exactly thatkey=value. exclusivecounts only as the last word of apolicyline.limitnumbers: whole numbers.connectionsmust fit in 32 bits.outbound_hostsentries are compared without case and without a trailing dot.hostallows every port,host:portonly that port, and*.example.comany name ending in.example.com(notexample.comitself). 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.
# --- 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_rolesFiles the server keeps
The tenant directory (tenants_file)
One line per tenant, five fields separated by spaces:
acme acme_admin 50 21474836480 60000
globex globex_admin - - 30000The 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:
# per-user-shard roles this shard hosts (SHARD HOST ROLE); database role
acme app
globex svcSHARD 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 key | Default | Enterprise use |
|---|---|---|
user_routing | off | prefer or require turns per-user routes on. With off every route is ignored. |
admin | off | host:port of the metrics endpoint, which gains a line per client and measure. |
api_listen, api_token_file, config_dir | off | The 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.
| Flag | Default | What it does |
|---|---|---|
--user-routes FILE | none | Per-user routes from this file (below). Checked every 5 seconds; a change applies at each role's next login. |
--user-routes-require | off | A login with no route is refused. Needs --user-routes or config_dir. |
--client-stats on|off | on | Keep per-client statistics. |
--client-stats-roles ROLE[,ROLE…] | none | The 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 N | 4096 | How many clients are tracked apart. Past it, new clients are counted together as one (other) row. |
--client-stats-dir DIR | none | Keep 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 N | 60 | How often an interval of the history is written, in seconds. |
--client-stats-retention-hours N | 168 | How long the history keeps intervals, in hours. |
--api-shard-role ROLE | rasterized | The 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.
# 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.
refuseturns the login away after its password is checked, with28000androle "<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 stayand 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(andstorageinCREATE TENANT) is not enforced.outbound_hostsapplies to every outbound connection the server makes for imports and S3, the operator's own included.