Вы просматриваете старую версию данной страницы. Смотрите текущую версию.
Сравнить с текущим просмотр истории страницы
Версия 1 Следующий »
Если планируется использовать уже развернутую базу данных, перед установкой Системы обязательно:
- Убедитесь, что версия вашей базы данных поддерживается Traffic Monitor:
- PostgreSQL 13
- Jatoba 5
- Выполните предварительную настройку.
Настройка СУБД
Чтобы подготовить удаленную базу данных к установке компонентов Traffic Monitor, выполните на сервере базы данных следующие действия:
- Установите дополнительные пакеты, выполнив команды:
dpkg -i postgresql-11-pathman_1.5.12-1.pgdg100+1_amd64.debapt-get install pgagent - Остановите работу сервисов
postgresqlиpgagent, используя команды:systemctl stop postgresqlsystemctl stop pgagent - Создайте директории для файлов и архивов, инициализируйте базу данных и смените директориям владельца и группу на
postgresс помощью команд:mkdir -p /u01/postgreschown postgres:postgres /u01/postgreslocale -a | grep en_US.utf8 > /dev/null || echo "en_US.UTF-8 UTF-8" >> /etc/locale.genlocale-genpg_dropcluster --stop 11 mainpg_createcluster -d /u01/postgres -p 5433 11 iwtm --locale=en_US.UTF-8 --encoding=UTF8usermod -a -G shadow postgressetfacl -d -m u:postgres:r /etc/parsec/macdbsetfacl -R -m u:postgres:r /etc/parsec/macdbsetfacl -m u:postgres:rx /etc/parsec/macdbsetfacl -d -m u:postgres:r /etc/parsec/capdbsetfacl -R -m u:postgres:r /etc/parsec/capdbsetfacl -m u:postgres:rx /etc/parsec/capdb
mkdir -p /u01/postgres/tmp
chown postgres:postgres /u01/postgres/tmp
mkdir -p /u02/pgdata
chown postgres:postgres /u02/pgdata
mkdir -p /u02/pgdata1
chown postgres:postgres /u02/pgdata1
mkdir -p /u02/arch
chown postgres:postgres /u02/arch - Создайте конфигурационный файл
/u01/postgres/iwtm-postgres.conf. Например, с помощью следующей команды:touch /etc/postgresql/11/iwtm/iwtm-postgres.conf Добавьте в файл
/etc/postgresql/11/iwtm/iwtm-postgres.confследующее содержимое:# ----------------------------- # PostgreSQL configuration file # ----------------------------- # # IWTM custom values listen_addresses = '*' port = 5433 max_connections = 1000 # (change requires restart) tcp_keepalives_idle = 60 # TCP_KEEPIDLE, in seconds' tcp_keepalives_interval = 20 # TCP_KEEPINTVL, in seconds' tcp_keepalives_count = 2 # TCP_KEEPCNT shared_buffers = kB huge_pages = try # on, off, or try max_locks_per_transaction = 512 temp_buffers = MB work_mem = MB effective_cache_size = MB min_wal_size = MB max_wal_size = MB log_min_duration_statement = 120000 # -1 is disabled, 0 logs all statements track_activity_query_size = 32768 # (change requires restart) log_autovacuum_min_duration = 30000 # -1 disables, 0 logs all actions and stats_temp_directory = '/u01/postgres/pg_stat_tmp' autovacuum_max_workers = 5 autovacuum_naptime = 20 maintenance_work_mem = GB autovacuum_freeze_max_age = 1000000000 shared_preload_libraries = 'pg_stat_statements,pg_pathman' track_io_timing = on track_activity_query_size = 32768 constraint_exclusion = off # on, off, or partition
Важно!
В примере содержимого конфигурационного файла указаны пустые поля значений следующих параметров:
shared_bufferswork_memmaintenance_work_memeffective_cache_sizetemp_buffersmin_wal_sizemax_wal_size
Выполните настройки перечисленных параметров в соответствии с официальной инструкцией (доступна на английском языке).
- Смените у конфигурационного файла владельца и группу на
postgres:chown postgres:postgres /etc/postgresql/11/iwtm/iwtm-postgres.conf Добавьте в конфигурационный файл
/u01/postgres/postgresql.confссылку на файлiwtm-postgres.confс помощью команды:echo "include = 'iwtm-postgres.conf'" >> /etc/postgresql/11/iwtm/postgresql.conf- Настройте файл доступа
pg_hba.confс помощью команд:echo "# Enable not local access" >> /etc/postgresql/11/iwtm/pg_hba.confecho "host postgres all 0.0.0.0/0 md5" >> /etc/postgresql/11/iwtm/pg_hba.conf - Запустите сервис
postgresqlи проверьте его статус с помощью команд:systemctl enable postgresqlsystemctl start postgresqlsystemctl status postgresql - Измените для администратора базы данных пароль по умолчанию:
su - postgrespsql -p 5433alter user postgres password 'xxXX1234'; - Создайте требуемые расширения, выполнив запросы:
create extension if not exists adminpack;create extension if not exists dblink;create extension if not exists lo;create extension if not exists xml2;create extension if not exists tablefunc;create extension if not exists intarray;create extension if not exists file_fdw;create extension if not exists "uuid-ossp";create extension if not exists pgcrypto;create extension if not exists pgrowlocks;create extension if not exists autoinc;create extension if not exists hstore;create extension if not exists pg_stat_statements;create extension if not exists pg_buffercache;create extension if not exists pg_pathman;create extension if not exists pgagent; Для выхода введите команды:
\qexit- Для настройки в ОС пользователя
pgagentвыполните команды:groupadd -f -r pgagentuseradd -g pgagent -r -s /bin/false -c "pgAgent Job Schedule" pgagentmkdir -p /home/pgagentchmod 0700 /home/pgagentchown pgagent:pgagent /home/pgagenttouch /var/log/pgagent.logchown pgagent:pgagent /var/log/pgagent.log
touch /home/pgagent/.pgpass
echo "localhost:5433:postgres:postgres:xxXX1234" > /home/pgagent/.pgpass
chmod 0600 /home/pgagent/.pgpass
chown pgagent:pgagent /home/pgagent/.pgpass
usermod -s /bin/bash pgagent Создайте или отредактируйте файл
/etc/sudoers.d/pgagent, чтобы содержимое соответствовало образцу ниже:# allow pgagent to execute any command pgagent ALL = (postgres) NOPASSWD: ALL Defaults:pgagent !requiretty
Измените
/etc/sudoers.d/pgagentправа, владельца и группу, выполнив команды:chmod 440 /etc/sudoers.d/pgagentchown root:root /etc/sudoers.d/pgagent- Для настройки сервиса
pgagentсоздайте директорию и файл с помощью команд:mkdir -p /usr/lib/systemd/systemtouch /usr/lib/systemd/system/pgagent.service Добавьте в файл
/usr/lib/systemd/system/pgagent.serviceследующее содержимое:[Unit] Description=PgAgent for PostgreSQL After=syslog.target After=network.target After=postgresql.service After=postgresql@11-iwtm.service BindsTo=postgresql.service BindsTo=postgresql@11-iwtm.service [Service] Type=forking User=pgagent Group=pgagent # 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 OOMScoreAdjust=-1000 ExecStart=/usr/bin/pgagent -s /var/log/pgagent.log hostaddr=127.0.0.1 dbname=postgres user=postgres port=5433 KillMode=mixed KillSignal=SIGINT # Give a reasonable amount of time for the server to start up/shut down TimeoutSec=300 [Install] WantedBy=multi-user.target WantedBy=postgresql.service WantedBy=postgresql@11-iwtm.service
- Для применения изменений в конфигурации сервиса выполните команду::
systemctl daemon-reload
- Запустите сервис
pgagentи проверьте его статус с помощью команд:systemctl enable pgagentsystemctl start pgagentsystemctl status pgagent
По завершении настройки убедитесь в отсутствии критических ошибок в логах базы данных и /var/log/pgagent.log.
- В файле
/usr/lib/systemd/system/jatoba-5.serviceизмените директорию, указанную в строкеEnvironment=PGDATA=, на/u01/postgres. - Для применения изменений в конфигурации сервиса выполните команду:
systemctl daemon-reload - Создайте директории для файлов и архивов, смените директориям владельца и группу на
postgres. Используйте команды:mkdir -p /u01/postgreschown postgres:postgres /u01/postgresmkdir -p /u02/pgdatamkdir -p /u02/pgdata1mkdir -p /u02/archchown -R postgres:postgres /u02 - Инициализируйте базу данных. Для этого:
- Перейдите в директорию
usr/jatoba-5/bin/:cd /usr/jatoba-5/bin/ - Используйте команду инициализации:
PGSETUP_INITDB_OPTIONS=" --encoding=UTF8" ./jatoba-setup initdb jatoba-5 --encoding=UTF8 --locale=en_US.UTF-8 -D /u01/postgres
- Перейдите в директорию
Создайте временную директорию и смените владельца и группу на
postgres. Используйте команды:mkdir -p /u01/postgres/tmpchown postgres:postgres /u01/postgres/tmpВажно!
Создание временной директории
tmpдопустимо только после инициализации базы данных.- В директории
/u01/postgres/создайте конфигурационный файлiwtm-postgres.conf:touch /u01/postgres/iwtm-postgres.conf Добавьте в файл
iwtm-postgres.confследующее содержимое:# ----------------------------- # PostgreSQL configuration file # ----------------------------- # # IWTM custom values listen_addresses = '*' port = 5433 max_connections = 1000 # (change requires restart) tcp_keepalives_idle = 60 # TCP_KEEPIDLE, in seconds' tcp_keepalives_interval = 20 # TCP_KEEPINTVL, in seconds' tcp_keepalives_count = 2 # TCP_KEEPCNT shared_buffers = kB # min 128KiB huge_pages = try # on, off, or try max_locks_per_transaction = 256 temp_buffers = MB work_mem = MB effective_cache_size = MB min_wal_size = MB max_wal_size = MB lc_messages = 'en_US.UTF-8' # locale for system error message log_directory = 'pg_log' log_filename = 'postgresql.log' # log file name pattern log_rotation_age = 0 # Automatic rotation of logfiles will happen after that time. 0 disables. log_rotation_size = 0 # Automatic rotation of logfiles will happen after that much log output. 0 disables. log_min_duration_statement = 120000 # -1 is disabled, 0 logs all statements track_activity_query_size = 32768 # (change requires restart) log_autovacuum_min_duration = 30000 # -1 disables, 0 logs all actions and autovacuum_max_workers = 5 autovacuum_naptime = 20 max_parallel_maintenance_workers = 8 maintenance_work_mem = MB autovacuum_freeze_max_age = 1000000000 shared_preload_libraries = 'pg_stat_statements' track_io_timing = on track_activity_query_size = 32768 constraint_exclusion = off # on, off, or partition standard_conforming_strings = on
Важно!
В примере содержимого конфигурационного файла указаны пустые поля значений следующих параметров:
shared_bufferswork_memmaintenance_work_memeffective_cache_sizetemp_buffersmin_wal_sizemax_wal_size
Выполните настройки перечисленных параметров в соответствии с официальной инструкцией (доступна на английском языке).
- Смените у конфигурационного файла владельца и группу на
postgres:chown postgres:postgres /u01/postgres/iwtm-postgres.conf - Добавьте в конфигурационный файл
/u01/postgres/postgresql.confссылку на файлiwtm-postgres.confс помощью команды:echo "include = 'iwtm-postgres.conf'" >> /u01/postgres/postgresql.conf - Настройте файл доступа
pg_hba.confс помощью команд:sed -i "s|local[[:space:]]*all[[:space:]]*all[[:space:]]*peer|local all all trust|" /u01/postgres/pg_hba.confsed -i "s|host[[:space:]]*all[[:space:]]*all[[:space:]]*127.0.0.1/32[[:space:]]*ident|host all all 127.0.0.1/32 trust|" /u01/postgres/pg_hba.confsed -i "s|host[[:space:]]*all[[:space:]]*all[[:space:]]*::1/128[[:space:]]*ident|host all all ::1/128 trust|" /u01/postgres/pg_hba.confecho "# Enable not local access" >> /u01/postgres/pg_hba.confecho "host postgres all 0.0.0.0/0 md5" >> /u01/postgres/pg_hba.conf - Активируйте СУБД согласно Руководству по установке СУБД Jatoba.
- Запустите сервис
jatoba-5и проверьте его статус. Используйте команды:systemctl enable jatoba-5systemctl start jatoba-5systemctl status jatoba-5 - Установите pgAgent из репозитория ОС:
yum install pgagent_15 Перенесите файлы для установки расширений из каталога
postgresql-15в каталогjatoba-5. Для этого:- Перейдите в
/usr/pgsql-15/share:cd /usr/pgsql-15/share - Используйте команды смены директорий:
cp -R pgagent_15-x.x.x /usr/jatoba-5/share/cp extension/* /usr/jatoba-5/share/extension/Важно!
В первой команде замените имя
pgagent_15-x.x.xна точное название каталога, расположенного в директории/usr/jatoba-5/share/. Например,pgagent_15-4.0.0.
- Перейдите в
- Измените пароль по умолчанию для администратора базы данных:
su - postgrespsql -p 5433alter user postgres password 'xxXX1234'; Создайте расширения, выполнив запросы:
create extension if not exists adminpack;create extension if not exists dblink;create extension if not exists lo;create extension if not exists xml2;create extension if not exists tablefunc;create extension if not exists intarray;create extension if not exists file_fdw;create extension if not exists "uuid-ossp";create extension if not exists pgcrypto;create extension if not exists pgrowlocks;create extension if not exists autoinc;create extension if not exists hstore;create extension if not exists pg_stat_statements;create extension if not exists pg_buffercache;create extension if not exists pgagent;- Для выхода введите команды:
\qexit - Для настройки в ОС пользователя pgAgent выполните команды:
mkdir /home/pgagenttouch /home/pgagent/.pgpassecho "127.0.0.1:5433:postgres:postgres:xxXX1234" > /home/pgagent/.pgpasschmod 0600 /home/pgagent/.pgpasschown pgagent:pgagent /home/pgagent/.pgpassusermod -s /bin/bash pgagent Создайте или отредактируйте файл
/etc/sudoers.d/pgagent, чтобы содержимое соответствовало образцу ниже:# allow pgagent to execute any command pgagent ALL = (postgres) NOPASSWD: ALL Defaults:pgagent !requiretty
- Измените у файла
/etc/sudoers.d/pgagentправа, владельца и группу, выполнив команды:chmod 440 /etc/sudoers.d/pgagentchown root:root /etc/sudoers.d/pgagent - Запустите сервис
pgagent_15и проверьте его статус с помощью команд:systemctl enable pgagent_15systemctl start pgagent_15systemctl status pgagent_15
По завершении настройки убедитесь в отсутствии критических ошибок в логах базы данных и /var/log/pgagent_15.log.
- Нет меток