18.1. Installing PostgreSQL for 1C on Linux #

18.1.1. Supported Linux Distributions
18.1.2. Adding Package Repository
18.1.3. Providing a Public Key in Astra Linux
18.1.4. Quick Installation and Setup
18.1.5. Custom Installation
18.1.6. Setting up Development Workstations
18.1.7. Configuring Multiple PostgreSQL Instances
18.1.8. Antivirus Considerations

For Linux-based operating systems, PostgreSQL for 1C is shipped as binary packages. Each PostgreSQL binary distribution consists of several packages. The package structure differs from vanilla PostgreSQL and offers the following installation modes:

The minimum hardware required to install PostgreSQL, create a database cluster and start the database server are as follows:

Additional disk space is required for data or supporting components.

18.1.1. Supported Linux Distributions #

PostgreSQL binary packages are available for the following Linux-based systems:

  • Red Hat Enterprise Linux (RHEL) systems and its derivatives: Red Hat Enterprise Linux 8/9/10, Rocky Linux 9/10, Oracle Linux 9/10, AlmaLinux 9/10, Red OS Murom 7.3/8, ROSA Chrome 2021.1

  • Debian-based systems: Debian 11/12/13, Ubuntu 22.04/24.04, Astra Linux 1.7/1.8

  • ALT 10/11, ALT SP 8.2, ALT SP Release 10

  • SUSE Linux Enterprise Server (SLES) 15

Note

PostgreSQL binary packages rely on the tzdata library provided by the operating system, so you must ensure that the latest available version is installed. If tzdata is outdated, the time in your database may be incorrect.

18.1.2. Adding Package Repository #

Before installing PostgreSQL from binary packages using the package manager of your operating system, you need to add the PostgreSQL package repository.

To add the repository, complete the following steps:

  1. Navigate to the PostgreSQL for 1C download page and click the download button.

  2. Fill in the questionnaire to get installation instructions. An e-mail will be sent to the address specified in the questionnaire.

  3. Download the pgpro-repo-add.sh Bash script via the link from the e-mail.

    This script adds the repository so that the package manager of your operating system can use it.

  4. Make sure that the wget utility is installed and can access the Internet.

    The script requires wget and the Internet access to check that the repository is accessible.

    Note

    It is not possible to use a SOCKS5 proxy for accessing the Internet as wget does not support this type of proxy.

  5. (Optional) Examine the content of the script, if necessary.

  6. Run the script as root (e. g. using sudo).

Now you are ready to install PostgreSQL for 1C using the package manager of your operating system.

18.1.3. Providing a Public Key in Astra Linux #

To be able to install PostgreSQL for 1C in Astra Linux in secure software environment (SSE) mode, you must provide the public key used for signing the PostgreSQL for 1C binaries.

To add the public key, complete the following steps:

  1. Download the SSE-ASTRA-GPG-POSTGRESPRO public key file for Astra Linux from the Postgres Pro repository.

    The public key file from the repository is in the ASCII format. However, the secure software environment in Astra Linux requires the public key in the binary format.

  2. Convert the key file from the ASCII format to the binary format:

    gpg --dearmor --output pgpro-astra.key SSE-ASTRA-GPG-POSTGRESPRO
    
  3. Copy the public key in the binary format to /etc/digsig/keys/.

  4. Ensure that the following parameters are added to /etc/digsig/digsig_initramfs.conf:

    DIGSIG_ELF_MODE=1
    DIGSIG_XATTR_MODE=0
    DIGSIG_IGNORE_XATTR_KEYS=0
    DIGSIG_IGNORE_GOST2001=0
    
  5. Update the initramfs image:

    sudo update-initramfs -u -k all
    
  6. Restart the machine.

  7. Proceed to the installation.

18.1.4. Quick Installation and Setup #

If you only need to install a single PostgreSQL instance and are not going to use any other PostgreSQL-based products on your system, you can use the quick installation mode. The typical process is as follows:

  1. Add the package repository required for your operating system.

  2. Install the postgrespro-1c-16 package. It will bring all the required components via dependencies, create the default database, start the database server, as well as enable server autostart at system boot and make all the provided programs available in PATH.

