Skip to content

Commit c1af83c

Browse files
committed
(PDB-4763) Add initial command broadcast docs
1 parent fb015c1 commit c1af83c

File tree

2 files changed

+73
-12
lines changed

2 files changed

+73
-12
lines changed

documentation/configure.markdown

+72-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,51 @@ 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+
# Currently required
431+
migrate = false
432+
433+
[database-primary]
434+
# Settings intentionally omitted.
435+
# Unset values default to those in [database]
436+
437+
[database-secondary]
438+
subname = //host2:5432/puppetdb
439+
username = <USERNAME2>
440+
password = <PASSWORD2>
441+
442+
When subsections are defined, the `[database]` section provides
443+
defaults that will apply whenever a value is not specified in a
444+
subsection. These defaults will also be used for the read database
445+
whenever an explict [`[read-database]`]](#[read-database]--settings)
446+
isn't provided.
447+
448+
PuppetDB currently migrates multiple write databases one at a time.
449+
If you'd prefer more control over the process you can migrate
450+
databases individually by running `puppetdb upgrade -c
451+
just-one-db.ini` for each database and making sure that each command
452+
exits successfully (with non-zero status).
453+
397454
### `gc-interval`
398455

399456
This controls how often, in minutes, to compact the database. The
@@ -579,24 +636,27 @@ suggesting appropriate action. If set to zero, this check is disabled.
579636
-----
580637

581638
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.
639+
settings, which can be useful if you have
640+
[set up a PostgreSQL Hot Standby](http://wiki.postgresql.org/wiki/Hot_Standby)
641+
cluster.
642+
643+
Whenever a `[read-database]` is specified, a `[database]` must also be
644+
specified to provide a write database. Whenever a `[read-database]`
645+
is not specified, the relevant read operations will be directed to the
646+
database specified in the `[database]` section, which must have all
647+
the required settings (i.e. any database subsections are irrelevant).
589648

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

652+
[read-database]
593653
subname = //<HOST>:<PORT>/<DATABASE>
594654
username = <USERNAME>
595655
password = <PASSWORD>
596656

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.
657+
Replace `<HOST>` with the DB server's hostname, `<PORT>` with the port
658+
on which PostgreSQL is listening, and `<DATABASE>` with the name of
659+
the database you've created for PuppetDB.
600660

601661
#### Using SSL With PostgreSQL
602662

src/puppetlabs/puppetdb/pdb_routing.clj

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

0 commit comments

Comments
 (0)