Manual archiving of daily tablespaces is performed in the following steps: Selecting daily tablespaces and data files To get a list of disconnected tablespaces, you must run the following query to the database under the account of the database schema owner. The queries are built according to the archiving policy of your company. For example, to select the daily TS storing the objects which were intercepted more than 100 days ago, run the following query: SELECT t.tbs_id, t.tbs_name, t.part_date
FROM tbs_list t
WHERE t.part_date < = date_trunc('day', current_date ) - '100 days'::interval 100 + 23 / 24 AND t.status IN (0, 3);
| Предупреждение |
|---|
| It is strongly recommended to run the following sample query in this section in order to retrieve the list of files. This is due to the fact that the file list if generated by any other ways may be incomplete. |
Archiving tablespace is Daily TS are located in separate catalogues. To get names of these catalogues, run the following command: select s.value || t.tbs_name archive_path
from tbs_list t
inner join setting s on s.setting = 'archive_path'
where t.part_date <= date_trunc('day', current_date) - '100 days'::interval and t.status in (0, 3)
where t.status IN (0, 3) indicates that the tablespaces with the ReadWrite (status code 0) and ReadOnly (status code 3) statuses are selected for archiving #su - postgres -c 'psql postgres iwtm'
postgres=# \db
List of tablespaces
Name | Owner | Location
------------+----------+-------------------------
iwtm | iwtm | /u01/iwtm_main/iwtm
iwtm_421 | iwtm | /u01/iwtm_data/iwtm_421
iwtm_423 | iwtm | /u01/iwtm_data/iwtm_423
iwtm_424 | iwtm | /u01/iwtm_data/iwtm_424
iwtm_425 | iwtm | /u01/iwtm_data/iwtm_425
iwtm_426 | iwtm | /u01/iwtm_data/iwtm_426
iwtm_427 | iwtm | /u01/iwtm_data/iwtm_427
iwtm_428 | iwtm | /u01/iwtm_data/iwtm_428
iwtm_429 | iwtm | /u01/iwtm_data/iwtm_429
iwtm_430 | iwtm | /u01/iwtm_data/iwtm_430
iwtm_431 | iwtm | /u01/iwtm_data/iwtm_431
iwtm_432 | iwtm | /u01/iwtm_data/iwtm_432
iwtm_433 | iwtm | /u01/iwtm_data/iwtm_433
iwtm_434 | iwtm | /u01/iwtm_data/iwtm_434
iwtm_435 | iwtm | /u01/iwtm_data/iwtm_435
iwtm_436 | iwtm | /u01/iwtm_data/iwtm_436
iwtm_437 | iwtm | /u01/iwtm_data/iwtm_437
iwtm_438 | iwtm | /u01/iwtm_data/iwtm_438
iwtm_439 | iwtm | /u01/iwtm_data/iwtm_439
iwtm_440 | iwtm | /u01/iwtm_data/iwtm_440
iwtm_441 | iwtm | /u01/iwtm_data/iwtm_441
iwtm_442 | iwtm | /u01/iwtm_data/iwtm_442
iwtm_443 | iwtm | /u01/iwtm_data/iwtm_443
iwtm_444 | iwtm | /u01/iwtm_data/iwtm_444
iwtm_445 | iwtm | /u01/iwtm_data/iwtm_445
iwtm_446 | iwtm | /u01/iwtm_data/iwtm_446
pg_default | postgres |
pg_global | postgres |
(28 rows)
Where Name corresponds to values from sample select tbs_name, tbs_id from iwtm.tbs_list. Disconnecting Daily Tablespaces from the Database | Предупреждение |
|---|
| It is strongly recommended not to disable daily TS when the <SchemaOwner>_iwtm_add_parts, <SchemaOwner>_iwtm_delete_tablespaces,<SchemaOwner>_iwtm_archive_tablespaces jobs are running as it may cause the data loss. |
- Call the procedure on behalf of the owner of the database schema, call the procedure:
select pkg_part_archive_tablespace(N); where N is a value of tbs_id attribute of the target TS from the tbs_list table. After running this script status of daily TS will change to to Offline. - Repeat the procedure call for each daily TS you want to disable.
Moving Datafiles Transfer the data files belonging to the disabled daily TS to the other data carrierstorage. To get a list of data files for all disconnected tablespaces, use the following script: select tbs_name from tbs_list where NOTE = 'Tablespace is offline'
where tbs_name is a name of a tablespace. tbs_list is a name of a table.
Data files are stored in the catalogue: select value from setting where setting='archive_path'.;
|