Note

By default, the database configuration is set for the PostgreSQL product being installed. If you need your database configured for a different product, choose custom installation and use the tune argument of the pg-setup initdb command.

Once the installation completes, you can launch psql on behalf of the postgres user and connect to the newly created database, which is located in the /var/lib/pgpro/1c-16/data directory.

Since the default database is created using the pg-setup script, the path to its data directory is stored in the /etc/default/postgrespro-1c-16 file. All the subsequent pg-setup commands, as well as any commands that manage PostgreSQL service, affect this database only. In this file, you can also change the value of PG_OOM_ADJUST_VALUE for postmaster child processes (see Section 19.4.4 for details).

18.1.5. Custom Installation #

Splitting the distribution into multiple packages enables customizing the installation for different purposes: database servers, client systems, or development workstations. Custom installations need to be configured manually, but give you more flexibility in using the product. You can install several PostgreSQL versions side by side, as well as together with other PostgreSQL-based products. In particular, this may be required when performing upgrades, or migrating from a different PostgreSQL-based product.

To perform a custom installation, complete the following steps:

  1. Add the package repository required for your operating system.

  2. Choose PostgreSQL packages required for your purposes and install them using the standard installation commands for your Linux distribution. The available packages are listed in Table 18.1.

    As a result, all files get installed into the /opt/pgpro/1c-16 directory.

  3. Run pg-wrapper as root to make the installed client and server programs available via PATH and add SQL man pages to the man page configuration file. This utility is provided in the postgrespro-1c-16-client package.

    /opt/pgpro/1c-16/bin/pg-wrapper links update
    

    For details on how to handle possible conflicts, see pg-wrapper description.

  4. If you chose to install the postgrespro-1c-16-server package, make sure to complete the following server setup:

    1. Create the default database by running the helper script pg-setup as root with the initdb option:

      /opt/pgpro/1c-16/bin/pg-setup initdb [initdb_options]
      

      where:

      • the tune command-line argument sets the database configuration.

      • initdb_options are regular initdb options.

      Note

      By default, pg-setup initializes the database cluster with checksums enabled. If this is not what you expect, specify the --no-data-checksums.

      The pg-setup script performs database administration operations as user postgres. If you do not specify any initdb options, the default database is created in the /var/lib/pgpro/1c-16/data directory, using localization settings specified in the LANG environment variable for the current session. All the LC_* environment variables are ignored.

      Since the default database is created using the pg-setup script, the path to its data directory is stored in the /etc/default/postgrespro-1c-16 file. All the subsequent pg-setup commands, as well as any commands that manage PostgreSQL service, affect this database only. In this file, you can also change the value of PG_OOM_ADJUST_VALUE for postmaster child processes (see Section 19.4.4 for details).

    2. Start the server by running pg-setup as root, as follows:

      /opt/pgpro/1c-16/bin/pg-setup service start
      

      Like vanilla PostgreSQL, PostgreSQL server runs on behalf of the postgres user.

      Note

      By default, automatic server startup is disabled, so you can manually control the database recovery after a system reboot. Optionally, you can configure the PostgreSQL server to start automatically. For details, see Section 18.1.5.2.

18.1.5.1. Choosing the Packages to Install #

The table below lists all the available PostgreSQL packages.

Table 18.1. PostgreSQL Packages

Package

Description

postgrespro-1c-16

Top-level package that installs and configures PostgreSQL for server and client systems. Do not use this package for upgrades or migrations.

Important

Installing the postgrespro-1c-16 package can delete existing installations of PostgreSQL and PostgreSQL-based products. Similarly, this PostgreSQL installation may be automatically removed if you later install another PostgreSQL-based product.

postgrespro-1c-16-client

Standard client applications, such as psql or pg_dump.

postgrespro-1c-16-libs

Shared libraries required to deploy client applications, including libpq; runtime libraries for ECPG processor.

postgrespro-1c-16-server

PostgreSQL server and PL/pgSQL server-side programming language.

postgrespro-1c-16-contrib

Additional extensions and programs deployable on database servers.

postgrespro-1c-16-devel

Header files and libraries for developing client applications and server extensions.

