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

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

Ключ

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

Если дальнейшее хранение данных не требуется, то Вы можете воспользоваться процедурой удаления ежедневных ТП (iwtm_iwtm_delete_tablespaces). Данная процедура позволяет автоматически удалить все данные, хранящиеся в табличном пространстве, сегменты, табличное пространство и файлы данных.

Предупреждение
titleВажно!
  1. Удаление табличных пространств – необратимая операция. После выполнения этой операции Вы не сможете восстановить удаленные данные.
  2. Процедура iwtm_iwtm_delete_tablespaces не работает с теми табличными пространствами, которые были отключены/подключены вручную.

В результате выполнения этой процедуры удаляются все ежедневные ТП (в т.ч. информация об архивированных ежедневных ТП), которые удовлетворяют следующему условию:

Дата создания табличного пространства меньше или равна разнице между текущей датой и заданным интервалом времени для удаления табличного пространства.

Информация
titleПримечание:

Если архивированное ежедневное ТП не подлежит восстановлению (т.к. информация о нем была удалена из базы данных), вы можете удалить файлы данных этого ТП из архива.

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

Во время удаления табличных пространств доступ к соответствующим таблицам закрыт. По этой причине в лог-файлах процессов iw_deliver, iw_x2db, iw_updater могут отображаться ошибки доступа к базе данных. После удаления ТП эти процессы восстанавливают доступ к БД автоматически.

Рекомендуется запускать задание на удаление данных ежедневно. В противном случае количество удаляемых данных увеличится, что приведет к большим временным затратам на выполнение данной процедуры и, как следствие, к увеличению времени простоя сервера Traffic Monitor.

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

Если в качестве интервала времени используются месяцы или годы, то рекомендуется в расчете использовать максимальное значение интервала. Для месяца – 31 день. Для года – 366 дней. Например, чтобы удалять ежедневные ТП старше 4-х лет, в задании iwtm _iwtm_delete_tablespaces укажите интервал 366*4=1464 дня.

Определение интервала времени для отключения ежедневных ТП
Для автоматического отключения табличных пространств (по умолчанию функция выключена) вы можете использовать различные сценарии (запускаются от имени владельца схемы данных). Установите срок хранения информации об архивных ТП:

  • Для ЕТП, хранящего объекты со статусом Нарушение:
    begin;

    select sp_setting_set('violation_delete_enabled', '1');

    select sp_setting_set('violation_delete_period', 'D');

    commit;

  • Для ЕТП, хранящего объекты со статусом Нет нарушений:
    begin;

    select sp_setting_set('noviolation_delete_enabled', '1');

    select sp_setting_set('noviolation_delete_period', 'D');

    commit;
  • Для ЕТП, хранящего снимки экрана (скриншоты):
    begin;

    select sp_setting_set('other_delete_enabled', '1');

    select sp_setting_set('other_delete_period', 'D');

    commit;
    где:
    1 – показатель того, что автоматическое удаление включено (чтобы выключить, используйте значение 0);
    D – количество дней, по прошествии которых ежедневное табличное пространство будет отключено в БД. Это число должно быть больше устанавливаемого количества дней до архивирования ежедневного ТП (см. "Автоматическое архивирование ежедневных табличных пространств").
    После отключения архивных ТП от БД (статус Offline) они становятся недоступны Системе. 

Удаление архивированных ТП

При отключении в БД архивированных ежедневных ТП в Системе остаются файлы данных (по умолчанию в директории /u02/arch). Чтобы освободить пространство на жестком диске, можно (на выбор):

  • удалить их вручную;
  • добавить новые задачи, запускаемые по расписанию в файле /etc/cron.d/iwtm_error_queue . cleanup или в другом файле с задачами в этой директории.
Информация
titleПример

Чтобы удалить все архивированные ежедневные ТП старше 150 суток:

  1. Откройте на редактирование файл   /etc/cron.d/iwtm_error_queuecleanup или другой файл с задачами в этой директории.
  2. Добавьте строки:
    35 3 * * * root find /u02/arch/ -type f -mtime +150 -delete > /dev/null 2>&1 &
    40 3 * * * root find /u02/arch/ -type d -ctime +10 -empty -delete > /dev/null 2>&1 &
  3. Сохраните изменения.
  4. Примените новые настройки сервиса cron:service
    systemctl reload crond reload

Удаление ежедневных ТП вручную

Если вам требуется немедленно удалить ежедневные ТП (например, из-за нехватки места в файловой системе был изменен интервал удаления, но следующий запуск задания произойдет нескоро), от имени владельца схемы базы данных выполните сценарий:

select pkg_part_delete_tablespaces();

Если требуется удалить одно ЭТП, выполните сценарий, указав его номер (tbs_id):

select pkg_part_delete_tablespace(<tbs_id>);

Удаление ежедневных ТП с помощью скрипта

Если вам требуется настроить автоматическое удаления ежедневных ТП, используйте скрипт /opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh или /opt/iw/tm5/bin/dbtools/dbconf-jobs-postgres.sh. Возможны команды:

ЦельКоманда

Задать период для удаления

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh set violation|noviolation|other <days> [-v] 

Включить автоудаление

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh enable violation|noviolation|other [-v]

