首页 > 其他分享 >清理SYSAUX(其二)

清理SYSAUX(其二)

时间:2023-05-19 16:25:34浏览次数:22  
标签:name SYSAUX 清理 其二 WRI SYS tablespace ST OPTSTAT

【是由于升级到19C之后index扩大导致,重建index】
1.
--检查表空间使用情况
column used format 999,999,999 heading 'USED(MB)'
column free format 999,999,999 heading 'FREE(MB)'
column total format 999,999,999 heading 'TOTAL(MB)'
column usedpct format 999 heading 'USED(%)'
break on report
compute sum label 'TOTAL(MB)' of used free total on report
select a.tablespace_name,
round(b.total) - round(nvl(c.free,0)) used,
round(nvl(c.free,0)) free,
round(b.total) total,
(round(b.total) - round(nvl(c.free,0)))/round(b.total)100 usedpct
from dba_tablespaces a,
(select tablespace_name, sum(bytes)/(1024
1024) total
from dba_data_files
group by tablespace_name) b,
(select tablespace_name, sum(bytes)/(10241024) free
from dba_free_space
group by tablespace_name) c
where a.tablespace_name = b.tablespace_name
and a.tablespace_name = c.tablespace_name (+)
union all
select tablespace_name||' (TEMPFILE)' tablespace_name,
round(sum(bytes)/(1024
1024)) used,
round(sum(bytes)/(10241024)) - round(sum(bytes)/(10241024)) free,
round(sum(bytes)/(10241024)) total,
round(sum(bytes)/(1024
1024))/round(sum(bytes)/(10241024))100 usedpct
from dba_temp_files
group by tablespace_name||' (TEMPFILE)'
having count(*) > 0
order by 1;

--具体内容
set lines 120
col occupant_name format a30
select occupant_name,space_usage_kbytes from v$sysaux_occupants order by space_usage_kbytes desc;

col segment_name format a30
col owner format a10
col tablespace_name format a10
col segment_type format a15
select segment_name,owner,tablespace_name,bytes/1024/1024 ""SIZE(MB)"",segment_type from dba_segments where tablespace_name='SYSAUX' order by bytes desc;

--job auto advisor 运行状态
col task_name format a35
select task_name, count(*) cnt from dba_advisor_objects group by task_name order by cnt desc;

col TASK_NAME format a25
col parameter_name format a35
col parameter_value format a20
set lines 120
select TASK_NAME,parameter_name, parameter_value FROM DBA_ADVISOR_PARAMETERS WHERE task_name='AUTO_STATS_ADVISOR_TASK' and PARAMETER_NAME='EXECUTION_DAYS_TO_EXPIRE';

SELECT EXECUTION_NAME, EXECUTION_END, STATUS
FROM DBA_ADVISOR_EXECUTIONS
WHERE TASK_NAME = 'AUTO_STATS_ADVISOR_TASK'
ORDER BY 2;

select * from (select segment_name,PARTITION_NAME, 
sum(bytes) / 1024 / 1024 total_mb, 
tablespace_name 
from dba_segments 
where tablespace_name in = 'SYSAUX'
group by segment_name, tablespace_name 
order by 3 desc) 
where rownum <= 20;

SELECT occupant_name ""Item"", 
 space_usage_kbytes / 1048576 ""Space Used (GB)"", 
 schema_name ""Schema"", 
 move_procedure ""Move Procedure"" 
 FROM v$sysaux_occupants 
 ORDER BY space_usage_kbytes desc;

---是由于升级到19C之后index扩大导致,重建index

==处理办法=

  1. Measure the size of the indexes below pre rebuild:
    set lines 1000

select Ai.index_name, sum(u.bytes)/1024/1024 ""SIZE"" from dba_segments u, all_indexes ai
where u.SEGMENT_NAME = ai.index_name
and ai.index_name in ('I_WRI$_OPTSTAT_H_ST','I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST','I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST','I_WRI$_OPTSTAT_HH_ST')
group by ai.index_name
order by 2
/
2) Collect and save metadata for indexes:

set long 1000
set pagesize 0
select DBMS_METADATA.GET_DDL('INDEX','I_WRI$_OPTSTAT_H_ST') from DUAL;
select DBMS_METADATA.GET_DDL('INDEX','I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST') from DUAL;
select DBMS_METADATA.GET_DDL('INDEX','I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST') from DUAL;
select DBMS_METADATA.GET_DDL('INDEX','I_WRI$_OPTSTAT_HH_ST') from DUAL;

CREATE INDEX ""SYS"".""I_WRI$_OPTSTAT_H_ST"" ON ""SYS"".""WRI$_OPTSTAT_HISTGRM_HISTORY"" (SYS_EXTRACT_UTC(""SAVTIME""))
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE ""SYSAUX"";

