Repository navigation
Configuration
There are three layers of configuration: the settings of kingresd (the control plane), the PostgreSQL parameters of the servers (managed from the console), and the settings of the extensions (PostgreSQL parameters with a kingres_shard. or similar prefix). This page covers the first two and points to the third.
Precedence, lowest to highest: built-in default, the JSON config file (-config or KINGRES_CONFIG), an environment variable, a command-line flag. The keys of the config file are the flag names. Unknown keys and invalid values stop the server at start. The package's unit reads /etc/kingres/kingresd.json and /etc/kingres/kingresd.env; the env file is readable by root only, so put secrets there, not in the JSON file.
The package's default file:
{
"listen": "127.0.0.1:8091",
"data-dir": "/var/lib/kingres",
"pg-bin-dir": "/opt/kingres/bin",
"socket-dir": "/run/kingres",
"pg-port": 5432,
"pg-listen": "127.0.0.1",
"log-format": "text",
"log-level": "info"
}The main settings (the full table, with timeouts and limits, is in the control-plane README):
| File key | Environment variable | Default | Meaning |
|---|---|---|---|
config |
KINGRES_CONFIG |
none | path of the JSON config file (a flag only, not a file key) |
listen |
KINGRES_LISTEN |
127.0.0.1:8091 |
address of the REST API and the panel |
pg-dsn |
KINGRES_PG_DSN |
host=127.0.0.1 port=5432 dbname=postgres |
DSN of the local map-group instance; its database holds the cluster catalog. May contain a password, so it is a secret and is never logged |
tls-cert-file, tls-key-file
|
KINGRES_TLS_CERT_FILE, KINGRES_TLS_KEY_FILE
|
none | enable HTTPS (both or neither) |
data-dir |
KINGRES_DATA_DIR |
kingresd-data (the package sets /var/lib/kingres) |
node state, setup token, audit log |
pg-bin-dir |
KINGRES_PG_BIN_DIR |
none | directory of postgres, initdb, pg_ctl, pg_config
|
socket-dir |
KINGRES_SOCKET_DIR |
<data-dir>/run |
base directory of the unix sockets of the instances; never /tmp
|
pg-port, pg-listen
|
KINGRES_PG_PORT, KINGRES_PG_LISTEN
|
5432, 127.0.0.1
|
port and listen_addresses of the managed instance. In a cluster of several servers pg-listen must include the address the other servers reach this one at |
internal-listen |
KINGRES_INTERNAL_LISTEN |
empty (off) | mutual-TLS listener of the internal server-to-server API. Required to join, add or remove servers and for forwarding. By convention the REST port plus one |
server-host |
KINGRES_SERVER_HOST |
machine host name | the name this server is registered under; it is the server id and a name of its certificate |
allow-remote-setup |
KINGRES_ALLOW_REMOTE_SETUP |
false |
allow setup calls from non-loopback addresses while uninitialized (the setup token is still required) |
session-ttl, max-sessions
|
KINGRES_SESSION_TTL, KINGRES_MAX_SESSIONS
|
8h, 10000
|
session lifetime and bound |
login-rate-limit, login-rate-window
|
KINGRES_LOGIN_RATE_LIMIT, KINGRES_LOGIN_RATE_WINDOW
|
10, 1m
|
login attempts per client address and per user name per window |
metrics-token |
KINGRES_METRICS_TOKEN |
none | bearer token that may scrape /metrics
|
log-level, log-format
|
KINGRES_LOG_LEVEL, KINGRES_LOG_FORMAT
|
info, text
|
debug to error; text or json
|
ledger-keys-dir |
KINGRES_LEDGER_KEYS_DIR |
<data-dir>/ledger/keys |
private ledger signing keys |
ledger-key-passphrase-file |
KINGRES_LEDGER_KEY_PASSPHRASE_FILE |
none | file with the passphrase that seals the key files; never read from the environment or the command line |
ledger-publication-listen |
KINGRES_LEDGER_PUBLICATION_LISTEN |
empty (off) | listener that serves the published ledger without authentication |
ledger-publication-tls-cert, ledger-publication-tls-key
|
KINGRES_LEDGER_PUBLICATION_TLS_CERT, KINGRES_LEDGER_PUBLICATION_TLS_KEY
|
none | TLS for that listener |
More settings of kingresd, all with an environment variable of the same name in upper case with KINGRES_ and underscores (the README has the complete table):
| File key | Default | Meaning |
|---|---|---|
audit-file |
<data-dir>/audit.jsonl |
append-only audit log |
read-header-timeout, read-timeout, write-timeout, idle-timeout
|
10s, 30s, 60s, 120s
|
HTTP server timeouts |
request-timeout, shutdown-timeout
|
30s, 15s
|
processing time of one API request; graceful shutdown |
max-body-bytes |
1048576 |
request body limit |
certificate-lifetime |
8760h |
validity of server certificates signed by this server (at least 5s) |
certificate-renew-fraction |
0.3333 |
renew when less than this part of the lifetime is left (above 0, at most 0.9) |
certificate-check-interval, certificate-retry-interval
|
1h, 1m
|
how often the renewal job looks; pause after a failed renewal (doubles up to the check interval) |
monitor-interval |
10s |
health checks and the metric sampler |
ledger-pending-max-age |
5m |
age of the oldest pending ledger transaction that raises ledgerPendingTooOld
|
version-check-interval |
1m |
how often the manager leader compares server versions (versionMismatch) |
gather-timeout |
3s |
time one server gets to answer its part of a cluster-wide read of logs, alerts or metrics |
rebalance-retry-backoff |
30s |
a failed rebalance move is tried again after this time times its failures, up to three tries |
partition-scheduler-interval |
1m |
how often the time-partition scheduler runs on the manager leader |
transfer-dir |
<data-dir>/transfer |
staging directory of the CSV table transfer; refused when it is not empty and not its own, or is or holds a data directory |
transfer-key-file |
<data-dir>/transfer.key |
file (mode 0600) with the master key that seals the staged files; created at first use |
transfer-max-duration |
24h |
longest time of one transfer task |
max-atomic-bytes |
2 GiB |
largest decompressed CSV file a table import accepts (the import is one transaction) |
max-import-bytes |
100 GiB |
largest sum of the entry sizes of a database archive that a database import accepts |
fault-dir |
empty (off) | tests only: fault-injection hook; leave it unset |
Failover timings (high availability; see High Availability):
| File key | Environment variable | Default | Meaning |
|---|---|---|---|
heartbeat-interval |
KINGRES_HEARTBEAT_INTERVAL |
1s |
heartbeat to every other server; at most half of suspect-timeout
|
suspect-timeout |
KINGRES_SUSPECT_TIMEOUT |
5s |
silence after which a server is suspect
|
failure-timeout |
KINGRES_FAILURE_TIMEOUT |
10s |
silence after which a server is dead
|
lease-duration |
KINGRES_LEASE_DURATION |
10s |
validity of a lease from the start of its round |
lease-renew |
KINGRES_LEASE_RENEW |
2s |
how often the holder renews |
lease-margin |
KINGRES_LEASE_MARGIN |
3s |
the grantor waits it after expiry, the holder fences that long before |
leader-loss-bound |
KINGRES_LEADER_LOSS_BOUND |
30s |
how long a server that cannot hear the manager leader keeps authorizing sessions from its own copy of roles and grants |
admin-keys-max-age |
KINGRES_ADMIN_KEYS_MAX_AGE |
72h |
how old the cache of the administrators' keys may be before declaring a server lost refuses it |
standby-sync-grace |
KINGRES_STANDBY_SYNC_GRACE |
30s |
how long no standby may stream before the group stops waiting for it |
standby-replace-after |
KINGRES_STANDBY_REPLACE_AFTER |
30m |
how long the record of an old primary whose server does not answer counts as a planned standby before a replacement is made elsewhere |
slot-retention-warn-bytes |
KINGRES_SLOT_RETENTION_WARN_BYTES |
1073741824 |
WAL a standby's slot may retain before replicationLagHigh is raised |
slot-retention-limit-bytes |
KINGRES_SLOT_RETENTION_LIMIT_BYTES |
4294967296 |
WAL a slot may retain before it is dropped and the standby rebuilt |
standby-port-base, standby-port-end
|
KINGRES_STANDBY_PORT_BASE, KINGRES_STANDBY_PORT_END
|
pg-port + 1000, base + 499 |
range of ports tried for a new standby instance |
allow-no-watchdog |
KINGRES_ALLOW_NO_WATCHDOG |
false |
tests and development only: start without the lease watchdog program kingres-watchdog
|
The lease settings must be the same on every server; a failover is refused with lease_settings_differ otherwise.
Client entry point (off unless set): client-listen (KINGRES_CLIENT_LISTEN, to the primary), client-standby-listen (KINGRES_CLIENT_STANDBY_LISTEN, to a local standby for lag-tolerant reads), client-max-connections (1000), client-connect-timeout (5s), client-idle-timeout (1h).
Other flags: -config (above), -version prints the version, the contract revision and the build commit; -stop-instances stops the managed instances with a fast shutdown and exits; -h lists the flags. A directory in pg-bin-dir that is not a KingresDB build of PostgreSQL 18 or 19 stops the server. Unset, it uses the directory of the binary, then PATH; with none found instance management is off and init-cluster answers 422.
Where the settings are used: Cluster Setup (a server of a cluster needs server-host, internal-listen and pg-listen), Installing and Packaging (the package files) and Upgrades (a package upgrade keeps the files you changed).
The role in the pg-dsn is the service role; it needs CONNECT, SELECT on the kingres schema and membership in pg_monitor. It is not used to authenticate users.
Configuration from the console is built. The design is config-phase13.md.
Every parameter that the control plane does not own can be set at four levels: the whole cluster, a server group, one server, and a database. The server, group and cluster levels are rendered into one file per instance; a narrower level beats a wider one (server over serverGroup over cluster over postgresql.conf over the built-in default). The database level is ALTER DATABASE ... SET with PostgreSQL's own precedence.
A change is validated against what PostgreSQL says about the parameter (type, range, unit, enum, and, for the parameters of a loaded extension, a check inside a rolled-back transaction), previewed, and applied as a task with a step per server. A parameter that needs a restart is shown as pending until the instance restarts. History and revert are kept.
Some parameters are managed by kingresd and are refused with config_parameter_managed: addresses and ports, shared_preload_libraries, the TLS files, password_encryption, the log settings, the standby connection parameters, synchronous_commit (kept per database), wal_level and the file locations. A value below a floor that protects kingresd is refused with config_value_below_floor (for example max_prepared_transactions below 1). Superuser-only parameters are refused.
The REST operations are /config/parameters, /config/parameters/{name}, /config/changes/preview, /config/changes, /config/changes/{changeId}/revert, /config/servers, /config/summary, /config/time, /config/time-zones and /config/restarts. The console has a Configuration page with a Time tab. The control plane does not set the system clock: it measures and reports the difference between the servers' clocks and alerts when it is too large; time synchronization is the job of NTP or chrony. See Control Plane and REST API and Web Console.
-
kingres_shard.*: for examplekingres_shard.default_bucket_count(default 128), and the switches of the faster read and write paths such askingres_shard.enable_pushdown. See Sharding and Sharding Query Pushdown. -
kingres_ledger.*: see Ledger. -
kingres_sketch,kingres_timepartandkingres_columnar(for example the memory limits of the sketch aggregates): see Analytics Extensions.
Every GUC of an extension carries the extension's prefix.
KingresDB's own code is licensed under AGPL-3.0-only. PostgreSQL code keeps the PostgreSQL License. Copyright of the project's own code: RooyeKhat Media Co. KingresDB is derived from PostgreSQL and is not endorsed by the PostgreSQL project. Repository | Licence | COPYRIGHT
KingresDB
1. Product
- Product Overview and Features
- Status and Roadmap
- User Guide
- Administrator Guide
- REST API Reference
- Web Console
- Command Line Client
- Extensions
- Limitations and Known Issues
- Release Notes
Features in detail
- Sharding
- Sharding Query Pushdown
- Sharding Table Lifecycle
- High Availability
- Ledger
- Ledger Signing and Publication
- Ledger Anchoring
- The Verifier
- Analytics Extensions
Administration
- Cluster Setup
- Servers Databases and Roles
- Rebalancing
- Configuration
- Memory and Warm-up
- Control Plane and REST API
- Upgrades
2. Architecture (arc42)
- Architecture
- Architecture Introduction and Goals
- Architecture Constraints
- Architecture System Context
- Architecture Containers
- Architecture Components
- Architecture Runtime Views Sharding
- Architecture Runtime Views Availability and Ledger
- Architecture Deployment
- Architecture Crosscutting Concepts
- Security Model
- Architecture Decisions
- Architecture Quality Requirements
- Architecture Risks and Technical Debt
- Enterprise Architecture
3. Data architecture
- Data Architecture
- Data Model Sharding
- Data Model Ledger
- Data Model System Database
- Data Model Analytics
- Data Lifecycle
- Backup Restore and PITR
- Data Security
- Data Quality and Integrity
4. Development
- Building from Source
- Development and Testing
- Repository Layout
- Coding Standards
- Branching and Synchronisation
- Testing Strategy
- Review Process
- Release Process
- Contributing
5. Operations