Stylesheet conf/userstyle.css not found, please contact the developer of "dokuwiki_2024" template.
linux:postgresql:pgagent
Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слеваПредыдущая версия | |||
linux:postgresql:pgagent [2023/01/20 05:46] – dx | linux:postgresql:pgagent [2023/05/21 14:23] (текущий) – dx | ||
---|---|---|---|
Строка 1: | Строка 1: | ||
+ | ====== Установка pgAgent в Debian 11 ====== | ||
+ | К сожалению PostgreSQL в отличие от [[microsoft: | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | Установку и настройку pgagent в документации нельзя назвать исчерпывающей из-за чего собственно и появилась эта заметка. Тем не менее ссылки на документацию оставлю | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ===== apt install ===== | ||
+ | |||
+ | <code bash> | ||
+ | apt-get update | ||
+ | apt-get install pgagent | ||
+ | </ | ||
+ | |||
+ | ===== Файл pgpass ===== | ||
+ | |||
+ | Чтобы избежать неприятностей и быть в безопасности [[https:// | ||
+ | |||
+ | Отдельно про файл pgpass я [[linux: | ||
+ | |||
+ | По-умолчанию используется пользователь '' | ||
+ | |||
+ | <code bash> | ||
+ | su - postgres | ||
+ | echo localhost: | ||
+ | chmod 600 ~/.pgpass | ||
+ | chown postgres: | ||
+ | </ | ||
+ | |||
+ | ===== Логи ===== | ||
+ | |||
+ | Создаём директорию для логов и выставляем права | ||
+ | |||
+ | <code bash> | ||
+ | mkdir / | ||
+ | chown -R postgres: | ||
+ | chmod g+w / | ||
+ | </ | ||
+ | |||
+ | ===== PostgreSQL ===== | ||
+ | |||
+ | Создаём в базе **postgres** новое [[https:// | ||
+ | |||
+ | <code sql> | ||
+ | CREATE EXTENSION pgagent; | ||
+ | |||
+ | CREATE USER " | ||
+ | LOGIN | ||
+ | NOSUPERUSER | ||
+ | INHERIT | ||
+ | NOCREATEDB | ||
+ | NOCREATEROLE | ||
+ | NOREPLICATION | ||
+ | encrypted password ' | ||
+ | |||
+ | GRANT USAGE ON SCHEMA pgagent TO pgagent; | ||
+ | GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA pgagent TO pgagent; | ||
+ | GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA pgagent TO pgagent; | ||
+ | </ | ||
+ | |||
+ | Проверяем соединение (журнал Postgres в файле ''/ | ||
+ | |||
+ | **psql** | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | **pgAgent** | ||
+ | |||
+ | <code bash> | ||
+ | su - postgres | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ===== pgagent.conf ===== | ||
+ | |||
+ | Создаём файл ''/ | ||
+ | |||
+ | <code bash> | ||
+ | DBNAME=postgres | ||
+ | DBUSER=pgagent | ||
+ | DBHOST=localhost | ||
+ | DBPORT=5432 | ||
+ | # ERROR=0, WARNING=1, DEBUG=2 | ||
+ | LOGLEVEL=1 | ||
+ | LOGFILE="/ | ||
+ | </ | ||
+ | |||
+ | ===== systemd сервис ===== | ||
+ | |||
+ | Создаём файл ''/ | ||
+ | |||
+ | <code bash> | ||
+ | [Unit] | ||
+ | Description=pgAgent for PostgreSQL | ||
+ | After=syslog.target | ||
+ | After=network.target | ||
+ | |||
+ | [Service] | ||
+ | Type=forking | ||
+ | |||
+ | User=postgres | ||
+ | Group=postgres | ||
+ | |||
+ | # Location of the configuration file | ||
+ | EnvironmentFile=/ | ||
+ | |||
+ | # Where to send early-startup messages from the server (before the logging | ||
+ | # options of pgagent.conf take effect) | ||
+ | # This is normally controlled by the global default set by systemd | ||
+ | # StandardOutput=syslog | ||
+ | |||
+ | # Disable OOM kill on the postmaster | ||
+ | OOMScoreAdjust=-1000 | ||
+ | |||
+ | ExecStart=/ | ||
+ | KillMode=mixed | ||
+ | KillSignal=SIGINT | ||
+ | |||
+ | Restart=on-failure | ||
+ | |||
+ | # Give a reasonable amount of time for the server to start up/shut down | ||
+ | TimeoutSec=300 | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Для удобства можно изменить расположение конфигурационного файла | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Запускаем наш systemd сервис | ||
+ | |||
+ | <code bash> | ||
+ | systemctl daemon-reload | ||
+ | systemctl enable pgagent | ||
+ | systemctl start pgagent | ||
+ | </ | ||
+ | |||
+ | ===== Logrotate ===== | ||
+ | |||
+ | Теперь нужно настроить **logrotate** о чём мы все с вами обычно забываем. | ||
+ | |||
+ | Создаём файл ''/ | ||
+ | |||
+ | <code bash> | ||
+ | / | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | su root root | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Проверка logrotate | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | EOM | ||
+ | |||
+ | {{tag> |