Выключить автоудаление

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh disable violation|noviolation|other [-v]
Просмотреть статус настроек
/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh show [-v]
Удалить все ЕТП
/opt/iw/tm5/bin/dbtools/dbconf-jobs-postgres.sh start iwtm_delete_tablespace
Информация
titleПример

Чтобы удалить все объекты со статусом "Нет нарушения", старше 15 суток, выполните команды:

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh set noviolation 15 [-v]

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh enable noviolation [-v]



Sv translation
languageen

If you do not need to further store the data, you can use the procedure for deleting daily tablespaces (iwtm_iwtm_delete_tablespaces). The procedure automatically deletes all the data in a tablespace, segments, and also the tablespace and data files.

Предупреждение
titleWarning!
  1. Deleting tablespaces cannot be undone. If you complete the operation, you will not be able to restore the deleted data.
  2. iwtm_iwtm_delete_tablespaces job cannot operate tablespaces which were disconnected/connected manually.

As a result, this procedure will remove all the daily tablespaces (including information about the archived daily tablespaces), which satisfy the following condition:

The date of creating a tablespace is less or equal to the difference between the current date and the specified time interval for deleting the tablespace.

Информация
titleNote:

If the archived daily tablespace cannot be restored (because the information in it was removed from the database), then you can delete data files of this tablespace from the archive.

Предупреждение
titleWarning!

While deleting tablespaces, access to the corresponding tables is closed. For this reason, log files of the iw_deliver, iw_x2db, iw_updater processes may contain database access errors. Once tablespaces are deleted, these processes automatically restore access to the database.

We recommend running a job to delete data daily. Otherwise, the amount of deleted data increases, which increases the time for running the procedure and consequently increases the idle time of the Traffic Monitor Server.

Предупреждение
titleWarning!

If months or years are used as a time interval, then we recommend you to apply the maximal interval value in the counting: 31 days for a month and 366 days for a year. For example, to delete daily TS older than 4 years, specify 366*4=1464 days interval in iwtm _iwtm_delete_tablespaces job.

Setting the interval of daily TS deletion

To perform TS deletion automatically (by default the function is disabled) you can use the following scripts (run under the account of the database schema owner). Specify period to store information of archived tablespaces:

  • For daily TS storing objects with Violation status:
    begin;

    select sp_setting_set('violation_delete_enabled', '1');

    select sp_setting_set('violation_delete_period', 'D');

    commit;

  • For daily TS storing objects with No Violation status:
    begin;

    select sp_setting_set('noviolation_delete_enabled', '1');

    select sp_setting_set('noviolation_delete_period', 'D');

    commit;
  • For daily TS storing screenshots:
    begin;

    select sp_setting_set('other_delete_enabled', '1');

    select sp_setting_set('other_delete_period', 'D');

    commit;

where:

1 indicates that automatical deletion is enabled (to disable it, specify 0 instead);

D is a number of days after which the daily TS will be deleted by the System. This number should be larger than the set number of days before archiving the daily tablespace (see "Автоматическое архивирование ежедневных табличных пространств"). 

After removal of the tablespaces disconnected from the database (with Offline status), they become unavailable in the System.

Deleting archived tablespaces

When deleting archived daily tablespaces from the database, datafiles remain in the System (by default, they are stored in the /u02/arch directory directory). To free up disk space on your hard drive, you can either:

  • delete tablespaces manually;

  • add new tasks to be started according to the schedule from the file scheduled tasks. You can add tasks either in the /etc/cron.d/iwtm_error_queuecleanup file or in another file with tasks in the directory. 
Информация
titleExample:

To delete all archived daily tablespaces that are older than 150 days:

  1. Open for editing the /etc/cron.d/iwtm_error_queue file for editingcleanup file or another file with tasks in the directory.
  2. Add lines:
    35 3 * * * root find /u02/arch/ -type f -mtime +150 -delete > /dev/null 2>&1 &
    40 3 * * * root find /u02/arch/ -type d -ctime +10 -empty -delete > /dev/null 2>&1 &
  3. Save changes.
  4. Apply new settings of the cron service: service
    systemctl reload crond reload

Deleting daily tablespaces manually

If you need to delete daily tablespaces immediately (e.g., due to file system space shortage the interval of deletion was changed, but the next launch of the job will not happen soon), then run the following script on behalf of the database scheme owner:

select pkg_part_delete_tablespaces();

If you need to delete only one daily tablespace, then run the script with this tablespace number (tbs_id) specified:

select pkg_part_delete_tablespace(<tbs_id>);

Deleting daily tablespaces with a script 

If you want to configure automatic deletion of daily tablespaces, use /opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh or /opt/iw/tm5/bin/dbtools/dbconf-jobs-postgres.sh script. You can use the following commands:

PurposeCommand

Set up deletion period

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh set violation|noviolation|other <days> [-v] 

Enable automatic deletion

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh enable violation|noviolation|other [-v]

Disable automatic deletion

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh disable violation|noviolation|other [-v]
View the state of settings
/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh show [-v]
Delete all daily TS
/opt/iw/tm5/bin/dbtools/dbconf-jobs-postgres.sh start iwtm_delete_tablespace
Информация
titleExample:

To delete all objects with "No violation" status, which are older than 15 days, run the following commands:

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh set noviolation 15 [-v]

/opt/iw/tm5/bin/dbtools/dbconf-iwdrop-postgres.sh enable noviolation [-v]