pg_integrity_check

pg_integrity_check — вычисление и проверка контрольных сумм отслеживаемых файлов (только сертифицированная редакция)

Синтаксис

pg_integrity_check [параметр-подключения...] [-s | --system] [-u | --user] [-c | --catalog] [-o | --output] [-l filename | --log=filename] [--syslog] [-D каталог_данных] [-C filename] [-v | --verbose] [-? | --help]

Описание

pg_integrity_check — утилита, поставляемая в составе Postgres Pro Shardman, которая может вычислять и проверять контрольные суммы важных объектов. Запуская pg_integrity_check, вы должны указать минимум один из параметров, определяющих тип отслеживаемых объектов: -s, -u или -c для неизменяемых файлов, дополнительных файлов или таблиц системных каталогов, соответственно.

Если вы используете ключ -o, pg_integrity_check вычисляет контрольные суммы и записывает их в файлы конфигурации в каталоге share/security/. Для выполнения этой команды у вас должно быть право записи в эти файлы. Ключ -o нельзя использовать вместе с -s, так как контрольные суммы неизменяемых файлов не могут перезаписываться.

Если вы не указываете ключ -o, pg_integrity_check сравнивает вычисленные контрольные суммы с соответствующими контрольными суммами в файлах конфигурации. Если контрольные суммы каких-либо из отслеживаемых объектов не совпадают, pg_integrity_check выводит сообщения о различиях.

Более подробно использование pg_integrity_check описано в Разделе 30.2.

Параметры

параметры-подключения

Стандартные параметры для подключения к базе данных: -d, -h, -p, -U. Вы должны указать параметры -d и -U для проверки контрольных сумм таблиц каталогов с ключом -c. За подробным описанием параметров подключения обратитесь к psql.

-s
--system

Проверить контрольные суммы неизменяемых файлов. В контрольных суммах неизменяемых файлов учитывается и содержимое, и атрибуты этих файлов.

-u
--user

Проверить контрольные суммы дополнительных файлов. В контрольных суммах дополнительных файлов учитывается и содержимое, и атрибуты этих файлов.

-c
--catalog

Проверить контрольные суммы для таблиц системных каталогов. Чтобы ключ -c работал корректно, вы также должны задать параметры подключения к базе данных. Сервер баз данных должен быть запущен и готов принимать подключения.

-o
--output

Пересчитать контрольные суммы и записать их в файл.

-l filename
--log=filename

Записывать результаты проверки контрольных сумм в файл журнала.

--syslog

Записывать результаты проверки контрольных сумм в syslog.

-D каталог_данных

Каталог данных кластера БД. Этот параметр необходим для определения имён файлов конфигурации при использовании ключа -u.

-C filename

Абсолютный путь к файлу конфигурации, который используется для проверки целостности таблиц системного каталога выбранной базы данных. При использовании с параметром -o pg_integrity_check записывает контрольные суммы в указанный файл. Если другие параметры не используются, pg_integrity_check проверяет данные по указанному файлу.

-v
--verbose

Выводить отладочную информацию, в том числе значения контрольных сумм.

-?
--help

Вывести справку по командной строке.

Возвращаемые значения

0 — контрольные суммы вычислены или проверены успешно.

1 — при изначальном подсчёте контрольных сумм неизменяемых файлов произошла ошибка.

2 — проверка контрольных сумм выявила изменения в одном или нескольких отслеживаемых объектах.

3 — при проверке контрольных сумм произошла неожиданная ошибка.

Примеры

Вычисление контрольных сумм для дополнительных файлов и внесение их в файл конфигурации share/security/_var_lib_pgpro_sdm-17_data.user.conf:

pg_integrity_check -u -o -D /var/lib/pgpro/sdm-17/data

Проверка целостности всех отслеживаемых объектов в базе данных postgres от имени пользователя postgres:

pg_integrity_check -s -u -c -D /var/lib/pgpro/sdm-17/data -d postgres -h localhost -p 5432 -U postgres

pg_integrity_check

pg_integrity_check — calculate and validate checksums for controlled files (certified edition only)

Synopsis

pg_integrity_check [connection-option...] [ -s | --system ] [ -u | --user ] [ -c | --catalog ] [ -o | --output ] [ -l filename | --log=filename ] [ --syslog ] [ -D datadir ] [ -C filename ] [ -v | --verbose ] [ -? | --help ]

Description

pg_integrity_check is a utility provided with Postgres Pro Shardman that can calculate and validate checksums for the objects you would like to control. When running pg_integrity_check, you must specify at least one of the options that define the type of the controlled objects: -s, -u, or -c for read-only files, additional files, or system catalog tables, respectively.

If you use the -o option, pg_integrity_check calculates checksums and writes them into configuration files under the share/security/ directory. You must have write access to the corresponding files to perform this command. You cannot use the -o option together with the -s option, since a checksum for read-only files cannot be overwritten.

If you omit the -o option, pg_integrity_check compares the calculated checksums with the corresponding checksums in the configuration files. If the checksums differ for any of the controlled objects, pg_integrity_check displays a message indicating the difference.

For details on using pg_integrity_check, see Section 30.2.

Options

connection-options

Standard options for connecting to a database: -d, -h, -p, -U. You must specify -d and -U options when validating checksums for catalog tables with the -c option. For detailed description of connection options, see psql.

-s
--system

Validate checksums for read-only files. Checksums for read-only files control both file contents and file attributes.

-u
--user

Validate checksums for additional files. Checksums for additional files control both file contents and file attributes.

-c
--catalog

Validate checksums for system catalog tables. For the -c option to work correctly, you must also specify connection parameters for the database. The database server must be started and accept connections.

-o
--output

Recalculate checksums and write it into a file.

-l filename
--log=filename

Write checksum validation results into a log file.

--syslog

Write checksum validation results into the syslog.

-D datadir

Data directory of the database cluster. This option is required to define the filenames for the generated configuration files when using -u option.

-C filename

The absolute path to the configuration file used for integrity checks of system catalog tables of the selected database. If used with the -o option, pg_integrity_check writes into the specified file. If no other option is used, pg_integrity_check checks data against the specified file.

-v
--verbose

Print debugging information, including checksum values.

-?
--help

Print command-line help.

Return Values

0 — checksums are calculated or validated successfully.

1 — an error occurred during the initial checksum calculation for read-only files.

2 — checksum validation revealed changes in one or more of the controlled objects.

3 — an unexpected error occurred during checksum validation.

Examples

Compute checksums for additional files and write them into the share/security/_var_lib_pgpro_sdm-17_data.user.conf configuration file:

pg_integrity_check -u -o -D /var/lib/pgpro/sdm-17/data

Check integrity of all controlled objects in the postgres database on behalf of the postgres user:

pg_integrity_check -s -u -c -D /var/lib/pgpro/sdm-17/data -d postgres -h localhost -p 5432 -U postgres
FAQ