bihactl — create a BiHA cluster in Postgres Pro
bihactl add --biha-node-id= node_id--host= [hostoptions]
bihactl init --biha-node-id= node_id--nquorum= quorum_value--host= [hostoptions]
bihactl status [options]
bihactl -V | --version
bihactl -? | --help
bihactl is a command line utility that allows creating a BiHA cluster, changing its composition, as well as monitoring the cluster status and version. For more information about the BiHA solution, see Built-in High Availability (BiHA).
This section contains information about the bihactl utility commands:
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.
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.
For servers with the Elbrus CPU architecture, execute
bihactl commands using the
rtc 4.3 binary compiler.
For example, to execute bihactl init,
add the rtc prefix with its options:
rtc --path_prefix / -- bihactl init -D node --port=5432 --biha-port=15432
Syntax:
bihactl add --biha-node-id=node_id--host=host{--use-leader=conn_info| --magic-string=magic_string| --magic-file=magic_file} [--convert-standby] [--pgdata=datadir] [--port=port] [--biha-port=biha_port] [--backup-method=backup_method] [--backup-options=backup_options] [--mode=node_mode] [--referee-with-postgres-db]]
Adds a follower node to the initialized cluster. When this command is
executed, a backup of the leader node is created by means of
pg_basebackup or pg_probackup.
When you add a node, bihactl keeps the replication
slot by calling pg_basebackup with the
--slot=
parameters and pg_probackup with the
SLOT_NAME, --wal-method=stream, --checkpoint=fast--stream --slot= parameters that prevents
deletion of WAL on the leader during backup.
SLOT_NAME
You must add nodes one by one. Do not add a new node if creation of a previously added
node has not been completed yet and the node is in the CSTATE_FORMING
state. Otherwise, you may encounter the following error:
WARNING: aborting backup due to backend exiting before pg_backup_stop was
called
The backup utility can be set with the -m option,
while the parameters of the selected backup are specified with the
-O option.
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. If
not specified, bihactl uses the
PGDATA value.
-f magic_file--magic-file=magic_file #
Specifies the path to the magic file that contains encoded data to connect to the leader
node. The file must exist when you execute the
bihactl add command.
-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_hostport=leader_portbiha-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. If you do not
specify the --backup-method option, the default
backup method is used. The pg_basebackup
utility 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 not specified:
When converting the existing cluster using
--convert-standby,
bihactl uses the PGPORT value.
When creating a BiHA cluster from scratch, bihactl uses the default 5432 value.
-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.
By default, the postgres database is not copied
to a node in referee or referee_with_wal
modes. To copy the postgres database to the referee,
use the --referee-with-postgres-db option.
-R--referee-with-postgres-db #
Copies the postgres database with all the objects
to the referee node. You can only use this option when adding a node
in referee or referee_with_wal
modes.
-s magic_string--magic-string=magic_string #Specifies the magic string that contains encoded data to connect to the leader node.
Syntax:
bihactl init --biha-node-id=node_id--nquorum=quorum_value--host=host[--convert [--root-cert=/path/to/ca.crt--server-cert=/path/to/server.crt\ --server-key=/path/to/server.key--user-postgres-cert=/path/to/client.crt\ --user-postgres-key=/path/to/client.key[--postgres-ssl-mode=ssl_mode]]] [--pgdata=datadir] [--port=port] [--biha-port=biha_port] [--use-ssl] [--minnodes=min_node_num] [--magic-file=magic_file] [--options=initdb_options] [--sync-standbys=sync_standbys_num[--sync-standbys-min=sync_standbys_min_num] [--root-cert=/path/to/ca.crt--user-biha-cert=/path/to/client.crt\ --user-biha-key=/path/to/client.key[--biha-ssl-mode=ssl_mode]]
Initializes a cluster and sets 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.
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. If
not specified, bihactl uses the
PGDATA value.
-f magic_file--magic-file=magic_file #Specifies the path for a file to be created. This file contains encoded data to connect to the leader node (magic string).
-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 minimum number of nodes, which must vote for the new leader node if the current leader is down. This parameter can be set with the biha.set_nquorum function.
When setting up this value, consider the split-brain risk.
It is recommended to use the following formula:
(total number of nodes + 1)/2.
For example, if your cluster has 3 nodes,
the nquorum value must be 2.
-o initdb_options--options=initdb_options #Specifies additional options of initdb.
-p port--port=port #Specifies the node port for incoming connections.
If not specified:
When converting the existing cluster using
--convert,
bihactl uses the PGPORT value.
When creating a BiHA cluster from scratch, bihactl uses the default 5432 value.
-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 #
Enables quorum-based synchronous replication
by setting the synchronous_standby_names parameter
and specifying the number of synchronous standbys (quorum) with the ANY method.
It is recommended that the sync_standbys_num value be less than
the value of the --minnodes option.
-y sync_standbys_min_num--sync-standbys-min=sync_standbys_min_num #
Enables relaxed quorum-based synchronous replication by
specifying the MIN field value of the
synchronous_standby_names parameter, which is the minimum number of
synchronous standbys that must be
available for the leader node to continue operation. The
sync_standbys_min_num 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.
--biha-ssl-mode=ssl_mode #
Determines the SSL authentication policy for the
biha_replication_user role. The following modes are supported:
verify-full (default)
require
verify-ca
For more information about modes, see sslmode.
--postgres-ssl-mode=ssl_mode #Determines the SSL authentication policy for the superuser. The following modes are supported:
verify-full (default)
require
verify-ca
For more information about modes, see sslmode.
--root-cert=/path/to/ca.crt #Specifies the path to the trusted CA certificate in the PEM format.
--server-cert=/path/to/server.crt #Specifies the path to the SSL certificate for the BiHA node in the PEM format.
--server-key=/path/to/server.key #Specifies the path to the private key for the --server-cert certificate in the PEM format.
--user-biha-cert=/path/to/client.crt #
Specifies the path to the SSL certificate for the biha_replication_user
role authentication in the PEM format.
--user-biha-key=/path/to/client.key #Specifies the path to the private key for the --user-biha-cert certificate in the PEM format.
--user-postgres-cert=/path/to/client.crt #Specifies the path to the SSL certificate for the superuser authentication in the PEM format.
--user-postgres-key=/path/to/client.key #Specifies the path to the private key for the --user-postgres-cert certificate in the PEM format.
Syntax:
bihactl status {--host=host [--port=port] | --magic-string=magic_string | --magic-file=magic_file}
Checks the node status and displays it in the biha.status_v view. This command can take the following options:
-f magic_file--magic-file=magic_fileSpecifies the path to the magic file that contains encoded data to connect to the leader node.
-h host--host=hostSpecifies the node host for incoming connections.
-p port--port=port
Specifies the node port for incoming connections. If not
specified, bihactl uses the PGPORT
value. The default value is 5432.
-s magic_string--magic-string=magic_stringSpecifies the magic string that contains encoded data to connect to the leader node.
Syntax:
bihactl -V bihactl --version
Displays the current version of the high-availability cluster.