首页 > 数据库 >Oracle 清理sysaux表空间-清理AWR分区数据

Oracle 清理sysaux表空间-清理AWR分区数据

时间:2023-08-08 10:11:23浏览次数:40  
标签:1024 name sysaux 清理 AWR WRH ACTIVE segment NAME

----0、表空间使用率
col TABLESPACE_NAME for a20;
col PCT_FREE for a10;
col PCT_USED for a10;
set lines 200;
Select Tablespace_Name,
Sum_m,
Max_m,
Count_Blocks Free_Blk_Cnt,
Sum_Free_m,
To_Char(100 * Sum_Free_m / Sum_m, '99.9999')|| '%' As Pct_Free,
100 - To_Char(100 * Sum_Free_m / Sum_m,'99.9999') || '%' As Pct_used
From (Select Tablespace_Name, Sum(Bytes) / 1024 / 1024 As Sum_m
From Dba_Data_Files
Group By Tablespace_Name)
Left Join
(Select Tablespace_Name As Fs_Ts_Name,
Max(Bytes) / 1024 / 1024 As Max_m,
Count(Blocks) As Count_Blocks,
Sum(Bytes / 1024 / 1024) As Sum_Free_m
From Dba_Free_Space
Group By Tablespace_Name)
On Tablespace_Name = Fs_Ts_Name
ORDER BY Sum_Free_m / Sum_m ;

----1、查看AWR保存策略
col SNAP_INTERVAL format a20
col RETENTION format a20
select * from dba_hist_wr_control;

----2、查看AWR占用空间
col Item for a30
col Schema for a20
set lines 200
SELECT occupant_name"Item",
round(space_usage_kbytes/1024/1024,3)"Space Used (GB)",
schema_name "Schema",
move_procedure "MoveProcedure"
FROM v$sysaux_occupants
ORDER BY 2 Desc;

----3、查看占用SYSAUX表空间的segment
--all
SELECT D.SEGMENT_NAME, D.SEGMENT_TYPE,SUM(BYTES)/1024/1024 SIZE_M
FROM DBA_SEGMENTS D
WHERE D.TABLESPACE_NAME = 'SYSAUX'
GROUP BY D.SEGMENT_NAME, D.SEGMENT_TYPE ORDER BY SIZE_M DESC;
--前10
SELECT * FROM (SELECT SEGMENT_NAME,
PARTITION_NAME,
SEGMENT_TYPE,
BYTES / 1024 / 1024
FROM DBA_SEGMENTS
WHERE TABLESPACE_NAME = 'SYSAUX'
ORDER BY 4 DESC)
WHERE ROWNUM <= 10;

----4、查询占用
col trun_table for a50;
select distinct 'truncate table '||segment_name||';' trun_table ,s.bytes/1024/1024
from dba_segments s
where s.segment_name like 'WRH$%'
and segment_type in ('TABLE PARTITION', 'TABLE')
and s.bytes/1024/1024>100
order by s.bytes/1024/1024/1024 desc;

----5、查看AWR真正保留时长
set lines 200
col ASH for a40;
col SNAP for a40;
col RETENTION for a40;

select sysdate - a.sample_time ash,
sysdate - s.begin_interval_time snap,
c.RETENTION
from sys.wrm$_wr_control c,
(
select db.dbid,min(w.SAMPLE_time) SAMPLE_time
from sys.v_$database db,sys.wrh$_active_session_history w
where w.dbid = db.dbid
group by db.dbid
) a,
(
select db.dbid,min(r.begin_interval_time) begin_interval_time
from sys.v_$database db,sys.wrm$_snapshot r
where r.dbid = db.dbid
group by db.dbid
) s
where a.dbid = s.dbid
and c.dbid = a.dbid;
ASH SNAP RETENTION
---------------------------------------- ---------------------------------------- ----------------------------------------
+000001454 18:11:15.512 +000000002 18:35:02.485 +00008 00:00:00.0

