Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.
Комментарий: Published by Scroll Versions from space TMIG and version 7.16
Sv translation
languageru

Чтобы подготовить удаленную базу данных к установке компонентов Traffic Monitor, выполните на сервере базы данных следующие действия:

  1. Установите дополнительные пакеты, выполнив команды:

    Блок кода
    languagetext
    yum -y install pgagent_15* 
    yum -y install postgresql15-contrib

  2. Остановите работу сервиса postgresql, используя команды:

    Блок кода
    languagetext
    systemctl stop postgresql
  3. Создайте директории для файлов и архивов, инициализируйте базу данных и смените директориям владельца и группу на postgres:

    Блок кода
    languagetext
    mkdir -p /u01/postgres
    chown postgres:postgres /u01/postgres
    export PGSETUP_INITDB_OPTIONS=" --encoding=UTF8"
    sudo -u postgres /usr/pgsql-15/bin/initdb --encoding=UTF8 --locale=en_US.UTF-8 -D /u01/postgres/
    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

  4. Создайте конфигурационный файл /etc/postgresql/15/iwtm/iwtm-postgres.conf. Например, с помощью команды:

    Блок кода
    languagetext
    touch /etc/postgresql/15/iwtm/iwtm-postgres.conf 
  5. Добавьте в файл /etc/postgresql/15/iwtm/iwtm-postgres.conf:

    Блок кода
    languagetext
    # -----------------------------
    # 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'
    track_io_timing = on
    track_activity_query_size = 32768
    enable_partitionwise_join = on
    
    constraint_exclusion = off                            # on, off, or partition
    standard_conforming_strings = on

    # IWTM custom values Astra Linux specific ac_ignore_socket_maclabel = false ac_ignore_server_maclabel = false ac_auto_adjust_macs = false ac_audit_destination = 'logfile'

    Предупреждение
    titleВажно!

    В примере содержимого конфигурационного файла указаны пустые поля значений для параметров:

    • shared_buffers

    • work_mem

    • maintenance_work_mem

    • effective_cache_size

    • temp_buffers

    • min_wal_size

    • max_wal_size

    Настройте эти параметры в соответствии с официальной инструкцией (на английском).

  6. Смените у конфигурационного файла владельца и группу на postgres:

    Блок кода
    languagetext
    chown postgres:postgres /etc/postgresql/15/iwtm/iwtm-postgres.conf
  7. Добавьте в конфигурационный файл /etc/postgresql/15/iwtm/iwtm-postgres.conf ссылку на файл iwtm-postgres.conf с помощью команды:

    Блок кода
    languagetext
    echo "include = 'iwtm-postgres.conf'" >> /etc/postgresql/15/iwtm/iwtm-postgres.conf
  8. Настройте файл доступа /etc/postgresql/15/iwtm/pg_hba.conf с помощью команд:

    Блок кода
    languagetext
    sed -i "s|local[[:space:]]*all[[:space:]]*all[[:space:]]*peer|local   all             all                                     trust|" /etc/postgresql/15/iwtm/pg_hba.conf 
    sed -i "s|host[[:space:]]*all[[:space:]]*all[[:space:]]*127.0.0.1/32[[:space:]]*ident|host    all             all             127.0.0.1/32            trust|" /etc/postgresql/15/iwtm/pg_hba.conf 
    sed -i "s|host[[:space:]]*all[[:space:]]*all[[:space:]]*::1/128[[:space:]]*ident|host    all             all             ::1/128                 trust|" /etc/postgresql/15/iwtm/pg_hba.conf 
    echo "# Enable not local access" >> etc/postgresql/15/iwtm/pg_hba.conf 
    echo "host    postgres        all             0.0.0.0/0               md5" >> /etc/postgresql/15/iwtm/pg_hba.conf
  9. Откройте файл доступа pg_hba.conf и убедитесь, что в нем присутствуют строки:

    Блок кода
    local   all             all                                     trust
    host    all             all             127.0.0.1/32            trust
    host    all             all             ::1/128                 trust
    host    postgres        all             0.0.0.0/0               md5

    Если строки отсутствуют, внесите их вручную.

  10. Запустите сервис postgresql и проверьте его статус с помощью команд:

    Блок кода
    languagetext
    systemctl enable postgresql
    systemctl start postgresql
    systemctl status postgresql
  11. Измените для администратора базы данных пароль по умолчанию:

    Блок кода
    languagetext
    su - postgres
    psql -p 5433
    alter user postgres password 'xxXX1234';
  12. Создайте нужные расширения, выполнив запросы:

    Блок кода
    languagetext
    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_buffercache;
    create extension if not exists pgagent;
  13. Для выхода введите команды:

    Блок кода
    languagetext
    \q
    exit
  14. Для настройки в ОС пользователя pgagent выполните команды:
    Блок кода
    languagetext
    groupadd -f -r pgagent
    useradd -g pgagent -r -s /bin/false -c "pgAgent Job Schedule" pgagent
    mkdir -p /home/pgagent
    chmod 0700 /home/pgagent
    chown pgagent:pgagent /home/pgagent
    touch /var/log/pgagent.log
    chown 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
  15. Создайте или отредактируйте файл /etc/sudoers.d/pgagent, чтобы его содержимое соответствовало образцу:

    # allow pgagent to execute any command
    pgagent ALL = (postgres) NOPASSWD: ALL
    Defaults:pgagent !requiretty
    Предупреждение
    titleВажно!

    Пустая строка в конце файла pgagent обязательна.

  16. Измените для /etc/sudoers.d/pgagent права, владельца и группу, выполнив команды:

    Блок кода
    languagetext
    chmod 440 /etc/sudoers.d/pgagent
    chown root:root /etc/sudoers.d/pgagent
  17. Для настройки сервиса pgagent создайте директорию и файл с помощью команд:

    Блок кода
    languagetext
    mkdir -p /usr/lib/systemd/system
    touch /usr/lib/systemd/system/pgagent.service
  18. Добавьте в файл /usr/lib/systemd/system/pgagent.service:

    Блок кода
    languagetext
    [Unit]
    Description=PgAgent for PostgreSQL
    After=syslog.target
    After=network.target
    After=postgresql.service
    After=postgresql@15-iwtm.service
    BindsTo=postgresql.service
    BindsTo=postgresql@15-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@15-iwtm.service
  19. Для применения изменений в конфигурации сервиса выполните команду:

    Блок кода
    languagetext
    systemctl daemon-reload
  20. В конфигурационном файле /var/log/pgagent.conf измените значение параметра DBPORT с 5432 на 5433:

    Блок кода
    languagetext
    sed -i --follow-symlinks "s/DBPORT=5432/DBPORT=5433/" /var/log/pgagent.conf
  21. Запустите сервис pgagent и проверьте его статус с помощью команд:

    Блок кода
    languagetext
    systemctl enable pgagent
    systemctl start pgagent
    systemctl status pgagent

