Глава 8. Развёртывание Postgres Pro AXE

В этой главе описывается, как развернуть Postgres Pro AXE на одном сервере. За подробной информацией о возможных сценариях развёртывания обратитесь к Главе 5.

Чтобы развернуть Postgres Pro AXE, выполните следующие шаги на сервере:

  1. Загрузите скрипт настройки репозитория, используя ключ доступа, полученный от Postgres Pro:

      wget --user ключ_доступа --password='' -O ./pgpro-repo-add.sh https://repo.postgrespro.ru/axe/axe/keys/pgpro-repo-add.sh
  2. Запустите скрипт настройки репозитория:

      sudo sh ./pgpro-repo-add.sh

    При появлении запроса введите учётные данные для доступа. Скрипт настройки репозитория сохраняет учётные данные репозитория в /etc/apt/auth.conf.d/repo.postgrespro.ru.conf и обновляет индекс пакетов.

  3. Установите СУБД Postgres Pro AXE и расширение pgpro_axe.

    Например:

      sudo apt install dbms-axe-17 pgpro-axe
  4. Добавьте расширение pgpro_axe в параметр конфигурации shared_preload_libraries:

      ALTER SYSTEM SET shared_preload_libraries = pgpro_axe;

    При обновлении параметра конфигурации shared_preload_libraries добавляйте pgpro_axe к существующему списку предварительно загружаемых библиотек, а не заменяйте этот список. В противном случае остальные предварительно загружаемые библиотеки больше не будут загружаться.

  5. Установите оставшиеся параметры конфигурации.

    Пример 8.1. Минимальная конфигурация Postgres Pro AXE

      ALTER SYSTEM SET axe.max_memory TO '16GB';
      ALTER SYSTEM SET axe.threads TO 2;
      ALTER SYSTEM SET duckdb.unsafe_allow_execution_inside_functions TO 'on';
      ALTER SYSTEM SET axe.force_execution TO false;
      ALTER SYSTEM SET axe.max_workers_per_postgres_scan TO 2;
      ALTER SYSTEM SET axe.threads_for_postgres_scan TO 2;
      ALTER SYSTEM SET axe.convert_unsupported_numeric_to_double TO true;
      ALTER SYSTEM SET max_prepared_transactions TO 20;

    На сервере с каталогом метаданных необходимо установить значение больше 0 для параметра конфигурации max_prepared_transactions, так как Postgres Pro AXE использует двухфазную фиксацию транзакций, которые одновременно изменяют таблицы-кучи и аналитические таблицы. То же самое применяется к транзакциям, выполняющим DDL-команды для аналитических таблиц, так как в этом случае также изменяются системные таблицы Postgres Pro. За подробной информацией обратитесь к Подразделу 15.4.2.

    В этой главе каталог метаданных будет инициализирован на локальном сервере Postgres Pro AXE. Если каталог метаданных инициализируется на удалённом сервере, установите параметр конфигурации max_prepared_transactions на этом сервере.

    За полным списком параметров обратитесь к Приложению C.

  6. Перезапустите сервер.

  7. Создайте базу данных для Postgres Pro AXE или используйте существующую.

    Например:

      CREATE DATABASE axe_db;
  8. Подключитесь к базе данных, затем создайте расширение pgpro_axe.

    Например:

      \connect axe_db
      CREATE EXTENSION pgpro_axe;

    Важно

    Расширение создаёт свои объекты в выделенных схемах axe, duckdb и _axe_proxy. Предложение SCHEMA не контролирует их расположение.

  9. Настройте администратора Postgres Pro AXE.

    Суперпользователи могут выполнять все операции. Для других ролей решение предоставляет выделенную роль администратора Postgres Pro AXE, которая может выполнять запросы к аналитическим таблицам, а также все SQL-команды и хранимые процедуры при условии, что ей предоставлены требуемые права.

    Например:

      CREATE ROLE axe_admin WITH LOGIN PASSWORD 'пароль';
      GRANT ALL ON SCHEMA axe TO axe_admin;
      ALTER SYSTEM SET axe.postgres_role TO 'axe_admin';
  10. Перезапустите сервер.

  11. Создайте секрет каталога метаданных.

    Каталог метаданных — это набор таблиц метаданных, которые организуют данные из Parquet-файлов в аналитические таблицы. Каталог хранится в схеме axe_catalog СУБД Postgres Pro AXE и может быть инициализирован на локальном сервере Postgres Pro AXE или на удалённом сервере.

    Например:

      SELECT axe.create_catalog_secret(current_setting('unix_socket_directories'), current_setting('port'), 'postgres', '', '');
  12. Убедитесь, что Postgres Pro AXE развёрнут успешно.