----6、查看AWR快照未清理原因
set lines 200
col SEGMENT_NAME for a40;
col PARTITION_NAME for a30;
col SEGMENT_TYPE for a30;
col OWNER for a10;

select owner,
segment_name,
partition_name,
segment_type,
bytes/1024/1024/1024 Size_GB
from DBA_SEGMENTS
where segment_name='WRH$_ACTIVE_SESSION_HISTORY';

select owner,
segment_name,
partition_name,
segment_type,
bytes/1024/1024/1024 Size_GB
from DBA_SEGMENTS
where segment_name='WRH$_EVENT_HISTOGRAM';

WRH$_ACTIVE_SESSION_HISTORY由于分区失败,导致所有数据均在同一个表空间,所以删除过期快照失败。

----7、处理步骤
1)查看未拆分的分区
Check the partition details for the offending table before the split:
select owner,
segment_name,
partition_name,
segment_type,
bytes/1024/1024/1024 Size_GB
from DBA_SEGMENTS
where segment_name='WRH$_ACTIVE_SESSION_HISTORY';
OWNER SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE SIZE_GB
---------- ---------------------------------------- ------------------------------ ------------------------------ ----------
SYS WRH$_ACTIVE_SESSION_HISTORY WRH$_ACTIVE_1099728244_0 TABLE PARTITION 13.5166016
SYS WRH$_ACTIVE_SESSION_HISTORY WRH$_ACTIVE_SES_MXDB_MXSN TABLE PARTITION .000061035

2)使用Oracle命令对AWR所有表进行分区
Split the partitions so that there is more chance of the smaller partition being purged:
alter session set "_swrf_test_action" = 72;
NOTE: This command will split partitions for ALL partitioned AWR objects. It also initiates a single split; it does not need to be disabled and will need to be repeated if multiple splits are required.
3)检查新的分区情况
select owner,
segment_name,
partition_name,
segment_type,
bytes/1024/1024/1024 Size_GB
from DBA_SEGMENTS
where segment_name='WRH$_ACTIVE_SESSION_HISTORY';
OWNER SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE SIZE_GB
---------- ---------------------------------------- ------------------------------ ------------------------------ ----------
SYS WRH$_ACTIVE_SESSION_HISTORY WRH$_ACTIVE_1099728244_0 TABLE PARTITION 13.5166016
SYS WRH$_ACTIVE_SESSION_HISTORY WRH$_ACTIVE_1099728244_56761 TABLE PARTITION .000061035
SYS WRH$_ACTIVE_SESSION_HISTORY WRH$_ACTIVE_SES_MXDB_MXSN TABLE PARTITION .000061035

4)删除老的分区
以上步骤执行完成后,再truncate原来的分区,只保留新分区,释放空间
ALTER TABLE WRH$_ACTIVE_SESSION_HISTORY TRUNCATE PARTITION WRH$_ACTIVE_1099728244_0;
5)检查索引是否正常
select index_name,partition_name,status from dba_ind_partitions where index_name='WRH$_ACTIVE_SESSION_HISTORY_PK';
select index_name,partition_name,status from dba_ind_partitions where index_name='WRH$_EVENT_HISTOGRAM_PK';

INDEX_NAME PARTITION_NAME STATUS
------------------------------ ------------------------------ --------
WRH$_ACTIVE_SESSION_HISTORY_PK WRH$_ACTIVE_1099728244_0 USABLE
WRH$_ACTIVE_SESSION_HISTORY_PK WRH$_ACTIVE_1099728244_56761 USABLE
WRH$_ACTIVE_SESSION_HISTORY_PK WRH$_ACTIVE_SES_MXDB_MXSN USABLE

6)手动收集AWR验证
EXEC DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();

标签:1024,name,sysaux,清理,AWR,WRH,ACTIVE,segment,NAME
From: https://www.cnblogs.com/xibuhaohao/p/17613426.html

