F.7. basic_archive — пример модуля архивирования WAL #

Модуль basic_archive является примером модуля архивирования. Он копирует файлы завершённых сегментов WAL в указанный каталог. Он не очень полезен сам по себе, но на его основе можно разработать собственный модуля архивирования. За дополнительными сведениями о модулях архивирования обратитесь к разделу Глава 50.

Чтобы этот модуль работал, его нужно добавить в shared_preload_libraries, а также включить режим archive_mode.

F.7.1. Параметры конфигурации #

basic_archive.archive_directory (string)

Каталог, в который сервер должен копировать файлы сегментов WAL. Этот каталог уже должен существовать. Значение по умолчанию — пустая строка, то есть архивирование WAL остановлено, но если archive_mode включён, сервер будет накапливать файлы сегментов WAL, ожидая, что значение будет вскоре задано.

Эти параметры должны задаваться в postgresql.conf. Обычное использование выглядит так:

# postgresql.conf
archive_mode = 'on'
archive_library = 'basic_archive'
basic_archive.archive_directory = '/path/to/archive/directory'

F.7.2. Примечания #

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

F.7.3. Автор #

Натан Боссарт (Nathan Bossart)

F.7. basic_archive — an example WAL archive module #

basic_archive is an example of an archive module. This module copies completed WAL segment files to the specified directory. This may not be especially useful, but it can serve as a starting point for developing your own archive module. For more information about archive modules, see Chapter 50.

In order to function, this module must be loaded via archive_library, and archive_mode must be enabled.

F.7.1. Configuration Parameters #

basic_archive.archive_directory (string)

The directory where the server should copy WAL segment files. This directory must already exist. The default is an empty string, which effectively halts WAL archiving, but if archive_mode is enabled, the server will accumulate WAL segment files in the expectation that a value will soon be provided.

These parameters must be set in postgresql.conf. Typical usage might be:

# postgresql.conf
archive_mode = 'on'
archive_library = 'basic_archive'
basic_archive.archive_directory = '/path/to/archive/directory'

F.7.2. Notes #

Server crashes may leave temporary files with the prefix archtemp in the archive directory. It is recommended to delete such files before restarting the server after a crash. It is safe to remove such files while the server is running as long as they are unrelated to any archiving still in progress, but users should use extra caution when doing so.

F.7.3. Author #

Nathan Bossart

FAQ