Chapter 8. Deploying Postgres Pro AXE

This chapter describes how to deploy Postgres Pro AXE on a single server. For more information about possible deployment scenarios, refer to Chapter 5.

To deploy Postgres Pro AXE, perform the following steps on the server:

  1. Download the repository setup script using the access key received from Postgres Pro:

      wget --user access_key --password='' -O ./pgpro-repo-add.sh https://repo.postgrespro.ru/axe/axe/keys/pgpro-repo-add.sh
    
  2. Run the repository setup script:

      sudo sh ./pgpro-repo-add.sh
    

    When prompted, enter the access credentials. The repository setup script saves the repository credentials to /etc/apt/auth.conf.d/repo.postgrespro.ru.conf and updates the package index.

  3. Install the Postgres Pro AXE DBMS and the pgpro_axe extension.

    For example:

      sudo apt install dbms-axe-17 pgpro-axe
    
  4. Add the pgpro_axe extension to the shared_preload_libraries configuration parameter:

      ALTER SYSTEM SET shared_preload_libraries = pgpro_axe;
    

    When updating the shared_preload_libraries configuration parameter, add pgpro_axe to the existing list of the preloaded libraries rather than replacing it. Otherwise, the other preloaded libraries will no longer be loaded.

  5. Set the remaining configuration parameters.

    Example 8.1. Minimal Postgres Pro AXE Configuration

      ALTER SYSTEM SET axe.max_memory TO '16GB';
      ALTER SYSTEM SET axe.threads TO 2;
      ALTER SYSTEM SET duckdb.unsafe_allow_execution_inside_functions TO 'on';
      ALTER SYSTEM SET axe.force_execution TO false;
      ALTER SYSTEM SET axe.max_workers_per_postgres_scan TO 2;
      ALTER SYSTEM SET axe.threads_for_postgres_scan TO 2;
      ALTER SYSTEM SET axe.convert_unsupported_numeric_to_double TO true;
      ALTER SYSTEM SET max_prepared_transactions TO 20;
    

    You must set the max_prepared_transactions configuration parameter to a value greater than 0 on the server with the metadata catalog, because Postgres Pro AXE uses two-phase commit for transactions that modify both heap tables and analytical tables. The same applies to transactions that execute DDL commands on analytical tables, since in this case system tables of Postgres Pro are also modified. For more information, refer to Section 15.4.2.

    In this chapter, the metadata catalog will be initialized on the local Postgres Pro AXE server. If you initialize the metadata catalog on a remote server, set the max_prepared_transactions configuration parameter on that server.

    For the full list of parameters, refer to Appendix C.

  6. Restart the server.

  7. Create a database for Postgres Pro AXE or use an existing one.

    For example:

      CREATE DATABASE axe_db;
    
  8. Connect to the database and create the pgpro_axe extension.

    For example:

      \connect axe_db
      CREATE EXTENSION pgpro_axe;
    

    Important

    The extension creates its objects in the dedicated axe, duckdb, and _axe_proxy schemas. The SCHEMA clause does not control their location.

  9. Configure the Postgres Pro AXE administrator.

    Superusers can perform all operations. For other roles, the solution provides a dedicated Postgres Pro AXE administrator role that can query analytical tables and execute all SQL commands and stored procedures if the required privileges are assigned to it.

    For example:

      CREATE ROLE axe_admin WITH LOGIN PASSWORD 'password';
      GRANT ALL ON SCHEMA axe TO axe_admin;
      ALTER SYSTEM SET axe.postgres_role TO 'axe_admin';
    
  10. Restart the server.

  11. Create the metadata catalog secret.

    The metadata catalog is a set of metadata tables that organize the data from Parquet files into analytical tables. The catalog is stored in the axe_catalog schema of the Postgres Pro AXE DBMS and can be initialized on the local Postgres Pro AXE server or on a remote server.

    For example:

      SELECT axe.create_catalog_secret(current_setting('unix_socket_directories'), current_setting('port'), 'postgres', '', '');
    
  12. Check that Postgres Pro AXE is deployed successfully.

FAQ