Skip to content

Commit 9fbf0d5

Browse files
committed
(PDB-4763) Add initial command broadcast docs
1 parent 189bb7b commit 9fbf0d5

File tree

2 files changed

+71
-12
lines changed

2 files changed

+71
-12
lines changed

documentation/configure.markdown

+70-12
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,18 @@ Replace `<HOST>` with the DB server's hostname. Replace `<PORT>` with
318318
the port on which PostgreSQL is listening. Replace `<DATABASE>` with
319319
the name of the database you've created for use with PuppetDB.
320320

321+
With this arrangemnt, PuppetDB will use the specified database for all
322+
operations (storage and queries), but PuppetDB supports other
323+
arrangments. It's possible to
324+
[specify a different read-only database](#[read-database]--settings)
325+
to among other things, handle queries, and provide responses for
326+
PuppetDB's [peer-to-peer synchronization process](#sync--settings).
327+
328+
It's also possible to specify [multiple storage databases](#broadcasting-commands)
329+
to which PuppetDB will attempt delivery of incoming information on a
330+
best-effort basis. Note that any given PuppetDB instance can have
331+
sync enabled or command broadcast, but not both.
332+
321333
#### Using SSL With PostgreSQL
322334

323335
It's possible to use SSL to protect connections to the database. There
@@ -394,6 +406,49 @@ Then specify `puppetdb_migrator` as the
394406
See the [migration coordination documentation](migration_coordination)
395407
for a more detailed explanation of the process.
396408

409+
#### Broadcasting commands to multiple databases
410+
411+
PuppetDB can be configured to attempt to send each command to multiple
412+
databases on a best-effort basis. There are no guarantees that any
413+
given command will reach all of the databases, so the process is
414+
inherently "lossy". At the moment PuppetDB will consider a command to
415+
be successfully processed as soon as it manages to send the command to
416+
at least one of the databases. Note that currently, a server cannot
417+
be configured to broadcast and [sync](#sync--settings).
418+
419+
To enable broadcast, create one `[database-NAME]` subsection for each
420+
database. For example, to attempt to send commands to a primary and
421+
secondary database, you could add something like this to your
422+
configuration:
423+
424+
[database]
425+
# When subsections are defined, unset values in any subsection will
426+
# default to the values set here.
427+
subname = //host1:5432/puppetdb
428+
username = <USERNAME1>
429+
password = <PASSWORD1>
430+
431+
[database-primary]
432+
# Settings intentionally omitted.
433+
# Unset values default to those in [database]
434+
435+
[database-secondary]
436+
subname = //host2:5432/puppetdb
437+
username = <USERNAME2>
438+
password = <PASSWORD2>
439+
440+
When subsections are defined, the `[database]` section provides
441+
defaults that will apply whenever a value is not specified in a
442+
subsection. These defaults will also be used for the read database
443+
whenever an explict [`[read-database]`]](#[read-database]--settings)
444+
isn't provided.
445+
446+
PuppetDB currently migrates multiple write databases one at a time.
447+
If you'd prefer more control over the process you can migrate
448+
databases individually by running `puppetdb upgrade -c
449+
just-one-db.ini` for each database and making sure that each command
450+
exits successfully (with non-zero status).
451+
397452
### `gc-interval`
398453

399454
This controls how often, in minutes, to compact the database. The
@@ -579,24 +634,27 @@ suggesting appropriate action. If set to zero, this check is disabled.
579634
-----
580635

581636
The `[read-database]` section configures PuppetDB's _read-database_
582-
settings, useful when running a PostgreSQL [Hot
583-
Standby](http://wiki.postgresql.org/wiki/Hot_Standby) cluster.
584-
Currently, only configuring a PostgreSQL read-database is supported. See
585-
the PostgreSQL documentation [here](http://wiki.postgresql.org/wiki/Hot_Standby)
586-
for details on configuring the cluster. The `[read-database]` portion
587-
of the configuration is in addition to the `[database]` settings. If
588-
`[read-database]` is specified, `[database]` must also be specified.
637+
settings, which can be useful if you have
638+
[set up a PostgreSQL Hot Standby](http://wiki.postgresql.org/wiki/Hot_Standby)
639+
cluster.
640+
641+
Whenever a `[read-database]` is specified, a `[database]` must also be
642+
specified to provide a write database. Whenever a `[read-database]`
643+
is not specified, the relevant read operations will be directed to the
644+
database specified in the `[database]` section, which must have all
645+
the required settings (i.e. any database subsections are irrelevant).
589646

590-
To configure PuppetDB to use a read-only database from the cluster,
591-
add the following to the `[read-database]` section:
647+
To configure PuppetDB to use a read-only database from a hot standby
648+
cluster, add the following to the configuration:
592649

650+
[read-database]
593651
subname = //<HOST>:<PORT>/<DATABASE>
594652
username = <USERNAME>
595653
password = <PASSWORD>
596654

597-
Replace `<HOST>` with the DB server's hostname. Replace `<PORT>` with
598-
the port on which PostgreSQL is listening. Replace `<DATABASE>` with
599-
the name of the database you've created for use with PuppetDB.
655+
Replace `<HOST>` with the DB server's hostname, `<PORT>` with the port
656+
on which PostgreSQL is listening, and `<DATABASE>` with the name of
657+
the database you've created for PuppetDB.
600658

601659
#### Using SSL With PostgreSQL
602660

src/puppetlabs/puppetdb/pdb_routing.clj

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
(conf/reject-large-commands? defaulted-config)
5454
(conf/max-command-size defaulted-config))
5555
"/query" (server/build-app get-shared-globals)
56+
;; FIXME: /admin/cmd read-db?
5657
"/admin" (admin/build-app enqueue-command-fn
5758
query-fn
5859
db-cfg

0 commit comments

Comments
 (0)