По завершении настройки убедитесь в отсутствии критических ошибок в логах базы данных и /var/log/pgagent.log.

Предупреждение
titleВажно!

Если вы настраиваете удаленную Базу данных (remote) на ОС Astra Linux "Смоленск" версии 1.8.6, то необходимо повысить мандатный доступ для пользователя iwtm. Для этого установите в файле /etc/postgresql/15/iwtm/iwtm-postgres.conf значение ac_ignore_maclabel = true

Это действие выполнять не нужно, если вы используете ОС Astra Linux версии 1.8 в редакциях "Воронеж" или "Орел". 

Sv translation
languageen

To prepare a remote database for installation of Traffic Monitor components, follow these steps on the database server:

  1. Install additional packages running the commands:

    Блок кода
    languagetext
    yum -y install pgagent_15* postgresql15-contrib
  2. Stop postgresql and pgagent services operation using the commands:

    Блок кода
    languagetext
    systemctl stop postgresql-15
    systemctl stop pgagent_15
  3. Create a file /etc/systemd/system/postgresql-15.service.d/override.conf or add the following content to it:

    Блок кода
    [Service]
    Environment=PGDATA=/u01/postgres
  4. To apply changes to service configuration, run the command:

    Блок кода
    languagetext
    systemctl daemon-reload
  5. Create directories for files and archives, initialize the database and change the directory's owner as well as the group to postgres:

    Блок кода
    languagetext
    mkdir -p /u01/postgres
    chown postgres:postgres /u01/postgres
    export PGSETUP_INITDB_OPTIONS=" --encoding=UTF8"
    sudo -u postgres /usr/pgsql-15/bin/initdb --encoding=UTF8 --locale=en_US.UTF-8 -D /u01/postgres/
    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
  6. Create a configuration file /u01/postgres/iwtm-postgres.conf. For example, use the command as follows:

    Блок кода
    languagetext
    touch /u01/postgres/iwtm-postgres.conf
  7. To /u01/postgres/iwtm-postgres.conf file, add the following content:

    Блок кода
    languagetext
    # -----------------------------
    # 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'
    track_io_timing = on
    track_activity_query_size = 32768
    enable_partitionwise_join = on
    
    constraint_exclusion = off                      # on, off, or partition
    standard_conforming_strings = on
    Предупреждение
    titleImportant!

    The configuration file's content above contains empty value fields as per parameters:

    • shared_buffers

    • work_mem

    • maintenance_work_mem

    • effective_cache_size

    • temp_buffers

    • min_wal_size

    • max_wal_size

    Configure these parameters according to official instructions. 

  8. Change the configuration file's owner and group to postgres:
    Блок кода
    languagetext
    chown postgres:postgres /u01/postgres/iwtm-postgres.conf
  9. In /u01/postgres/postgresql.conf file, add a link to iwtm-postgres.conf file. Use the command:

    Блок кода
    languagetext
    echo "include = 'iwtm-postgres.conf'" >> /u01/postgres/postgresql.conf
  10. Configure the access file pg_hba.conf using the commands:

    Блок кода
    languagetext
    sed -i "s|local[[:space:]]*all[[:space:]]*all[[:space:]]*peer|local   all             all                                     trust|" /u01/postgres/pg_hba.conf
    sed -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.conf
    sed -i "s|host[[:space:]]*all[[:space:]]*all[[:space:]]*::1/128[[:space:]]*ident|host    all             all             ::1/128                 trust|" /u01/postgres/pg_hba.conf
    echo "# Enable not local access" >> /u01/postgres/pg_hba.conf
    echo "host    postgres        all             0.0.0.0/0               md5" >> /u01/postgres/pg_hba.conf
  11. Start postgresql service and check its status using the commands:
    Блок кода
    languagetext
    systemctl enable postgresql-15
    systemctl start postgresql-15
    systemctl status postgresql-15
  12. Change the database administrator's default password:

    Блок кода
    languagetext
    su - postgres psql -p 5433 alter user postgres password 'xxXX1234';
  13. Create all required extensions running the queries below:

    Блок кода
    languagetext
    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;
  14. To exit, enter the commands:

    Блок кода
    languagetext
    \q
    exit
  15. To configure pgagent user in OS, run the commands:
    Блок кода
    languagetext
    mkdir /home/pgagent
    touch /home/pgagent/.pgpass
    echo "127.0.0.1:5433:postgres:postgres:xxXX1234" > /home/pgagent/.pgpass
    chmod 0600 /home/pgagent/.pgpass
    chown pgagent:pgagent /home/pgagent/.pgpass
    usermod -s /bin/bash pgagent
  16. Create or edit the file /etc/sudoers.d/pgagent, so that the content looks as follows:

    # allow pgagent to execute any command
    pgagent ALL = (postgres) NOPASSWD: ALL
    Defaults:pgagent !requiretty
    Предупреждение
    titleImportant!

    Empty line at the end of pgagent file is compulsory.

  17. Change the privileges, owner and group as per /etc/sudoers.d/pgagent. Run the commands:

    Блок кода
    languagetext
    chmod 440 /etc/sudoers.d/pgagent
    chown root:root /etc/sudoers.d/pgagent
  18. In /etc/pgagent/pgagent_15.conf configuration file, change the value of DBPORT parameter from 5432 to 5433:

    Блок кода
    languagetext
    sed -i --follow-symlinks "s/DBPORT=5432/DBPORT=5433/" /etc/pgagent/pgagent_15.conf
  19. Run pgagent and check its status using the commands:

    Блок кода
    languagetext
    systemctl enable pgagent_15
    systemctl start pgagent_15
    systemctl status pgagent_15

Once you have configured the database, make sure there are no critical errors in /var/log/pgagent_15.log and database logs.