There are three modes of storing data in DB: - Normal – switching to the following partition (when it is specified) happens after the previous one is overflow.
- Fast/Slow disks – dividing pools into fast and slow ones. Recent data are to be kept in fast pool. In a number of days specified, the System relocate them to the slow ones. Slow pool operates in Normal mode.
- Rotate – switching to the following partition happens every day once the previous one is overflow.
You select storage mode when installing Traffic Monitor. By default, the installer offers you Normal mode. You can change the storage mode later. By default, DTS are stored in the /u02/pgdata1 directory. | Информация |
|---|
| Modes described in this article relate to data stored in DB only. Changing mode does not affect data stored in Data Storage. |
Fast/slow disks ModeThe System moves data from the fast disk to the slow one every night. If you are switching from Normal mode to Fast/slow mode, you store a large amount of DTS on your old partition, and you specify the old partition as a fast disk, then data transfer may take a long time. If you will use the old disk as a fast one, before switching mode make sure that the following conditions are met: - The new partition size is not less than the old one size. So, there is enough space for transferring all DTS from the old partition;
- There is free space in the old partition not less than the largest tablespace that will be transferred to the slow disk.
The System creates DTSs every day in such a way that the database always has DTS for the next six days, excluding the current day. So, if when switching from Normal mode to Fast/slow mode, you specify a new partition as a fast disk, then, for first seven days, the System will save events to the already created DTS on the slow disk. In this case, the System will create new DTSs on the fast disk. For configuring Fast/slow mode, we will use the new partition /u03/pgdata/ as a slow disk and the old partition /u02/pgdata1/ as a fast one. To configure "Fast/slow" storage mode (fast and slow disks): - Edit the
/etc/fstab file to automatically mount the new partition to /u03:
/dev/sdd1 /u03/ ext4 defaults 1 2 - Create the
pgdata folder:
mkdir /u03/pgdata
- Change the user:
chown -R postgres:postgres /u03 - Log into the database:
su - iwtm
psql -p 5433 -h <DB_server_IP_address> postgres iwtm
psql -p 5433 -h 127.0.0.1 postgres iwtm – to connect to the local database
- Specify the storage period on fast disks (7 by default):
select pkg_part_set_fast_days(7);
- Specify the path to the fast disk:
select pkg_part_set_fast_path('/u02/pgdata1/',1);
- Specify the path to the slow disk:
select pkg_part_set_df_path('/u03/pgdata/',1);
- If necessary, you can use multiple slow disks. The data will be recorded to the next slow disk when the previous one is full. To add slow disks, specify a new path:
select pkg_part_set_df_path('/u03/pgdata2/',2); - Specify the total amount of slow disks (up to 10):
select pkg_part_set_df_path_cnt('2');
- Change the mode to fast-slow disks:
select pkg_part_set_filesys_type('fast/slow') The data will be transferred from the fast disks to slow ones during a night job. - To start the file transfer manually, run:
select iwtm.pkg_part_move_fast_tablespaces_to_slow();
| Информация |
|---|
| The System allows using multiple slow disks. |
| Информация |
|---|
| In Fast/slow mode, the screenshot tablespaces are stored in slow partitions only. |
To switch back to "Normal" storage mode: - Check the contents of the
/u02/pgdata1/ fast disk directory:
ls /u02/pgdata1/ - Check the contents of the
/u03/pgdata/ slow disk directory:
ls /u03/pgdata/ - Log into the database:
su - iwtm psql -p 5433 -h <DB_server_IP_address> postgres iwtm psql -p 5433 -h 127.0.0.1 postgres iwtm – to connect to the local database
- Change the storage period on fast disks:
select pkg_part_set_fast_days(-1); The "-1" value is specified to transfer tablespaces for today. - Run the task to transfer the tablespaces from fast disks to slow disks:
select iwtm.pkg_part_move_fast_tablespaces_to_slow(); - Check the contents of the fast disks directory. The tablespaces that are created for future dates should remain. Such tablespaces should be manually deleted by using the iw_space_manager service:
iw_space_manager tbs:delete <tbs_id> or via the database (if you do not use Data Storage):
select pkg_part_delete_tablespaces(<tbs_id>);
- Run the task (cron) of the iw_space_manager service to create DTSs imidiately:
iw_space_manager cron or start a job in the database (if you do not use Data Storage):
/opt/iw/tm5/bin/dbtools/dbconf-jobs-postgres.sh start iwtm_add_parts
- Check that all tablespaces have been transferred from the fast disks:
ls /u02/pgdata1/ - Check that the tablespaces for future dates have been created on the slow disks:
ls -alt /u03/pgdata/ - Enable Normal mode:
select pkg_part_set_filesys_type('normal');
Rotate ModeTo configure "Rotate" storage mode (daily rotation): - Mount the partition and make sure that it can be mounted automatically on reboot.
- Create the
pgdata folder:
mkdir /u03/pgdata
- Change the user:
chown -R postgres:postgres /u03
- Log into the database:
su - iwtm
psql -p 5433 -h <DB_server_IP_address> postgres iwtm
psql -p 5433 -h 127.0.0.1 postgres iwtm – to connect local database
- Add a path to the second partition:
select pkg_part_set_df_path('/u03/pgdata/',2);
- Specify a new number of paths:
select pkg_part_set_df_path_cnt(2); - Switch to rotate mode:
select pkg_part_set_filesys_type('rotate'); postgres=# select * from setting where setting like 'df_%'; setting | value | editable -------------+---------------+---------- df_path1 | /u02/pgdata1/ | 1 df_path2 | /u03/pgdata/ | 1 df_path_cnt | 2 | 1 df_filesys_type | rotate | 1
|