Глава 8. Развёртывание Postgres Pro AXE
В этой главе описывается, как развернуть Postgres Pro AXE на одном сервере. За подробной информацией о возможных сценариях развёртывания обратитесь к Главе 5.
Чтобы развернуть Postgres Pro AXE, выполните следующие шаги на сервере:
Загрузите скрипт настройки репозитория, используя ключ доступа, полученный от Postgres Pro:
wget --user
ключ_доступа--password='' -O ./pgpro-repo-add.sh https://repo.postgrespro.ru/axe/axe/keys/pgpro-repo-add.shЗапустите скрипт настройки репозитория:
sudo sh ./pgpro-repo-add.sh
При появлении запроса введите учётные данные для доступа. Скрипт настройки репозитория сохраняет учётные данные репозитория в
/etc/apt/auth.conf.d/repo.postgrespro.ru.confи обновляет индекс пакетов.Установите СУБД Postgres Pro AXE и расширение pgpro_axe.
Например:
sudo apt install dbms-axe-17 pgpro-axe
Добавьте расширение pgpro_axe в параметр конфигурации
shared_preload_libraries:ALTER SYSTEM SET shared_preload_libraries = pgpro_axe;
При обновлении параметра конфигурации
shared_preload_librariesдобавляйтеpgpro_axeк существующему списку предварительно загружаемых библиотек, а не заменяйте этот список. В противном случае остальные предварительно загружаемые библиотеки больше не будут загружаться.Установите оставшиеся параметры конфигурации.
Пример 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.
Создайте базу данных для Postgres Pro AXE или используйте существующую.
Например:
CREATE DATABASE axe_db;
Подключитесь к базе данных, затем создайте расширение pgpro_axe.
Например:
\connect axe_db CREATE EXTENSION pgpro_axe;
Важно
Расширение создаёт свои объекты в выделенных схемах
axe,duckdbи_axe_proxy. ПредложениеSCHEMAне контролирует их расположение.Настройте администратора 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';Создайте секрет каталога метаданных.
Каталог метаданных — это набор таблиц метаданных, которые организуют данные из Parquet-файлов в аналитические таблицы. Каталог хранится в схеме
axe_catalogСУБД Postgres Pro AXE и может быть инициализирован на локальном сервере Postgres Pro AXE или на удалённом сервере.Например:
SELECT axe.create_catalog_secret(current_setting('unix_socket_directories'), current_setting('port'), 'postgres', '', '');
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:
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.shRun 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.confand updates the package index.Install the Postgres Pro AXE DBMS and the pgpro_axe extension.
For example:
sudo apt install dbms-axe-17 pgpro-axe
Add the pgpro_axe extension to the
shared_preload_librariesconfiguration parameter:ALTER SYSTEM SET shared_preload_libraries = pgpro_axe;
When updating the
shared_preload_librariesconfiguration parameter, addpgpro_axeto the existing list of the preloaded libraries rather than replacing it. Otherwise, the other preloaded libraries will no longer be loaded.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_transactionsconfiguration 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_transactionsconfiguration parameter on that server.For the full list of parameters, refer to Appendix C.
Create a database for Postgres Pro AXE or use an existing one.
For example:
CREATE DATABASE axe_db;
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_proxyschemas. TheSCHEMAclause does not control their location.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';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_catalogschema 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', '', '');