相关文章

  • pg_wal文件过多过大清理方式
    pg_wal文件过多过大如果PostgreSQL中的pg_wal文件过多或过大,可能是由于以下原因:数据库写入负载过大:如果你的数据库有大量的写入操作,会导致pg_wal文件的增长速度很快。备份和复制延迟:如果你的数据库设置了基于WAL的备份或复制,但备份或复制操作无法及时进行,pg_wal......
  • 视频融合平台视频汇聚平台LiteCVR的存储异常垃圾数据增多如何快捷清理
    LiteCVR视频融合平台部署迅捷高效,具备极大的功能灵活性,支持多种协议和设备类型的接入。在视频方面,它能够实现多项功能,包括视频直播、录像、回放、检索、云存储、告警上报、语音对讲、集群、智能分析以及平台级联等。根据用户的反馈,使用LiteCVR时发现数据库中存在大量无效数据,导致......
  • 清理C盘
    一、%temp% 二、/首先按下WIN+R,然后在运行中输入services.msc回车;/在服务中找到【Windowsupdate服务】,右键点击停止;/然后打开文件夹C:\Windows\SoftwareDistribution\Download  参考:https://answers.microsoft.com/zh-hans/windows/forum/all/%E5%A6%82%E4%BD%95%E......
  • SQL SERVER数据库日志清理
    新建查询,选择master数据库USE[master]GOALTERDATABASEblogSETRECOVERYSIMPLEWITHNO_WAIT----blog为需要清除日志的数据库名称GOALTERDATABASEblogSETRECOVERYSIMPLE--简单模式----blog为需要清除日志的数据库名称GOUSEblo......
  • 泛微OA清理人员抄送待办
    创建查询,链接ecology数据库,解决人员ID为6的抄送数据--1。备份wf_curr0724bak自定义select*intowf_curr0724bakfromworkflow_currentoperator--2查询替换useridselect*fromworkflow_currentoperatorawhereisremarkin(8,9)andisremarkin(8,9)andisL......
  • Linux系统cpu过高如何清理缓存
    查看缓存区及内存使用情况free-h//空闲内存=free+buffers+cached//已用内存=total-空闲内存缓存区分buffers和cached区别//内核在保证系统能正常使用物理内存和数据量读写情况下来分配缓冲区大小。//buffers用来缓存metadata及pages,可以理解为系统缓存,例如,vi打开一个文......
  • sysaux或system表空间使用率高
    sysaux解决方案查看表空间使用率setlinesize200settaboffSELECTa.tablespace_name,TRUNC(tablespace_size*b.block_size/1024/1024)"Total_space(MB)",TRUNC(used_space*b.block_size/1024/1024)"Used_space(MB)",TRUN......
  • App Cleaner & Uninstaller - mac系统清理和卸载
    AppCleaner&Uninstaller是一款功能强大的应用程序清理和卸载工具。在这800字的介绍中,我将向您详细说明AppCleaner&Uninstaller的特点、功能和优势。AppCleaner&Uninstaller获取 首先,AppCleaner&Uninstaller提供了一个简洁直观的界面,使用户能够轻松查找和删除......
  • 强制缓存和协商缓存以及栈溢出的垃圾清理问题
    强制缓存和协商缓存是HTTP中常用的缓存机制,用于优化网页加载速度和减少服务器负载。强制缓存:通过设置响应头信息中的Expires(过期时间)或Cache-Control(缓存控制)字段,客户端可以将服务器返回的资源缓存在本地,直到一定时间或过期时间到达。当再次请求该资源时,客户端可以直接从缓存中......
  • 定期清理日志脚本(Linux or Mac)
    一个项目的运行必然会产生大量的日志,经过时间的日积月累这些日志难免会对硬盘造成负载,下面用ssh脚本编写一个定期清理日志的脚本#使用vi或者vimviclean_logs.sh#给脚本赋予权限chmod+xclean_logs.sh#编写清理日志的命令#!/bin/bashlog_dir=/var/log/app......