On Debian-based systems, this package is called postgrespro-1c-16-dev.

postgrespro-1c-16-plperl

Server-side programming language based on Perl (see Chapter 46).

postgrespro-1c-16-plpython3

Server-side programming language based on Python 3 (see Chapter 47).

postgrespro-1c-16-pltcl

Server-side programming language based on Tcl (see Chapter 45).

postgrespro-1c-16-docs

Documentation (English).

postgrespro-1c-16-docs-ru

Documentation (Russian).

postgrespro-1c-16-test

Test scripts for the server.

This package is only available on RHEL-based and SUSE systems.

postgrespro-1c-16-jit

This package provides support for Just-in-Time (JIT) compilation.

This package is only available for the supported Debian and Ubuntu systems, Astra Linux 1.7/1.8, supported ALT systems, CentOS 8, Rocky Linux 8/9, Oracle Linux 8/9, AlmaLinux 9, SLES 15 and RHEL 8/9.

To learn more about enabling and using JIT, see Chapter 32.


Also, PostgreSQL includes libraries and utilities required for the PostgreSQL server and provided packages. These packages are only provided for the distributions that don't include the required versions of these libraries.

Table 18.2. Third-party libraries and utilities for PostgreSQL for 1C

Library/utility

Description

liblz4

A library for fast lossless data compression.

libunwind

A stack unwinding library used by crash_info. This package is provided for RHEL 8.

libbacktrace

A backtrace library used by crash_info. This package is provided for ALT SP 8.2, Red OS 7.3/8, RHEL 8/9, and SLES 15.

perl-IO-Tty, perl-IPC-Run

Two Perl libraries used in the TAP test framework available in the postgrespro-1c-16-devel package for extension developers and engineers. perl-IO-Tty is provided for RED OS Murom 7.3/8, RHEL 8/9, and perl-IPC-Run is provided for RED OS Murom 7.3/8, RHEL 8/9, SLES 15.


Additionally, PostgreSQL provides separate packages with debug information for some operating systems:

  • On Debian-based systems, see the postgrespro-1c-16-dbg package.

  • On RHEL-based systems, see the postgrespro-1c-16-debuginfo package.

  • On ALT Linux systems, all packages containing binary files have the corresponding -debuginfo packages.

Server installations require at least the following packages:

  • postgrespro-1c-16-server

  • postgrespro-1c-16-client

  • postgrespro-1c-16-libs

To use additional PostgreSQL extensions, you must also install the postgrespro-1c-16-contrib package. On Debian-based systems, postgrespro-1c-16-server package depends on postgrespro-1c-16-contrib package, so the latter must always be installed together with the server.

For client installations, it is usually enough to install the postgrespro-1c-16-client and postgrespro-1c-16-libs packages. If you use custom applications and do not need standard client utilities such as psql, you can install the postgrespro-1c-16-libs package only.

Development workstations require at least the following packages:

  • postgrespro-1c-16-libs

  • postgrespro-1c-16-devel/ postgrespro-1c-16-dev

You may also want to install and configure the server with a test database on development systems. For details on additional configuration that may be required, Section 18.1.6.

18.1.5.2. Enabling Automatic Server Startup #

If you are running a custom installation, automatic server startup is disabled by default. Once the default database is created, you can configure the server to start automatically upon system boot using service management solutions available in your operating system or third-party high-availability software. To facilitate this task, postgrespro-1c-16-server package provides the pg-setup script, which is installed in the /opt/pgpro/1c-16/bin directory.

To enable server autostart, run the pg-setup script with the following options:

pg-setup service enable

If required, you can disable server autostart using the same script:

pg-setup service disable

Alternatively, you can use system service management solutions directly by running the autostart scripts for SysV-style init.d and systemd provided in the postgrespro-1c-16-server package. Depending on your Linux distribution, PostgreSQL supports different service management solutions:

Linux Distribution

Provided Scripts

RHEL-based systems, SLES 15

systemd unit file

Debian, Ubuntu, ALT 10/11

Both systemd unit file and SysV-style init.d script

To use systemd for automatic server startup, run the following command:

systemctl enable postgrespro-1c-16

