Installation¶
Security hardening of the appliance
The appliance applies part of the recommendations of the advanced security hardening guide when it is built; the state of each recommendation, and what remains to be done after deployment, is given in Security hardening of the PostgreSQL database appliance.
Note
As a reminder, switching to root on Debian machines must be done with the following command:
1 | |
The instructions provided on this page should be followed for the installation of all nodes in the PostgreSQL cluster.
Systems settings¶
Connection to the machine¶
By default, there are two accounts on virtual appliances: a user account and a super-user account.
- User account
- Login :
systancia - Password:
systnci
- Login :
- Super-user account
- Login :
root - Password:
systnci
- Login :
Connect to the machine in console mode with the systancia account, then switch to the root account with the
following command and the root password:
1 | |
Connecting as root
The root account is not accepted directly, neither in console mode nor over SSH.
Note
The default keyboard layout is QWERTY.
Modification of the keyboard layout¶
You can change the keyboard layout with the following command line:
1 | |
A menu appears to allow you to choose another keyboard layout.
Then use the following command line to apply and save the settings:
1 | |
The settings will take effect immediately after this command is executed.
Configuration of the network¶
The virtual appliance may not receive a network configuration when it starts up for the following reasons:
- The network interface name is not
ens192: the appliance is configured for DHCP only on theens192interface - No DHCP server is available
To check the network interface name, its status, and the assigned IP addresses, run the following command as root:
1 | |
Example
After executing the command, the following response is displayed:
1 | |
The name of the network interface in the example is ens192, the interface is active and has the IP address 10.100.0.51/24.
If the name is different from ens192 or if the command does not return any network settings, you will need to configure the network manually using the following commands:
1 2 | |
Replace:
IP_ADDRESSby the machine's IP addressSUBNETby the subnetworkDEV_NAMEname of the previously retrieved network interfaceGATEWAYby the network gateway
Example
To configure the PostgreSQL node with the following information:
- IP address:
10.100.0.51 - Sub-network:
/24or255.255.255.0 - Network interface name:
eth0 - Network gateway:
10.100.0.254
The commands are as follows:
1 2 | |
Note
This network configuration is temporary, therefore any server restart will reset the manual settings made with the ip address and ip route commands.
Permanent configuration will be performed by the PostgreSQL cluster configuration utility.
However, thanks to this network configuration, you can now access the PostgreSQL node via SSH.
Modification of the time zone¶
By default, the virtual appliance is set to the Europe/Paris time zone.
To change this time zone, first use the following command to retrieve the syntax of available time zones:
1 | |
Then use the following command line:
1 | |
Example
To set the time zone to London, the following command must be executed:
1 | |
Check the server's time zone using the following command line:
1 | |
Configuration of an NTP time server¶
Danger
It is strongly recommended that you configure a time server to keep the system clock up to date: any time difference between PostgreSQL nodes may cause instability or even cause the cluster to stop working.
The necessary steps are described on the NTP configuration page (the configuration is equivalent to that of CyberElements Bastion Mediation Controller servers).
Creating a PKI to generate PostgreSQL node certificates¶
Information
This section is optional if you already have a PKI from which you have been able to generate the certificates indicated in the prerequisites.
This section will present the various steps for creating a PKI and the certificates required for the PostgreSQL cluster. Note that it will not be indicated how to renew them, as the renewal of a certificate involves its re-creation.
Attention!
The procedure described has been validated on a Debian 13 machine with the openssl package. However, any machine with a recent version of OpenSSL (3.0 or later) will be able to complete the procedure. Except for Windows or MacOS where the system commands will have to be adapted.
Definition of variables and customisations¶
This section provides various commands and configuration files that use variables that can be modified.
The table below summarises all the values and allows you to define them so that you can modify them directly in the commands displayed on this page.
| Value | Variable | Definition |
|---|---|---|
PSQL_IP |
Virtual IP address of the PostgreSQL cluster. | |
PSQL_NAME |
Short name (not the FQDN) associated with the virtual IP address of the PostgreSQL cluster. | |
PSQL_1_IP |
IP address of the PostgreSQL cluster node n°1. | |
PSQL_1_NAME |
Short name (not the FQDN) of the PostgreSQL cluster node n°1. | |
PSQL_2_IP |
IP address of the PostgreSQL cluster node n°2. | |
PSQL_2_NAME |
Short name (not the FQDN) of the PostgreSQL cluster node n°2. | |
PSQL_3_IP |
IP address of the PostgreSQL cluster node n°3. | |
PSQL_3_NAME |
Short name (not the FQDN) of the PostgreSQL cluster node n°3. | |
CA_ROOT_NAME |
Name assigned to the root certification authority (CA) of the PKI. |
Preparation¶
The following actions will be performed in a new directory in order to gather all the new files in a single directory. Any directory can be used, but its access must be limited as much as possible. Log in to PostgreSQL node n°1 as root and run the following commands:
1 2 3 | |
Creation of the root certification authority¶
Run the following command to create a new root CA. You will be prompted for a password to protect the CA:
1 | |
Replace CA_ROOT_NAME with the name of the root CA if you haven't customised it here.
Creation of certificates¶
The commands required to generate certificates for PostgreSQL nodes are as follows:
1 2 3 | |
1 2 3 | |
1 2 3 | |
The first command creates a new key, the second generates a certificate signing request CSR file, and the third creates the certificate itself.
The certificate still needs to be converted to P12, which will require you to set a password:
1 | |
1 | |
1 | |
The files required to install the PostgreSQL cluster can be found here (please replace the variables CA_ROOT_NAME, PSQL_1_NAME, PSQL_2_NAME, and PSQL_3_NAME with the values you selected earlier):
/root/psql-certificates/CA_ROOT_NAME.crt: certificate of the root CA/root/psql-certificates/PSQL_1_NAME.p12: certificate for the PostgreSQL node n°1/root/psql-certificates/PSQL_2_NAME.p12: certificate for the PostgreSQL node n°2/root/psql-certificates/PSQL_3_NAME.p12: certificate for the PostgreSQL node n°3
Installation of a PostgreSQL cluster¶
Information
The following steps must be performed on all three PostgreSQL nodes.
Preparation for the configuration of the PostgreSQL cluster¶
It is necessary to establish an SFTP or SCP connection in order to send to the appliance:
- The certificate from the certification authority that signed the certificates for the PostgreSQL nodes
- The PostgreSQL node certificate in
P12format
Please note that SFTP or SCP connections cannot be initialised using the root account. In addition, files can simply be placed in /home/systancia/.
It is necessary to move these files to a new directory:
1 2 3 | |
Replace:
PSQL_?_NAMEwith the name of the certificate intended for the PostgreSQL node being installedROOT_CA_NAMEwith the name of the root certificate authority's certificate
1 2 3 | |
The commands above must have been customised according to the customisation settings.
1 2 3 | |
The commands above must have been customised according to the customisation settings.
1 2 3 | |
The commands above must have been customised according to the customisation settings.
The P12 file contains the private key of the node: restrict its access to the root account:
1 2 | |
Configuration of the PostgreSQL node¶
To start initialising the node configuration, the following commands must be executed:
1 2 | |
The second command will launch a utility that will require the following information:
Passwords entered in the utility
The passwords entered in the utility must contain neither the % character nor the $ character. If the utility
stops before the end, delete the /etc/cleanroom-vault.ini file before running it again:
1 | |
- New passwords for the
rootandsystancialocal users - Name of the PostgreSQL node (not the FQDN)
- The IP address of the PostgreSQL node, the name of its network interface, the default network gateway to use, as well as the DNS servers and DNS suffix
- The version of PostgreSQL: the appliance provides version
17, proposed by default - The access port to the PostgreSQL cluster; we recommend using port
5432 - Password for the PostgreSQL account used for replication and for
pg_rewind - Name and IP address of a second PostgreSQL node
- Name and IP address of the last PostgreSQL node
- Virtual IP address of the PostgreSQL cluster
- The IP addresses (separated by commas) of the CyberElements Bastion Edge Gateways or any other machines that need to connect to the cluster
- Name and password of the PostgreSQL user account
- The IP addresses or networks (separated by commas) authorised to connect via SSH to PostgreSQL nodes
- Certificate information for the PostgreSQL node (node certificate in P12 format + root CA certificate)
After entering this information, a summary of all your entries will be provided before validation.
Once the configuration is applied, restrict the access to the private key of the node written by the utility:
1 | |
In order to apply the configuration, a restart is required:
1 | |
Tip for speeding up the installation of PostgreSQL nodes n°2 and n°3
After installing PostgreSQL node n°1, you can retrieve the configuration settings used to set it up from the /etc/cleanroom-vault.ini file.
Example of the /etc/cleanroom-vault.ini file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
Simply modify the highlighted lines with the values of the PostgreSQL node being installed, based on the file you retrieved from PostgreSQL node n°1.
Danger
If you reuse the example file, you will need to modify all of the following highlighted values according to your environment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
Once all the PostgreSQL nodes are installed, delete the /etc/cleanroom-vault.ini file from each node, as it contains the passwords entered during the configuration in plain text:
1 | |
Opening the Patroni port and enabling the local firewall¶
The configuration utility writes the rules of the local firewall in the /etc/nftables.conf file. To enable the use of
the PostgreSQL cluster management commands with patronictl, open the Patroni port 8008 in these rules, then enable
the firewall. Run the following commands as root on each PostgreSQL node:
1 2 | |
Information
When the firewall is enabled, the connections between the nodes are reset: etcd elects its leader again, which
takes a few seconds. The state of the cluster can then be checked by
obtaining the cluster LEADER node.
So that patronictl trusts the certificate of the Patroni API (port 8008), add the certification authority of the
cluster to the settings of patronictl in the /etc/patroni/config.yml file, then reload Patroni. Run the following
commands as root on each PostgreSQL node:
1 2 | |
Information
Without this setting, the patronictl commands that go through the Patroni API fail with the
certificate verify failed error, for example when switching the LEADER node
or reinitialising a node.
Virtual IP address and VRRP identifier¶
VRRP identifier
The virtual IP address of the cluster is carried through keepalived with the VRRP identifier (VRID) 100 by
default, which must be unique on the local network of the nodes (see the prerequisites). To use
another identifier, see Changing the VRRP identifier; if the virtual IP address
is carried by no node, see Troubleshooting keepalived.
Creation of the default database required for installing CyberElements Bastion¶
When installing CyberElements Bastion, you must first create a database named default.
To do this, fill out the following table to customise the command you will need to run from a node of the PostgreSQL cluster other than the LEADER node:
| Value | Variable | Definition |
|---|---|---|
DB_USERNAME |
The database username specified during PostgreSQL node configuration |
Command to be executed from a node of the PostgreSQL cluster other than the LEADER node (see how to obtain the cluster LEADER node):
1 | |