Oracle daily maintenance-Handling the problem of insufficient tablespace size

文章介绍了在check_mk平台上监控Oracle数据库表空间使用率的自定义指标,当使用率达到95%或98%时会触发警告或关键报警。解决方案包括检查失败次数是否超过阈值,查看数据文件的空间使用情况。建议添加最大大小,或者在有足够空间的文件系统中添加新的数据文件来扩展表空间。
摘要由CSDN通过智能技术生成

1.About check_mk metric:ORA_IYOA_Tablespace_Check
This is a custom monitoring metric on check_mk platform,
the threshold is defined in /usr/lib/check_mk_oracle/MAIN/conf/perf_ORCL_tablespace.json

[oracle@IDPCN-IYCost conf]$ cat perf_ORCL_tablespace.json 
{"target_info":[{
"perf_min":"0",
"chk_interval":5000,
"output_cmd":"echo",
"post_action":"",
"perf_crit":"98",
"chk_cmd":"sh run_tablespace.sh",
"perf_max":"0",
"chk_result_separator":";",
"perf_warn":"95",
"database":"ORCL"
}]}
[oracle@IDPCN-IYCost conf]$ 

notice the two threshold value:“perf_warn”:“95”,“perf_crit”:“98”, mean tablespace usage ratio arrival 95% or 98%, will trigger the warning or critical alarm respectively

2.solution:
2.1check whether the failures times are more than threshold value,notice the failures column

        select tablespace_name, usedsize, freesize , autosize,used_per  
        from 
        (
        select  /* + RULE */ allsize.tablespace_name,allsize.usedsize , allsize.freesize, NVL(aut.autosize ,0) autosize,
        Round((allsize.usedsize  -allsize.freesize) * 100 / (usedsize + NVL(aut.autosize ,0)) ) used_per
        FROM    
        (SELECT  df.tablespace_name                      tablespace_name ,
                        ROUND(df.bytes / (1024 * 1024 * 1024),2)           usedsize,      
                        ROUND(SUM(fs.bytes) / (1024 * 1024 * 1024 ),2)     freesize,
                        Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1)       pused,
                        Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) pfree 
                        FROM dba_free_space  fs,
                        (SELECT tablespace_name,SUM(bytes) bytes
                          FROM dba_data_files  GROUP BY tablespace_name) df  
                 WHERE fs.tablespace_name (+)  = df.tablespace_name       
                 AND df.tablespace_name   NOT IN ('SYSAUX','SYSTEM','UNDOTBS2','UNDOTBS1' )
                 GROUP BY df.tablespace_name,df.bytes  ) allsize,
        (SELECT tablespace_name , ROUND(SUM((MAXBYTES-USER_BYTES)/(1024*1024*1024)),2)  autosize  
                         from dba_data_files  
                         WHERE  AUTOEXTENSIBLE ='YES' GROUP BY tablespace_name )  aut
        where   aut.tablespace_name (+)  = allsize.tablespace_name     
        order by  used_per  desc 
        )
        where rownum <= 1

output:
在这里插入图片描述

in the case, used_per was 100% for SAMPLE_DATA tablespace, which will trigger critical alarm.

2.2 check the space usage of datafile in tablespace

select file_name,tablespace_name,maxbytes/1024/1024 maxbytes_mb,bytes/1024/1024 size_mb,autoextensible from dba_data_files where tablespace_name='CPSQST_DATA'

output:
在这里插入图片描述
tablespace and data file in oracle 10g have the following characteristics:
1.a tablespace can accommodate up to 1022 files
2. maximum up to 32GB space for single file.
3. datafile can autoextent up to maxsize
2.3so in the case,you can:
2.3.1.add maxsize, of course you need to confirm actual available space in os before this.

[oracle@hq_testDB ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              22G   18G  2.6G  88% /
/dev/sda1              99M   22M   72M  24% /boot
tmpfs                 2.0G   16K  2.0G   1% /dev/shm
/dev/sdb1              79G   71G  3.9G  95% /u1
/dev/sdc1              79G   60G   16G  80% /u2
/dev/sdd1             168G  142G   17G  90% /u3
/dev/sde              114G   97G   11G  91% /u4
/dev/sdf              394G  371G  3.2G 100% /u5

in the case, file_id 16 and 17 were located in /u1, but unfortunately only 3.9G available,maybe you need to add harddisk, but here I will ignore the annoyance of space warning,so only can add up to 3.9G space to tablespace in /u1,here I will try add 1GB

alter database datafile 17 autoextend on maxsize 1G

2.3.2.add datafile in tablespace. only /u2 has most available space ,so I will add new datafile to here,for conveniency managment, it is recommended that you create same folder hierarchy as other datafile in tablespace, this is also advice from oracle(OMF standard)

[oracle@hq_testDB u2]$ mkdir -p /u2/oradata/sample_data
[oracle@hq_testDB u2]$ chmod -R 775 /u2/oradata/sample_data

next, you can add datafile to sample_data tablespace

alter tablespace sample_data add datafile '/u2/oradata/sample_data/sample_data03.dbf' size 50M autoextend on maxsize 1G

confirm again

select file_id,file_name,tablespace_name,maxbytes/1024/1024 maxsize_mb,bytes/1024/1024 usedsize_mb,autoextensible from dba_data_files where tablespace_name='SAMPLE_DATA'

在这里插入图片描述
here,the size for fild_id 17 was added to 1024MB by step 2.3.1, and also added a new datafile with 1GB space by step 2.3.2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值