To use SysV-style init.d script:

  • On ALT Linux systems, run the following command:

    systemctl enable postgrespro-1c-16
    

  • On Debian systems, use update-rc.d. See the corresponding man page for details.

18.1.6. Setting up Development Workstations #

While installing postgrespro-1c-16-libs and postgrespro-1c-16-devel/ postgrespro-1c-16-dev packages may be enough, it is usually convenient to have the server set up on the development system. For quick setup, you can install postgrespro-1c-16 package, which automatically configures the provided client and server programs and creates the default database. However, if you are going to use several PostgreSQL-based products simultaneously, follow the custom installation instructions in Section 18.1.5.

To compile programs with PostgreSQL libraries using the pg_config utility shipped with PostgreSQL, make sure it appears before the path to other pg_config versions, if any. Note that on RHEL-based systems pg_config is not added to PATH automatically. If you do not have any other pg_config versions on your system, you can use pg-wrapper provided in the postgrespro-1c-16-client package to create a symbolic link to pg_config in the standard binary directory.

To compile programs using pkg-config command, add the /opt/pgpro/1c-16/lib/pkgconfig/ path to the PKG_CONFIG_PATH environment variable.

If you would like to compile PostgreSQL extensions that support JIT inlining, make sure to meet the following additional requirements:

  • Install LLVM development package and Clang compiler. You must choose the packages of the same version that was used for the postgrespro-1c-16-jit to be installed on the server. To determine the required version for the current PostgreSQL release, check the CLANG value in the /opt/pgpro/1c-16/lib/pgxs/src/Makefile.global file.

  • When running make or make install commands, specify the with-llvm=yes option to compile and install bitcode files for your extension. By default, bitcode compilation is disabled as it depends on Clang compiler availability.

18.1.6.1. Using Third-Party Programs with PostgreSQL #

To use PostgreSQL server with a client program provided with a third-party product, you can install the version of PostgreSQL libraries that was used to compile this program. For example, if this program is provided with vanilla PostgreSQL, you may need to install the libpq or postgresql-libs packages available for your Linux distribution. In this case, the program may not be able to use some new features of PostgreSQL server, but it is probably not designed to use them anyway.

If you prefer to use PostgreSQL libraries with a third-party program, or would like to enable support for a new feature that does not require client application change, such as SCRAM authentication, you can recompile your program with PostgreSQL libraries.

Important

If the program is compiled with one version of libpq but used with another, its stable work cannot be guaranteed.

If you are creating .rpm or .deb packages for your program, it is recommended to do the following:

  1. Add /opt/pgpro/1c-16/bin to PATH inside your build scripts (.spec files or debian/rules).

  2. Specify postgrespro-1c-16-dev in the BuildDepends or BuildRequires tags for your program.

Thus, you can ensure that your package build process calls the right version of pg_config whenever the source package is rebuilt.

18.1.7. Configuring Multiple PostgreSQL Instances #

To set up several PostgreSQL server instances with different data directories on Linux, do the following:

  1. Install and configure PostgreSQL as explained in Section 18.1.4 or Section 18.1.5.

  2. Once the first default database is created, run initdb specifying the path to a different data directory and any other parameters required to initialize another server instance.

  3. Specify different ports for your server instances in the corresponding postgresql.conf files to avoid conflicts.

  4. If required, configure automatic server startup, as follows:

    1. Create a copy of /etc/init.d/postgrespro-1c-16 or /lib/systemd/system/postgrespro-1c-16.service with a different name, specifying the path to the data directory.

    2. Enable automatic server startup using the provided autostart scripts for your system service management facility instead of pg-setup, as described in Section 18.1.5.2. Make sure to use the renamed copies of the scripts you created in step 1.

18.1.8. Antivirus Considerations #

It is strongly recommended to avoid using antivirus software on systems where PostgreSQL is running because it may cause additional load on your environment and result in unexpected database behavior that would lead to performance and reliability issues. If you need to use antivirus software, make sure to exclude the following directories from virus scanning as they do not contain any executable files:

  • PGDATA directory that stores main cluster data, usually located in /var/lib/pgpro/1c-16/data unless you specified another directory in initdb options

  • Paths to created tablespaces