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

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

  1. Остановите работу сервиса tantor-be-server-15 с помощью команды:

    systemctl stop tantor-be-server-15.service
  2. Скопируйте в директорию /var/lib/postgresql/tantor-be-15/data/ имеющийся конфигурационный файл iwtm-postgres.conf или создайте там новый со следующим содержимым:

    # -----------------------------
    # Tantor 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 = 128kB
    
    huge_pages = try                           # on, off, or try
    
    max_locks_per_transaction = 512
    temp_buffers = 32MB
    work_mem = 16MB
    effective_cache_size = 4096MB
    
    min_wal_size = 6144MB
    max_wal_size = 6144MB
    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
    # stats_temp_directory = '/var/lib/postgresql/tantor-be-15/data/pg_stat_tmp'
    
    autovacuum_max_workers = 5
    autovacuum_naptime = 20
    maintenance_work_mem = 1GB
    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

    Важно!

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

    • shared_buffers

    • work_mem

    • maintenance_work_mem

    • effective_cache_size

    • temp_buffers

    • min_wal_size

    • max_wal_size

    Настройте эти параметры под вашу систему в соответствии с официальной инструкцией PostgreSQL.

  3. Выдайте пользователю postgres права на файл iwtm-postgres.conf.
    chown postgres:postgres /var/lib/postgresql/tantor-be-15/data/iwtm-postgres.conf
  4. Добавьте в конфигурационный файл /var/lib/postgresql/tantor-be-15/data/postgresql.conf ссылку на файл iwtm-postgres.conf с помощью команды:
    echo "include = 'iwtm-postgres.conf'" >> /var/lib/postgresql/tantor-be-15/data/postgresql.conf
  5. Отредактируйте файл доступа /var/lib/postgresql/tantor-be-15/data/pg_hba.conf:
    1. После строк:

      # IPv6 local connections:
      host    all             all             ::1/128                 md5

      добавьте строку:

      host    postgres        all             0.0.0.0/0               md5

      Примечание:

      Указанные значения подходят для установки Traffic Monitor с параметрами по умолчанию. Если при установке Traffic Monitor вы будете использовать другие значения, укажите их здесь.

    2. Замените строки с помощью команд:


      sed -i "s|host[[:space:]]*all[[:space:]]*all[[:space:]]*127.0.0.1/32[[:space:]]*md5|host    all             all             127.0.0.1/32            trust|" /var/lib/postgresql/tantor-be-15/data/pg_hba.conf
      sed -i "s|local[[:space:]]*all[[:space:]]*all[[:space:]]*peer|local   all             all                                     trust|" /var/lib/postgresql/tantor-be-15/data/pg_hba.conf
  6. Создайте директорию /var/lib/pgpro/ent-15/data/tmp и назначьте ей владельца и группу с помощью команд:
    mkdir –p /var/lib/postgresql/tantor-be-15/data/tmp
    chown postgres:postgres /var/lib/postgresql/tantor-be-15/data/tmp
  7. Установите pgAgent:

    1. Запустите сервис Tantor:

      systemctl start tantor-be-server-15.service
    2. Скачайте пакет pgagent_15-4.2.2-3.rhel7.x86_64.rpm из репозитория Yum.
    3. Установите пакет с помощью команды:

      yum install pgagent_15-4.2.2-3.rhel7.x86_64.rpm
    1. Запустите сервис Tantor:

      systemctl start tantor-be-server-15.service
    2. Перейдите в рабочую директорию.
      В нашем примере:

      cd /distr
    3. Скопируйте в директорию входящий в комплект поставки архив iwtm-postgresql-15.14-x.x.x.xxx-redos-x.x.tar.gz.
    4. Распакуйте архив с помощью команды:

      tar -xvf iwtm-postgresql-15.14-x.x.x.xxx-redos-x.x.tar.gz

      В нашем примере:

      tar -xvf iwtm-postgresql-15.14-7.16.0.97-redos-7.3.tar.gz
    5. Перейдите в директорию с содержимым архива.
    6. Установите пакет pgagent_15-4.2.2-3.rhel7.x86_64.rpm с помощью команды:

      yum install pgagent_15-4.2.2-3.rhel7.x86_64.rpm
  8. Скопируйте файлы расширения:

    cp /usr/pgsql-15/share/extension/pgagent* /opt/tantor/db/15/share/postgresql/extension/
  9. Смените пользователя на postgres:
    su - postgres
  10. Подключитесь к базе данных:


    psql -p 5433
  11. Измените для администратора базы данных пароль по умолчанию:


    alter user postgres with password 'xxXX1234';
  12. Создайте нужные расширения с помощью запросов:


    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;
  13. Для выхода введите команды:


    \q
    exit
  14. Для настройки в ОС пользователя pgagent выполните команды:

    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
  15. Создайте /etc/sudoers.d/iw-pgagent со следующим содержимым:

    # allow pgagent to execute any command
    pgagent ALL = (postgres) NOPASSWD: ALL
    Defaults:pgagent !requiretty

    Вы можете сделать это с помощью команд:


    touch /etc/sudoers.d/iw-pgagent
    echo "# allow pgagent to execute any command" > /etc/sudoers.d/iw-pgagent
    echo "pgagent ALL = (postgres) NOPASSWD: ALL" >> /etc/sudoers.d/iw-pgagent
    echo 'Defaults:pgagent !requiretty' >> /etc/sudoers.d/iw-pgagent
  16. Измените для /etc/sudoers.d/iw-pgagent права, владельца и группу, выполнив команды:
    chmod 440 /etc/sudoers.d/iw-pgagent
    chown root:root /etc/sudoers.d/iw-pgagent
  17. Отредактируйте конфигурационный файл /etc/pgagent/pgagent_15.conf:

    Используйте команды:

    sed -i --follow-symlinks "s/DBPORT=5432/DBPORT=5433/" /etc/pgagent/pgagent_15.conf
    echo "LD_LIBRARY_PATH=/opt/tantor/db/15/lib/" >> /etc/pgagent/pgagent_15.conf

    Используйте команды:

    sed -i --follow-symlinks "s/DBPORT=5432/DBPORT=5433/" /etc/pgagent/pgagent-15.conf
    echo "LD_LIBRARY_PATH=/opt/tantor/db/15/lib" >> /etc/pgagent/pgagent-15.conf
  18. Включите сервис pgAgent, запустите его, а затем проверьте его статус:

    Используйте команды:

    systemctl enable pgagent_15
    systemctl start pgagent_15
    systemctl status pgagent_15
    1. Включите сервис:

      systemctl enable pgagent-15
    2. Внесите изменения в файл /etc/systemd/system/multi-user.target.wants/pgagent-15.service.
      В разделе Unit в строках: 

      After=postgresql-15.service
      BindsTo=postgresql-15.service

      замените postgresql-15.service на tantor-be-server-15.service:

      After=tantor-be-server-15.service
      BindsTo=tantor-be-server-15.service
    3. Запустите сервис и проверьте его статус:

      systemctl start pgagent-15
      systemctl status pgagent-15
  19. Создайте директорию /u02:

    mkdir /u02
  20. Создайте директории для табличных пространств и смените владельца и группу на postgres:

    mkdir /u02/pgdata
    mkdir /u02/pgdata1
    mkdir /u02/arch
    chown -R postgres:postgres /u02

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

  • Нет меток