tablespaces
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tablespaces [2018/12/06 21:05] – created 91.177.234.129 | tablespaces [2021/11/13 11:41] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Tablespaces ====== | + | * [[https:// |
| + | * [[http:// | ||
| - | | + | |
| - | =====Update all datafiles in the database to be autoextend on and maxsize unlimited===== | + | ==== Check the system-wide tablespace warning and critical alerting thresholds ==== |
| + | < | ||
| + | set lines 1000 pages 100 | ||
| + | col object_name for a30 | ||
| + | col warning_value for a30 | ||
| + | col critical_value for a30 | ||
| + | select metrics_name | ||
| + | , object_name | ||
| + | , warning_operator | ||
| + | , warning_value | ||
| + | , critical_operator | ||
| + | , critical_value | ||
| + | from | ||
| + | / | ||
| + | </code> | ||
| + | < | ||
| + | METRICS_NAME | ||
| + | ---------------------------------------------------------------- ------------------------------ ------------ ------------------------------ ------------ ------------------------------ | ||
| + | Tablespace | ||
| + | Tablespace Space Usage | ||
| + | Tablespace Space Usage GE | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Reset the tablespace thresholds to their system-wide default ==== | ||
| + | < | ||
| + | begin | ||
| + | dbms_server_alert.set_threshold ( dbms_server_alert.tablespace_pct_full | ||
| + | , null | ||
| + | , null | ||
| + | , null | ||
| + | , null | ||
| + | , 1 | ||
| + | , 1 | ||
| + | , null | ||
| + | , dbms_server_alert.object_type_tablespace | ||
| + | , null | ||
| + | ); | ||
| + | end; | ||
| + | / | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== Override tablespace warning and critical thresholds | ||
| + | < | ||
| + | begin | ||
| + | dbms_server_alert.set_threshold | ||
| + | , warning_operator | ||
| + | , warning_value | ||
| + | , critical_operator | ||
| + | , critical_value | ||
| + | , observation_period => 1 | ||
| + | , instance_name | ||
| + | , object_type | ||
| + | , object_name | ||
| + | , | ||
| + | | ||
| + | end; | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Quick check of free space in a tablespace ==== | ||
| + | < | ||
| + | select df.tablespace_name | ||
| + | , trunc(fs.bytes/ | ||
| + | , trunc(df.bytes/ | ||
| + | , trunc( ( (fs.bytes/ | ||
| + | from | ||
| + | , dba_data_files df | ||
| + | where fs.tablespace_name = df.tablespace_name | ||
| + | and df.tablespace_name = nvl(upper('& | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Update all datafiles in the database to be autoextend on and maxsize unlimited ==== | ||
| A quick fix to ensure all tablespaces can be extended to the max. Have to keep an eye on the filesystem growth now. | A quick fix to ensure all tablespaces can be extended to the max. Have to keep an eye on the filesystem growth now. | ||
| - | < | + | < |
| + | set lines 1000 pages 0 newpa none feedb off trims on echo off termo off | ||
| + | spool fix_ts.sql | ||
| + | select 'alter database datafile ' | ||
| + | spool off | ||
| + | @fix_ts | ||
| + | </ | ||
| + | |||
| + | ==== Shrink tablespace to reclaim space on filesystem ==== | ||
| + | For temporary tablespaces, | ||
| + | < | ||
| + | ls -l / | ||
| + | |||
| + | -rw-r----- | ||
| + | -rw-r----- | ||
| + | </ | ||
| + | < | ||
| + | alter tablespace temp_system shrink space; | ||
| + | </ | ||
| + | < | ||
| + | ls -l / | ||
| + | |||
| + | -rw-r----- | ||
| + | -rw-r----- | ||
| + | </ | ||
| - | =====User quotas on all tablespaces===== | + | ==== User quotas on all tablespaces ==== |
| + | < | ||
| col quota format a10 | col quota format a10 | ||
| | | ||
| Line 17: | Line 117: | ||
| | | ||
| | | ||
| + | </ | ||
| - | =====Tablespace Growth Report 1===== | + | ==== Tablespace Growth Report 1 ==== |
| - | < | + | < |
| + | select b.tsname tablespace_name | ||
| + | , MAX(b.used_size_mb) cur_used_size_mb | ||
| + | , round(AVG(inc_used_size_mb), | ||
| + | from ( SELECT a.days, | ||
| + | from ( SELECT TO_CHAR(sp.begin_interval_time,' | ||
| + | from | ||
| + | AND ts.tsname = dt.tablespace_name AND sp.begin_interval_time > sysdate-7 | ||
| + | GROUP BY TO_CHAR(sp.begin_interval_time,' | ||
| + | ORDER BY ts.tsname, days ) a | ||
| + | ) b | ||
| + | GROUP BY b.tsname ORDER BY b.tsname; | ||
| + | </ | ||
| - | =====Tablespace Growth Report 2===== | + | ==== Tablespace Growth Report 2 ==== |
| - | The period range for this report is dependent on the snapshot retention period set for the db<br /> | + | The period range for this report is dependent on the snapshot retention period set for the db\\ |
| - | [[http:// | + | [[http:// |
| - | < | + | < |
| - | =====Tablespace Growth Report 3===== | + | set linesize 120 |
| - | [[http:// | + | column name format a15 |
| + | column variance format 9G990D00 | ||
| + | alter session set nls_date_format=' | ||
| + | with t as ( | ||
| + | select ss.run_time, | ||
| + | round(su.tablespace_usedsize*dt.block_size/ | ||
| + | from | ||
| + | dba_hist_tbspc_space_usage su, | ||
| + | (select trunc(BEGIN_INTERVAL_TIME) run_time, | ||
| + | group by trunc(BEGIN_INTERVAL_TIME) ) ss, | ||
| + | v$tablespace ts, | ||
| + | dba_tablespaces dt | ||
| + | where su.snap_id = ss.snap_id | ||
| + | and | ||
| + | and | ||
| + | and | ||
| + | select e.run_time, | ||
| + | from t e, t b | ||
| + | where e.run_time = b.run_time + 1 | ||
| + | order by 1; | ||
| + | </ | ||
| + | ==== Tablespace Growth Report 3 ==== | ||
| + | [[http:// | ||
| You probably have a problem with the autoextend max_size if column 5 is less than column 8! | You probably have a problem with the autoextend max_size if column 5 is less than column 8! | ||
| - | < | + | < |
| + | set pages 400 lines 132 | ||
| + | ------------------------------------------------------- | ||
| + | -- free.sql | ||
| + | -- | ||
| + | -- This SQL Plus script lists freespace by tablespace | ||
| + | -------------------------------------------------------- | ||
| + | |||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | break on report | ||
| + | compute sum of kbytes on report | ||
| + | compute sum of used on report | ||
| + | compute sum of free on report | ||
| + | |||
| + | select ( | ||
| + | | ||
| + | decode(segment_space_management,' | ||
| + | | ||
| + | | ||
| + | | ||
| + | , nvl(a.tablespace_name,' | ||
| + | , kbytes_alloc kbytes | ||
| + | , kbytes_alloc-nvl(kbytes_free, | ||
| + | , nvl(kbytes_free, | ||
| + | , ((kbytes_alloc-nvl(kbytes_free, | ||
| + | , nvl(largest, | ||
| + | , nvl(kbytes_max, | ||
| + | , decode( kbytes_max, 0, 0, (kbytes_alloc/ | ||
| + | from ( | ||
| + | | ||
| + | , | ||
| + | , | ||
| + | | ||
| + | | ||
| + | ) a | ||
| + | , | ||
| + | ( | ||
| + | | ||
| + | , | ||
| + | , | ||
| + | | ||
| + | | ||
| + | union all | ||
| + | | ||
| + | , | ||
| + | , | ||
| + | | ||
| + | | ||
| + | ) b | ||
| + | where a.tablespace_name (+) = b.tablespace_name | ||
| + | order by &1 | ||
| + | / | ||
| + | </ | ||
| If you are stuck on software written last century: | If you are stuck on software written last century: | ||
| - | < | + | < |
| + | set pages 400 lines 132 | ||
| + | ------------------------------------------------------- | ||
| + | -- free.sql | ||
| + | -- | ||
| + | -- This SQL Plus script lists freespace by tablespace | ||
| + | -------------------------------------------------------- | ||
| - | =====Segment Growth Report===== | + | column |
| - | < | + | column |
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | column | ||
| + | break on report | ||
| + | compute sum of kbytes on report | ||
| + | compute sum of free on report | ||
| + | compute sum of used on report | ||
| - | =====What is the size of the segments in the SYSAUX tablespace? | + | select (select decode(extent_management,' |
| - | < | + | from dba_tablespaces where tablespace_name |
| - | =====What are the components that make up the SYSAUX tablespace? | + | nvl(b.tablespace_name, |
| - | < | + | |
| + | | ||
| + | | ||
| + | | ||
| + | ((kbytes_alloc-nvl(kbytes_free, | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | from ( select sum(bytes)/ | ||
| + | max(bytes)/ | ||
| + | tablespace_name | ||
| + | | ||
| + | group by tablespace_name ) a, | ||
| + | ( select sum(bytes)/ | ||
| + | sum(maxbytes)/ | ||
| + | tablespace_name | ||
| + | from sys.dba_data_files | ||
| + | group by tablespace_name | ||
| + | union all | ||
| + | select sum(bytes)/ | ||
| + | sum(maxbytes)/ | ||
| + | tablespace_name | ||
| + | from sys.dba_temp_files | ||
| + | group by tablespace_name )b | ||
| + | where a.tablespace_name (+) = b.tablespace_name | ||
| + | order by &1 | ||
| + | / | ||
| + | </ | ||
| - | =====Alert | + | ==== Use snapshot history tables used by AWR to track tablespace |
| - | < | + | < |
| + | select * from dba_hist_tbspc_space_usage order by to_date(substr(rtime, | ||
| + | </ | ||
| - | =====Which sessions are using TEMP tablespace? | + | ==== Segment Growth Report |
| - | < | + | < |
| + | column " | ||
| + | column "Space Used (MB)" justify right format | ||
| + | column "Total Object Size (MB)" justify right format 9, | ||
| + | set linesize 150 | ||
| + | set pages 80 | ||
| + | set feedback off | ||
| - | =====What is the currently assigned default temporary tablespace?===== | + | select * from (select to_char(end_interval_time, |
| + | round(sum(space_used_delta) / sum(c.bytes) * 100, 2) " | ||
| + | from | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | where begin_interval_time > trunc(sysdate) - & | ||
| + | and sn.snap_id | ||
| + | and b.object_id = a.obj# | ||
| + | and b.owner = c.owner | ||
| + | and b.object_name = c.segment_name | ||
| + | and c.segment_name = '& | ||
| + | group by to_char(end_interval_time, | ||
| + | order by to_date(mydate, | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== What is the size of the segments in the SYSAUX tablespace? ==== | ||
| + | < | ||
| + | set lines 2000 | ||
| + | col owner for a30 | ||
| + | col segment_name for a40 | ||
| + | select owner | ||
| + | , segment_name | ||
| + | , (bytes/ | ||
| + | from | ||
| + | where tablespace_name = ' | ||
| + | order by bytes; | ||
| + | </ | ||
| + | ==== What are the components that make up the SYSAUX tablespace? ==== | ||
| + | < | ||
| + | set lines 2000 | ||
| + | col occupant_name | ||
| + | col schema_name | ||
| + | col move_procedure for a50 heading "Move Procedure" | ||
| + | col used | ||
| + | select occupant_name | ||
| + | , round(space_usage_kbytes/ | ||
| + | , schema_name | ||
| + | , move_procedure | ||
| + | from | ||
| + | order by 2 | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Show actual space taken up by objects in TEMP tablespaces ==== | ||
| + | < | ||
| + | select vss.tablespace_name | ||
| + | , tot.mb_total | ||
| + | , sum (vss.used_blocks * tot.block_size) / 1024 / 1024 mb_used | ||
| + | , tot.mb_total - sum (vss.used_blocks * tot.block_size) / 1024 / 1024 mb_free | ||
| + | from | ||
| + | , ( | ||
| + | | ||
| + | , | ||
| + | , | ||
| + | | ||
| + | , | ||
| + | | ||
| + | | ||
| + | , | ||
| + | ) tot | ||
| + | where vss.tablespace_name = tot.name | ||
| + | group by vss.tablespace_name | ||
| + | , tot.mb_total | ||
| + | / | ||
| + | </ | ||
| + | ==== Alert tablespace with least space available ==== | ||
| + | < | ||
| + | select t1.naam | ||
| + | , round (t1.df_grootte/ | ||
| + | , round (t2.vrij/ | ||
| + | , round (t1.ruimte/ | ||
| + | , round ( (t1.df_grootte - t2.vrij) / (t1.df_grootte + t1.ruimte) * 100, 0) vullingsgraad | ||
| + | , ( | ||
| + | case when round ( (df_grootte - vrij) / (df_grootte + ruimte) * 100, 2) > 95 then ' | ||
| + | when round ( (df_grootte - vrij) / (df_grootte + ruimte) * 100, 2) > 85 then ' | ||
| + | else ' | ||
| + | end | ||
| + | ) alert_lvl | ||
| + | from ( | ||
| + | | ||
| + | , | ||
| + | , | ||
| + | , | ||
| + | | ||
| + | | ||
| + | ) t1 | ||
| + | , ( | ||
| + | | ||
| + | , | ||
| + | | ||
| + | | ||
| + | ) t2 | ||
| + | , ( | ||
| + | | ||
| + | , | ||
| + | | ||
| + | | ||
| + | ) t3 | ||
| + | where t1.naam = t2.naam | ||
| + | and t1.naam = t3.naam | ||
| + | order by vullingsgraad desc | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Slow or hanging drop tablespace including contents and datafiles ==== | ||
| + | Maybe a bug if there are no active sessions on the tablespace being dropped. See Metalink Note 438461.1 | ||
| + | < | ||
| + | exec dbms_stats.gather_fixed_objects_stats; | ||
| + | exec dbms_stats.gather_dictionary_stats; | ||
| + | execute dbms_stats.gather_schema_stats(' | ||
| + | alter system flush shared_pool; | ||
| + | alter system flush shared_pool; | ||
| + | alter system flush shared_pool; | ||
| + | </ | ||
| + | |||
| + | ==== Which sessions are using TEMP tablespace? ==== | ||
| + | < | ||
| + | set lines 1000 | ||
| + | col killer | ||
| + | col status | ||
| + | col username | ||
| + | col osuser | ||
| + | col spid for a10 | ||
| + | col mb_used | ||
| + | col module for a20 | ||
| + | col program | ||
| + | col tablespace for a10 | ||
| + | col statements for 999 | ||
| + | select s.sid||',' | ||
| + | , s.status | ||
| + | , s.username | ||
| + | , s.osuser | ||
| + | , p.spid | ||
| + | , p.pid pid | ||
| + | , s.module | ||
| + | , p.program | ||
| + | , sum(t.blocks)*tbs.block_size/ | ||
| + | , t.tablespace | ||
| + | , count(*) | ||
| + | from | ||
| + | , v$session | ||
| + | , dba_tablespaces tbs | ||
| + | , v$process | ||
| + | where 1=1 | ||
| + | and t.session_addr = s.saddr | ||
| + | and s.paddr | ||
| + | and t.tablespace | ||
| + | group by s.sid | ||
| + | , s.status | ||
| + | , s.serial# | ||
| + | , s.username | ||
| + | , s.osuser | ||
| + | , p.spid | ||
| + | , p.pid | ||
| + | , s.module | ||
| + | , p.program | ||
| + | , tbs.block_size | ||
| + | , t.tablespace | ||
| + | order by killer | ||
| + | / | ||
| + | </ | ||
| + | or | ||
| + | < | ||
| + | set lines 1000 pages 100 | ||
| + | col hash_value for a40 | ||
| + | col tablespace for a10 | ||
| + | col username for a15 | ||
| + | select s.sid | ||
| + | , s.username | ||
| + | , u.tablespace | ||
| + | , s.sql_hash_value||'/' | ||
| + | , u.segtype | ||
| + | , u.blocks | ||
| + | from | ||
| + | , v$tempseg_usage u | ||
| + | where s.saddr = u.session_addr | ||
| + | order by u.blocks | ||
| + | / | ||
| + | </ | ||
| + | ...and what SQL statement is running there? | ||
| + | < | ||
| + | col stmt for a70 wrap | ||
| + | col piece noprint | ||
| + | select sql.piece | ||
| + | , replace(sql.sql_text, | ||
| + | from | ||
| + | , v$sqltext_with_newlines sql | ||
| + | where ses.status | ||
| + | and ses.username | ||
| + | and ses.sql_address | ||
| + | and ses.sql_hash_value = sql.hash_value | ||
| + | and ses.audsid | ||
| + | and ses.sid | ||
| + | order by sql.piece | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Show temp tablespace usage with os user (and killer) ==== | ||
| + | < | ||
| + | col killer for a60 | ||
| + | col osuser for a15 | ||
| + | set lines 1000 pages 100 | ||
| + | |||
| + | select 'alter system disconnect session ''' | ||
| + | , to_char(s.logon_time,' | ||
| + | , s.type | ||
| + | , sci.osuser | ||
| + | , s.status | ||
| + | , su.tablespace | ||
| + | from | ||
| + | , gv$session_connect_info sci | ||
| + | , gv$process p | ||
| + | , gv$sort_usage su | ||
| + | where 1=1 | ||
| + | and p.addr | ||
| + | and p.inst_id | ||
| + | and s.sid = su.session_num | ||
| + | and s.sid = sci.sid | ||
| + | and s.serial# | ||
| + | order by s.logon_time | ||
| + | / | ||
| + | </ | ||
| + | ==== How much space is being used by inactive sessions using temp storage (with killer)? ==== | ||
| + | < | ||
| + | set lines 1000 pages 100 | ||
| + | col killer | ||
| + | col inst_id nopri | ||
| + | col logon for a21 | ||
| + | col osuser | ||
| + | col spid for a10 | ||
| + | col username | ||
| + | col program | ||
| + | col tablespace for a10 | ||
| + | col temp_size | ||
| + | select 'alter system disconnect session ''' | ||
| + | , round(((b.blocks*p.value)/ | ||
| + | , a.inst_id instance | ||
| + | , nvl(a.username, | ||
| + | , a.program | ||
| + | , a.status | ||
| + | , a.sql_id | ||
| + | from | ||
| + | , gv$sort_usage b | ||
| + | , gv$parameter p | ||
| + | where p.name | ||
| + | and a.saddr = b.session_addr | ||
| + | and a.inst_id=b.inst_id | ||
| + | and a.inst_id=p.inst_id | ||
| + | and a.status = ' | ||
| + | / | ||
| + | </ | ||
| + | and that wrapped up in PL/SQL | ||
| + | < | ||
| + | declare | ||
| + | cursor c1 is | ||
| + | select 'alter system disconnect session ''' | ||
| + | from | ||
| + | ( | ||
| + | select s.sid||',' | ||
| + | , s.status | ||
| + | from | ||
| + | , v$session | ||
| + | , dba_tablespaces tbs | ||
| + | , v$process | ||
| + | where 1=1 | ||
| + | and t.session_addr = s.saddr | ||
| + | and s.paddr | ||
| + | and t.tablespace | ||
| + | ) s | ||
| + | where s.status = ' | ||
| + | stmt varchar2(4000); | ||
| + | begin | ||
| + | for r1 in c1 | ||
| + | loop | ||
| + | begin | ||
| + | dbms_output.put_line(r1.stmt); | ||
| + | execute immediate r1.stmt; | ||
| + | exception | ||
| + | when others then | ||
| + | null; | ||
| + | end; | ||
| + | end loop; | ||
| + | end; | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Current TEMP tablespace usage ==== | ||
| + | < | ||
| + | select vss.tablespace_name | ||
| + | , dtf.total_mb | ||
| + | , dtf.total_mb-round(vss.used_blocks*8/ | ||
| + | , round(vss.used_blocks*8/ | ||
| + | , round(vss.max_used_blocks*8/ | ||
| + | from | ||
| + | , ( | ||
| + | | ||
| + | , | ||
| + | | ||
| + | | ||
| + | ) dtf | ||
| + | where 1=1 | ||
| + | and vss.tablespace_name = dtf.tablespace_name | ||
| + | / | ||
| + | </ | ||
| + | ==== Find the SQL that is taking up all the TEMP space ==== | ||
| + | < | ||
| + | select hash_value | ||
| + | , sorts | ||
| + | , rows_processed/ | ||
| + | from | ||
| + | where hash_value in ( | ||
| + | | ||
| + | | ||
| + | | ||
| + | ) | ||
| + | and sorts > 0 | ||
| + | and parsing_schema_name like '& | ||
| + | order by rows_processed/ | ||
| + | / | ||
| + | </ | ||
| + | ==== What is the currently assigned default temporary tablespace? ==== | ||
| See DEFAULT_TEMP_TABLESPACE to see which TEMP table space is defaulted at database level | See DEFAULT_TEMP_TABLESPACE to see which TEMP table space is defaulted at database level | ||
| - | < | + | < |
| + | set lines 200 pages 100 newpa none | ||
| + | col description for a60 noprint | ||
| + | col property_name | ||
| + | col property_value for a120 | ||
| + | select * | ||
| + | from database_properties | ||
| + | / | ||
| + | </ | ||
| - | =====Reduce (or recreate) size of temporary tablespace===== | + | ==== Reduce (or recreate) size of temporary tablespace ==== |
| - | Sometimes the TEMP tablespace grows too big - out of all proportion to the size of the database.<br /> | + | Sometimes the TEMP tablespace grows too big - out of all proportion to the size of the database.\\ |
| Create a // | Create a // | ||
| - | < | + | < |
| + | create temporary tablespace tempx tempfile '/ | ||
| + | </ | ||
| Assign this new // | Assign this new // | ||
| - | < | + | < |
| + | alter database default temporary tablespace tempx; | ||
| + | </ | ||
| Check for any sessions still holding on to the TEMP tablespace | Check for any sessions still holding on to the TEMP tablespace | ||
| - | < | + | < |
| + | set lines 1000 pages 0 newpa none | ||
| + | col stmt for a300 | ||
| + | select 'alter system disconnect session ''' | ||
| + | from | ||
| + | ( | ||
| + | select s.sid||',' | ||
| + | , s.status | ||
| + | from | ||
| + | , v$session | ||
| + | , dba_tablespaces tbs | ||
| + | , v$process | ||
| + | where 1=1 | ||
| + | and t.session_addr = s.saddr | ||
| + | and s.paddr | ||
| + | and t.tablespace | ||
| + | ) s | ||
| + | where s.status = ' | ||
| + | / | ||
| + | </ | ||
| Drop the original temp tablespace | Drop the original temp tablespace | ||
| - | < | + | < |
| + | drop tablespace temp including contents and datafiles; | ||
| + | </ | ||
| Recreate the original temp tablespace (smaller, or with fewer datafiles) | Recreate the original temp tablespace (smaller, or with fewer datafiles) | ||
| - | < | + | < |
| + | create temporary tablespace temp tempfile '/ | ||
| + | , | ||
| + | , | ||
| + | , | ||
| + | </ | ||
| Assign the new temp tablespace to the database | Assign the new temp tablespace to the database | ||
| - | < | + | < |
| + | alter database default temporary tablespace temp; | ||
| + | </ | ||
| Drop the // | Drop the // | ||
| - | < | + | < |
| + | drop tablespace tempx including contents and datafiles; | ||
| + | </ | ||
| - | =====Recreate the temporary tablespace when it belongs to a tablespace group===== | + | ==== Recreate the temporary tablespace when it belongs to a tablespace group ==== |
| Verify the tablespace groups and their members | Verify the tablespace groups and their members | ||
| - | < | + | < |
| + | select * from dba_tablespace_groups; | ||
| + | |||
| + | GROUP_NAME | ||
| + | ------------------------------ ------------------------------ | ||
| + | TEMP | ||
| + | TEMP | ||
| + | </ | ||
| Check the filenames for these tablespaces | Check the filenames for these tablespaces | ||
| - | < | + | < |
| + | select file_name, tablespace_name from dba_temp_files order by 2,1; | ||
| + | |||
| + | FILE_NAME | ||
| + | ------------------------------------------- ------------------- | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| Create new tablespaces and assign them to a new group | Create new tablespaces and assign them to a new group | ||
| - | < | + | < |
| + | create temporary tablespace temp_g1 tempfile '/ | ||
| + | create temporary tablespace temp_g2 tempfile '/ | ||
| + | </ | ||
| Recheck the groups | Recheck the groups | ||
| - | < | + | < |
| + | select * from dba_tablespace_groups; | ||
| + | |||
| + | GROUP_NAME | ||
| + | ------------------------------ ------------------------------ | ||
| + | TEMP | ||
| + | TEMP | ||
| + | TEMP_G | ||
| + | TEMP_G | ||
| + | </ | ||
| Make the new tablespace group the default at database level | Make the new tablespace group the default at database level | ||
| - | < | + | < |
| + | alter database default temporary tablespace temp_g; | ||
| + | </ | ||
| Check for any sessions still using the old default temporary tablespace (group) | Check for any sessions still using the old default temporary tablespace (group) | ||
| - | < | + | < |
| + | SET PAGESIZE 50 | ||
| + | SET LINESIZE 300 | ||
| + | COLUMN tablespace FORMAT A20 | ||
| + | COLUMN temp_size FORMAT A20 | ||
| + | COLUMN sid_serial FORMAT A20 | ||
| + | COLUMN username FORMAT A20 | ||
| + | COLUMN program FORMAT A50 | ||
| + | |||
| + | SELECT b.tablespace, | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | FROM | ||
| + | | ||
| + | | ||
| + | WHERE p.name | ||
| + | AND a.saddr = b.session_addr | ||
| + | AND a.inst_id=b.inst_id | ||
| + | AND a.inst_id=p.inst_id | ||
| + | ORDER BY b.tablespace, | ||
| + | / | ||
| + | |||
| + | TABLESPACE | ||
| + | -------------------- -------------------- ---------- -------------------- -------------------- -------------------------------------------------- -------- ------------- | ||
| + | TEMP2 1M 1 467, | ||
| + | </ | ||
| Kill any sessions that may be killed | Kill any sessions that may be killed | ||
| - | < | + | < |
| + | alter system disconnect session ' | ||
| + | </ | ||
| Remove the old tablespaces from the tablespace group and reassign the new tablespaces to it | Remove the old tablespaces from the tablespace group and reassign the new tablespaces to it | ||
| - | < | + | < |
| + | alter tablespace temp1 tablespace group ''; | ||
| + | alter tablespace temp2 tablespace group ''; | ||
| + | alter tablespace temp_g1 tablespace group temp; | ||
| + | alter database default temporary tablespace temp; | ||
| + | alter tablespace temp_g2 tablespace group temp; | ||
| + | </ | ||
| Drop the old tablespaces | Drop the old tablespaces | ||
| - | < | + | < |
| + | drop tablespace temp1 including contents and datafiles; | ||
| + | drop tablespace temp2 including contents and datafiles; | ||
| + | </ | ||
| Check the final situation | Check the final situation | ||
| - | < | + | < |
| + | select * from dba_tablespace_groups; | ||
| - | =====Which tablespaces are encrypted===== | + | GROUP_NAME |
| + | ------------------------------ ------------------------------ | ||
| + | TEMP | ||
| + | TEMP | ||
| + | </ | ||
| + | |||
| + | === TDE Transparent Data Encryption === | ||
| + | ==== Make a wallet keystore ==== | ||
| + | mkdir -p " | ||
| + | sqlplus / as sysdba | ||
| + | alter system set wallet_root=" | ||
| + | shu immediate | ||
| + | startup | ||
| + | alter system set tde_configuration=" | ||
| + | administer key management create keystore ' | ||
| + | |||
| + | set lines 1000 pages 100 | ||
| + | col wrl_parameter for a40 | ||
| + | select con_id, wrl_type, wrl_parameter, | ||
| + | |||
| + | administer key management set keystore open force keystore identified by some_password; | ||
| + | administer key management set key identified by some_password with backup; | ||
| + | |||
| + | administer key management create auto_login keystore from keystore ' | ||
| + | |||
| + | select tablespace_name, | ||
| + | alter tablespace users encryption online encrypt; | ||
| + | |||
| + | alter system set encrypt_new_tablespaces=always; | ||
| + | |||
| + | |||
| + | ==== Which tablespaces are encrypted ==== | ||
| Encrypt tablespaces to protect data (after having created a wallet) | Encrypt tablespaces to protect data (after having created a wallet) | ||
| - | < | + | < |
| - | =====Check encryption algorithm===== | + | select tablespace_name, |
| - | < | + | </ |
| + | ==== Check encryption algorithm ==== | ||
| + | < | ||
| + | select t.name | ||
| + | , e.encryptionalg | ||
| + | , e.encryptedts | ||
| + | from | ||
| + | , v$encrypted_tablespaces e | ||
| + | where t.ts# = e.ts#; | ||
| + | </ | ||
tablespaces.1544130327.txt.gz · Last modified: 2018/12/06 21:05 by 91.177.234.129
