harpctl command-line tool v3.7
harpctl
is a command-line tool for directly manipulating the consensus layer
contents to fit desired cluster geometry. You can use it to, for example, examine node
status, "promote" a node to lead master, disable/enable cluster management,
bootstrap cluster settings, and so on.
Synopsis
In addition to this basic synopsis, each of the available commands has its own series of allowed subcommands and flags.
Configuration
harpctl
must interact with the consensus
layer to operate. This means a certain minimum amount of settings must be
defined in config.yml
for successful execution. This includes:
dcs.driver
dcs.endpoints
cluster.name
As an example using etcd:
See Configuration for details.
Execution
Execute harpctl
like this:
Each command has its own series of subcommands and flags. Further help for these are available by executing this command:
harpctl apply
You must use an apply
command to "bootstrap" a HARP cluster using a
file that defines various attributes of the intended cluster.
Execute an apply
command like this:
This essentially creates all of the initial cluster metadata, default or custom management settings, and so on. This is done here because the DCS is used as the ultimate source of truth for managing the cluster, and this makes it possible to change these settings dynamically.
This can either be done once to bootstrap the entire cluster, once per type of object, or even on a per-node basis for the sake of simplicity.
This is an example of a bootstrap file for a single node:
As seen here, it is good practice to always include a cluster name preamble to ensure all changes target the correct HARP cluster, in case several are operating in the same environment.
Once apply
completes without error, the node is integrated with the rest
of the cluster.
Note
You can also use this command to bootstrap the entire cluster at once since all defined sections are applied at the same time. However, we don't encourage this use for anything but testing as it increases the difficulty of validating each portion of the cluster during initial definition.
harpctl fence
Marks the local or specified node as fenced. A node with this status is essentially completely excluded from the cluster. HARP Proxy doesn't send it traffic, its representative HARP Manager doesn't claim the lead master lease, and further steps are also taken. If running, HARP Manager stops Postgres on the node as well.
Execute a fence
command like this:
The node-name is optional; if omitted, harpctl
uses the name of
the locally configured node.
harpctl get
Fetches information stored in the consensus layer for various elements of the cluster. This includes nodes, locations, the cluster, and so on. The full list includes:
cluster
— Returns the cluster state.leader
— Returns the current or specified location leader.location
— Returns current or specified location information.locations
— Returns list of all locations.node
— Returns the specified Postgres node.nodes