Тип сервиса
Сервис PostgreSQL (PostGIS)
Самостоятельно размещаемый сервис базы данных PostgreSQL с расширениями PostGIS для геопространственных данных и пространственных запросов внутри стека.
Вы добавляете этот сервис в стек и выбираете там его версию и ресурсы. Каждое окружение может их переопределить.
На этой странице
В StackMaster
Как PostgreSQL (PostGIS) работает в StackMaster
Database, user and passwords
Wodby manages the database and its user; the application does not create them.
- One database and one user are created for the environment, both named after the application and the environment. The database is
UTF8with theen_US.utf8locale. - The user's password and the password of the administrator
postgresare generated once per environment (tokenspasswordandroot_password). - Further databases and users are added on Wodby, which runs the same create and grant actions. A role created by hand with a name Wodby later needs, but another password, makes the create action fail rather than replace it.
Ownership inside a database
Each managed database is owned by its own role named <database>:owner, which cannot log in. Granting a user access makes it a member of that role, and the user's sessions in that database act as that role. What follows from it:
- Objects are created in the
publicschema and belong to the owner role, whichever user created them. All users granted access to the database share its data. - In such a session
current_useris the owner role;session_useris the user that logged in. Code that comparescurrent_userwith the login name sees the owner role instead. - Only users granted access can connect to the database.
- A backup carries no role names and no grants, so it can be imported into a database with another name and other users.
How a linked service reaches it
- Host: the name of this app service inside the environment. Port:
5432. - A service linked to this one receives the host, port, database name, user name and password as environment variables defined by its own link (for example
DB_HOST,DB_PORT,DB_NAME,DB_USERNAME,DB_PASSWORDon the PHP service). Read those in the application; do not hardcode them and do not connect aspostgresfrom the application.
Extensions
Wodby creates extensions as the administrator. POSTGRES_DB_EXTENSIONS on this service is a comma-separated list of extensions created in a database when Wodby creates it. pgvector is bundled in the image but not enabled: add vector to that list. The label pgvector on the service means the library is present, not that the extension exists in the database.
Server configuration
The container writes /etc/postgresql/postgresql.conf on every start from a template and environment variables. Two ways to change settings, neither of them editing the generated file:
- Set a variable on this service:
POSTGRES_MAX_CONNECTIONS,POSTGRES_SHARED_BUFFERS,POSTGRES_WORK_MEM,POSTGRES_MAINTENANCE_WORK_MEM,POSTGRES_EFFECTIVE_CACHE_SIZE,POSTGRES_MAX_WAL_SIZE,POSTGRES_TIMEZONE,POSTGRES_SHARED_PRELOAD_LIBRARIES. - Set the setting Max prepared transactions (
POSTGRES_MAX_PREPARED_TRANSACTIONS, default0) above 0 for applications that use two-phase commit (PREPARE TRANSACTION). PostgreSQL restarts to apply it. - Override the service's config file
config("PostgreSQL config"), which replaces the template, for a setting no variable covers.
A change applies with the next deployment of the service. The service runs a single instance.
Data, backups and imports
- Data is on the
datavolume. - The backup is a gzipped SQL dump of the environment's database. Tables matching its "excluded table contents" option keep their definition and lose their rows.
- The database import replaces the data volume: the dump is loaded while a new, empty data directory is initialized, and the imported objects are handed to the database's owner role. It accepts
.gz,.tar.gz,.tgzand.zip. Roles a dump names that this server does not have exist only while the dump is loaded.
Check the result
In the database container:
PGPASSWORD="$POSTGRES_PASSWORD" psql -h localhost -U postgres -c '\l'lists the databases and their owner roles.PGPASSWORD="$POSTGRES_PASSWORD" psql -h localhost -U postgres -d <database> -c '\dx'lists the extensions in a database.
PostgreSQL (PostGIS) on Wodby
What this service adds to the PostgreSQL service it is based on.
- The image bundles PostGIS, and
POSTGRES_DB_EXTENSIONShas a default:postgis,postgis_raster,postgis_sfcgal,fuzzystrmatch,address_standardizer,address_standardizer_data_us,postgis_tiger_geocoderandpostgis_topology. These extensions are created in a database when Wodby creates it; the application does not runCREATE EXTENSION postgis. - Setting
POSTGRES_DB_EXTENSIONSon this service replaces the whole default list. To add an extension such asvector, repeat the PostGIS extensions that are needed and append it.
Everything else, including the database, user, ownership, configuration, backups and imports, is as in the PostgreSQL service.
Check the result
In the database container, PGPASSWORD="$POSTGRES_PASSWORD" psql -h localhost -U postgres -d <database> -c 'SELECT postgis_full_version();' shows the PostGIS version in a database.
Обзор
Технический профиль PostgreSQL (PostGIS)
Версии
Основан на
Репозиторий исходного кода
Публичный Helm-чарт
Постоянные тома
Страница базы данных
Стеки
Стеки, в которые входит PostgreSQL (PostGIS)
Данные
Резервные копии и импорт данных: PostgreSQL (PostGIS)
Резервные копии вручную и по расписанию
Создавайте резервную копию, когда она нужна, или задайте расписание в пресете резервного копирования.
Импорт из архива, по URL или из резервной копии
Источником импорта может быть загруженный архив, публичный URL или готовая резервная копия совместимого сервиса.
Где хранятся архивы
StackMaster записывает каждый архив в StackMaster Blob Storage или в бакет у провайдера хранилища, подключённого как интеграция.
Конфигурация
Конфигурация сервиса PostgreSQL (PostGIS)
Тома
Файлы конфигурации
Настройки
Связанные базы данных