CREATE INDEX ""SYS"".""I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST"" ON ""SYS"".""WRI$_OPTSTAT_HISTGRM_HISTORY"" (""OBJ#"", ""INTCOL#"", SYS_EXTRACT_UTC(""SAVTIME""), ""COLNAME"")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE ""SYSAUX"";

CREATE UNIQUE INDEX ""SYS"".""I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST"" ON ""SYS"".""WRI$_OPTSTAT_HISTHEAD_HISTORY"" (""OBJ#"", ""INTCOL#"", SYS_EXTRACT_UTC(""SAVTIME""), ""COLNAME"")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE ""SYSAUX"";

CREATE INDEX ""SYS"".""I_WRI$_OPTSTAT_HH_ST"" ON ""SYS"".""WRI$_OPTSTAT_HISTHEAD_HISTORY"" (SYS_EXTRACT_UTC(""SAVTIME""))
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE ""SYSAUX"";

3)Drop indexes:

drop index SYS.I_WRI$_OPTSTAT_H_ST;
drop index SYS.I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST;
drop index SYS.I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST;
drop index SYS.I_WRI$_OPTSTAT_HH_ST;

  1. Create these indices using Metadata collected as per step 2

  2. Gather statistics for two tables:
    EXEC DBMS_STATS.GATHER_TABLE_STATS('SYS','WRI$_OPTSTAT_HISTGRM_HISTORY');
    EXEC DBMS_STATS.GATHER_TABLE_STATS('SYS','WRI$_OPTSTAT_HISTHEAD_HISTORY');

  3. Measure the size of the indexes below post rebuild:

select Ai.index_name, sum(u.bytes)/1024/1024 ""SIZE"" from dba_segments u, all_indexes ai
where u.SEGMENT_NAME = ai.index_name
and ai.index_name in ('I_WRI$_OPTSTAT_H_ST','I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST','I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST','I_WRI$_OPTSTAT_HH_ST')
group by ai.index_name
order by 2
/

标签:name,SYSAUX,清理,其二,WRI,SYS,tablespace,ST,OPTSTAT
From: https://www.cnblogs.com/sage914/p/17415499.html

相关文章

  • 清理SYSAUX(其一)
    1:addSYSAUXtablespace或者如下脚本:iftest-f/var/opt/oracle/oratabthenvoratab=/var/opt/oracle/oratabelsevoratab=/etc/oratabfiexportvoratabecho""voratab=$voratab"">AL.shps-ef|greppmon_|grep-v""greppmon&......
  • 如何正确的清理C盘
    https://zhuanlan.zhihu.com/p/74793683 如何正确的清理C盘彷徨设计师,设计教育工作者 1,289人赞同了该文章如何正确清理C盘Windows电脑操作系统一般是安装在磁盘驱动器的C盘中,一旦运行,便会产生许多垃圾文件,C盘空间在一定程度上都会越来越小。伴随着......
  • macOS系统2023最佳清理软件CleanMyMac X 4.13功能介绍及如何激活解锁许可证
    CleanMyMacX4.13在软件功能列表中为MAC用户提供了常见的清理(系统垃圾、邮件附件、废纸篓)功能,还有保护(移除恶意软件、隐私)、速度(优化、维护)、应用程序(卸载器、更新程序、扩展)、文件(空间透镜、大型和旧文件、碎纸机)等功能。操作界面极其易用,例如仅需要点击几下就可以完成MAC系统的......
  • git 清理commit中历史提交记录的大文件
    git清理commit中历史提交记录的大文件起源是公司需要把代码仓库同步到另外一个代码仓库,结果另外一个仓库被限制大文件超过64M提交,所以会同步失败。刚开始我直接把大文件压缩到64m以内,结果还是同步失败。后来才知道是因为提交记录里面有包含大文件的信息也要删除才行。具体操作......
  • CentOS系统的/tmp目录自动清理规则
    CentOS系统的/tmp目录自动清理规则1、CentOS7CentOS7下,系统使用systemd管理易变与临时文件,与之相关的系统服务有3个:systemd-tmpfiles-setup.service:CreateVolatileFilesandDirectoriessystemd-tmpfiles-setup-dev.service:Createstaticdevicenodesin/devsystemd-tmpf......
  • 清理zabbix历史数据
    zabbix历史记录一般是这几个表清理历史记录就是清理这几个表简单粗暴清理直接重建表TRUNCATETABLEhistory;OPTIMIZETABLEhistory;TRUNCATETABLEhistory_uint;OPTIMIZETABLEhistory_uint;TRUNCATETABLEhistory_str;OPTIMIZETABLEhistory_str;TRUNCATE......
  • 清理分区
    背景:分区表按照月进行分区,定期删除分区清理数据,记录操、操作方案1、查询分区情况selecta.TABLE_OWNER,a.TABLE_NAME,a.PARTITION_NAME,b.column_name,a.HIGH_VALUEfromdba_tab_partitionsa,dba_part_key_columnsbwherea.table_name='tablenameXXX_XX'anda.table_owner='X......
  • 2022-02-21:不含连续1的非负整数。 给定一个正整数 n ,返回范围在 [0, n] 都非负整数中,
    2022-02-21:不含连续1的非负整数。给定一个正整数n,返回范围在[0,n]都非负整数中,其二进制表示不包含连续的1的个数。输入:n=5输出:5解释:下面是带有相应二进制表示的非负整数<=5:0:01:12:103:114:1005:101其中,只有整数3违反规则(有两个连续的1),其......
  • 日志清理小脚本
    #!/bin/bash#获取日志目录大小,单位Gcur_file_size=`du-h--max-depth=1/oraclelog/archlog|awk'{print$1}'|sed's/G//g'`#获取日志文件占总磁盘大小比例size_ratio=`echo$cur_file_size1024|awk'{print$1/$2}'`#判断如果达到80%磁盘,则进行日志清理if_del=`echo......
  • Maven 仓库优先加载本地的仓库jar包配置,清理无法下载的jar
    Settings-Maven-Runner-VMOptions中添加-DarchetypeCatalog=internal,优先从本地仓库读取,添加-Dmaven.wagon.http.ssl.insecure=true-Dmaven.wagon.http.ssl.allowall=true,忽略证书检查https://www.jb51.net/article/276265.htm清理本地没下载完的https://www.jb51.......