TwinCAT Runtime Linux®
![]() | These instructions refer to version 17 of PostgreSQL. |
Installation of PostgreSQL
- Connect to the PackageManager of TwinCAT Runtime Linux® to install the corresponding package.
- 1. Update the packages.
sudo apt update- 2. Install the PostgreSQL database server.
sudo apt install postgresql-17- 3. Activate the PostgreSQL service.
- The database has been successfully installed and the service started.
sudo systemctl start postgresqlInitializing PostgreSQL
- 1. Switch to the database user
sudo -i -u postgres- 2. Start psql
psql- 3. Initialize the database.
Initdb- 4. Change the default password of postgres
\password postgres- 5. Exit psql
\q- 6. Log out.
- The database has been successfully initialized and started.
exitSettings for access via the network
- 1. Create a configuration file in the /etc/nftables.conf.d/ directory with the name 00-postgre.conf, for example
sudo nano /etc/nftables.conf.d/00-postgre.conf- 2. Insert the following content and adjust the values to your network requirements:
table inet filter {
chain input {
# accept PostgresSQL
tcp dport 5432 accept
}
}- 3. Save and close the configuration file.
- 4. Load the new rule with the command
sudo systemctl reload nftables- 5. Check the settings and make sure that the configuration has been applied correctly.
- Port 5432 has been enabled for the PostgreSQL database.
sudo nft list ruleset- 6. Open postgresql.conf to adjust the "listen_addresses".
sudo nano /etc/postgresql/17/main/postgresql.conf- 7. Change the entry listen_addresses to '*' and remove the # to activate the line.
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)- 8. Save and exit the editor.
- 9. Open pg_hba.conf to adjust the security settings.
sudo nano /etc/postgresql/17/main/pg_hba.conf- 10. Adjust the entry host all all 127.0.0.1/32 or add a new one. Change the method to md5.
- By default, 127.0.0.1/32 is entered as local only. If other systems are to have access to the database, the corresponding IP address must be set.
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256- 11. Save and exit the editor.
- 12. Restart the service.
- Thanks to the new configuration, your database is now accessible over the network.
sudo systemctl restart postgresqlFurther Information
