bihactl

bihactl — create a BiHA cluster in Postgres Pro

Synopsis

bihactl add [options]

bihactl init [options]

bihactl status [options]

bihactl -V | --version

bihactl -? | --help

Description

bihactl is a utility that allows you to create, manage, and monitor a BiHA cluster in Postgres Pro by means of the following commands:

  • bihactl init used to initialize a cluster and set the leader node. When this command is executed, bihactl accesses the initdb utility, at this stage you can also specify its parameters with the -o option.

  • bihactl add used to add follower nodes to the configured leader node. When this command is executed, a backup of the leader node is created by means of pg_basebackup or pg_probackup. The backup utility can be set with the -m option, while the parameters of the selected backup are specified with the -O option.

  • bihactl status used to check the status of cluster nodes.

The follower node can be added using a magic string saved after the bihactl init command by adding the -s option to the bihactl add command.

Important

It is not recommended to execute the bihactl commands in the PGDATA directory. The bihactl utility may create the biha_init.log and biha_add.log files in the directory where it is executed. However, the target PGDATA directory must be empty for proper execution of the bihactl commands.

Command-Line Reference #

add #

Syntax:

bihactl add [-c | --convert-standby]
            [-D | --pgdata=datadir]
            [-f | --magic-file=magic_file]
            [-h | --host=host]
            [-I | --biha-node-id=node_id]
            [-l | --use-leader=conn_info]
            [-m | --backup-method=backup_method]
            [-O | --backup-options=backup_options]
            [-p | --port=port]
            [-P | --biha-port=biha_port]
            [-r | --mode=node_mode]
            [-s | --magic-string=magic_string]

Add a follower node to the initialized cluster. This command can take the following options:

-c
--convert-standby

Converts an existing node to make it a follower node in the high-availability cluster. The node should be a leader node replica prior to the conversion.

-D datadir
--pgdata=datadir

Specifies the directory where the database cluster should be stored.

-f magic_file
--magic-file=magic_file

Uses a magic file that contains encoded data to connect to the leader node.

-h host
--host=host

Specifies the node host for incoming connections.

-I node_id
--biha-node-id=node_id

Specifies the unique ID of the node.

-l conn_info
--use-leader=conn_info

Specifies parameters to connect to the leader node in the following format:

host=leader_host port=leader_port biha-port=leader_biha_port

-m backup_method
--backup-method=backup_method

Specifies the backup utility. The allowed values are pg_basebackup and pg_probackup. The default value is pg_basebackup, which is the only value that can be used when adding the referee node.

-O backup_options
--backup-options=backup_options

Specifies additional options of pg_basebackup or pg_probackup depending on the backup utility specified in the --backup-method option.

-p port
--port=port

Specifies the node port for incoming connections. If the port is not specified, it is taken from postgresql.conf or set to default. The default value is 5432.

-P biha_port
--biha-port=biha_port

Specifies the port used to exchange service information between nodes. If not specified, the value is set to port + 1.

-r node_mode
--mode=node_mode

Specifies the operation mode of the node. The allowed values are as follows:

  • regular — the node can operate as the leader or as the follower. This is the default value.

  • referee — the node only participates in the leader elections and does not contain any user databases.

  • referee_with_wal — the node participates both in the leader elections in the same way as in the referee mode and receives the entire WAL from the leader node.

-s magic_string
--magic-string=magic_string

Uses a magic string that contains encoded data to connect to the leader node.

init #

Syntax:

bihactl init [-C | --convert]
             [-D | --pgdata=datadir]
             [-f | --magic-file=magic_file]
             [-h | --host=host]
             [-I | --biha-node-id=node_id]
             [-M | --minnodes=min_node_num]
             [-N | --nquorum=quorum_value]
             [-o | --options=initdb_options]
             [-p | --port=port]
             [-P | --biha-port=biha_port]
             [-S | --use-ssl]
             [-Y | --sync-standbys=sync_standbys_num]
             [-y | --sync-standbys-min=sync_standbys_min_num]

Initialize a cluster and set the leader node. This command can take the following options:

-C
--convert

Converts an existing node to make it the leader node in the high-availability cluster.

-D datadir
--pgdata=datadir

Specifies the directory where the database cluster should be stored.

-f magic_file
--magic-file=magic_file

Uses a magic file that contains encoded data to connect to the leader node.

-h host
--host=host

Specifies the node host for incoming connections.

-I node_id
--biha-node-id=node_id

Specifies the unique ID of the node.

-M min_node_num
--minnodes=min_node_num

Specifies the minimum number of operational nodes for the leader node to be open for write transactions. If not specified, the value equals the nquorum value.

-N quorum_value
--nquorum=quorum_value

Specifies the number of operational nodes participating in the leader election. It is recommended that this value should be greater than a half of the number of nodes in the cluster so that the leader node can be elected by simple majority. For example, if you intend to have a cluster with 5 nodes, set the quorum value to 3.

-o initdb_options
--options=initdb_options

Specifies additional options of initdb.

-p port
--port=port

Specifies the node port for incoming connections. If the port is not specified, it is taken from postgresql.conf or set to default. The default value is 5432.

-P biha_port
--biha-port=biha_port

Specifies the port used to exchange service information between nodes. If not specified, the value is set to port + 1.

-S
--use-ssl

Enables the protected mode of the service information exchange between cluster nodes with SSL/TLS over the biha control channel.

-Y sync_standbys_num
--sync-standbys=sync_standbys_num

Specifies the number of synchronous follower nodes to connect to the leader node. It is recommended that this value should be less than the value of the --minnodes option.

-y sync_standbys_min_num
--sync-standbys-min=sync_standbys_min_num

Specifies the minimum number of synchronous follower nodes that must be available for the leader node to continue operation. The value must be lower than --sync-standbys and cannot be negative. If the option is not specified, the BiHA cluster operates according to the default synchronous replication restrictions, i.e., the leader node is not available for write transactions until all followers catch up with its current state.

status #

Syntax:

bihactl status [-f | --magic-file=magic_file]
               [-h | --host=host]
               [-p | --port=port]
               [-s | --magic-string=magic_string]

Check the node status. This command can take the following options:

-f magic_file
--magic-file=magic_file

Uses a magic file that contains encoded data to connect to the leader node.

-h host
--host=host

Specifies the node host for incoming connections.

-p port
--port=port

Specifies the node port for incoming connections. If the port is not specified, it is be taken from postgresql.conf or set to default. The default value is 5432.

-s magic_string
--magic-string=magic_string

Uses a magic string that contains encoded data to connect to the leader node.

-V | --version #

Syntax:

bihactl -V
bihactl --version

Display the current version of the high-availability cluster.

-? | --help #

Syntax:

bihactl -?
bihactl --help

Display command-line help.