PostgreSQL® Server Installation

In case of Linux, use the PostgreSQL® server version package provided by ETM.

Starting with the WinCC OA version 3.18, the NGA manager also includes a backend to use the relational, open-source PostgreSQL® database for historical archiving and querying of value changes and alerts. The functionality of NGA InfluxDB® and PostgreSQL® backend is identical except mentioned separately.

The PostgreSQL® database and its installation software of the database are not part of WinCC OA.

PostgreSQL® Server Installation Steps

To create a database instance of the PostgreSQL®, proceed as follows. Consider also the notes in the chapter Troubleshooting PostgreSQL® :

  • Install PostgreSQL® 13 (PostgreSQL® 13 can be downloaded under https://www.postgresql.org/download/ ). Make sure the check box to install pgAdmin is checked. This tool is very useful to browse the database. For supported operating systems for PostgreSQL® Server, see chapter Software requirements -Supported PostgreSQL Version for NGA .
    CAUTION: Install PostgreSQL® 13 on all computers on which a PostgreSQL®-Backend runs or "Direct Read" is used via PostgreSQL® backends.
  • Under Linux the WinCC OA SQLDrivers package: WinCC_OA_3.18.0-SqlDrivers-rhel.x86_64.rpm is required for the NGA - database connection when PostgreSQL® is used.
  • Create the database directories db, events, alerts, backups in your desired directory, e.g. C:/postgresql_backend/.
    Note: The backup folder must be accessible to the users under whom WinCC OA is running.
  • Edit the winccoa_path/data/NGA/PostgreSQL/sql/db.windows.config /db.linux.config file under C:/postgresql_backend/ with the directories just created, for example:
    # DB Paths
    dbPath=c:/postgresql_backend/db              #Path to DB schema files
    dbEventsPath=c:/postgresql_backend/events    #Path to EVENTS DB Files
    dbAlertsPath=c:/postgresql_backend/alerts    #Path to ALERTS DB Files
    dbBackupPath=c:/postgresql_backend/backups   # Path to the backed up segment files

    The winccoa_path/data/NGA/PostgreSQL/sql/db.windows.config /db.linux.config file must contain the paths to the database directories db, events, alerts, backups in the C:/postgresql_backend/ directory.

    CAUTION: Only letters and numbers ([a-zA-Z0-9]) can be used for the content of the winccoa_path/data/NGA/PostgreSQL/sql/db.windows.config file.
Note: The workflow for creating PostgreSQL® schema.sql cannot process uppercase letters in the database name. Only use lower case letters in the database name and in the database schema name (In the db.windows.config /db.linux.config file in the directory winccoa_path/data/NGA/PostgreSQL/sql.
  • Specify the database adminPassword and the winccoaPassword - see Database Passwords (DB Admin & WinCC OA DB User). The adminPassword is the password that was used when the database was installed (see previous steps).
  • If you change the winccoaPassword (initially defined in: winccoa_path/data/NGA/PostgreSQL/sql/db.windows.config /db.linux.config), the password must also be changed in NGA via System Management > Database > Database - Configuration > Backend > General settings > Basic configuration:
    Figure 1. Change the password
  • Run the winccoa_path/data/NGA/PostgreSQL/sql/create_database_windows.ps1 script for Windows to create the DB schema.
    Note: For the update of the PostgreSQL® database schema and for the scripts for backup/restore, see chapter PostgreSQL® Database Maintenance.
Note:

You can use the following command on a remote host to check if you can access the database: psql -h <host> -p <port> -U <db user name> -c "SELECT pg_is_in_recovery();"

If the database is available, the result of the SELECT query is shown. Otherwise an error message is shown.

  • Start the WinCC OA project and NGA via System Management > Runtime Engineering.
  • Change the "Backend" for the alert group "ALERT" to PostgreSQL®.
    Figure 2. Change the "Backend" for the Alert Group "ALERT"
Note: Note that by default an "EVENT" type archive group is already available for InfluxDB®. It is deactivated by default. An archive group of type EVENT is also available for PostgreSQL®: "EVENT_PG". If you migrate from an InfluxDB® backend to a PostgreSQL® backend. Instead of changing all the archive configs of the DPs to use the EVENT archive group for PostgreSQL® "EVENT_PG", you can simply change the backend assigned to EVENT to PostgreSQL®. Note, however, that when doing so, saved data for the changed archive group is lost.
Tip: It is recommended to adapt the number of reading/writing threads for the PostgreSQL® backend to the number of CPU cores available on the machine where the PostgreSQL® database runs, since for each open connection a PostgreSQL® fork process is created.