PostgreSQL® Server Installation

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® :

  1. 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.
    CAUTION: Install PostgreSQL® 13 on all computers on which a PostgreSQL®-Backend runs or "Direct Read" is used via PostgreSQL® backends.
    Note: Check whether the PostgreSQL installation path is contained in the PATH variable. If this is not the case, add the location of the directory with the PostgreSQL® binary files (e.g. C:/Program Files/PostgreSQL/13/bin directory) to the PATH variable.
  2. 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.
  3. 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.
  4. 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.
  5. Specify the adminPassword and the winccoaPassword - see Database Passwords (DB Admin & WinCC OA DB User).
  6. The adminPassword is the password that was used when the database was installed (see previous steps). If you change the winccoa password, the password must also be changed in NGA via System Management > Database > Database - Configuration > Backend > General settings > Basic configuration

    Figure 1. Change the password
  7. Run the winccoa_path/data/NGA/PostgreSQL/sql/create_database_windows.ps1 script for Windows to create the DB schema.
    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.

  8. Start the WinCC OA project and NGA via System Management > Runtime Engineering.
  9. 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.