通过查看ASM磁盘组的容量以及所有表空间的使用情况,可以给往后的容量配置做准备预测。
----查看存储容量:
---查看v$asm_diskgroup视图
SQL> select group_number,name,total_mb,free_mb from v$asm_diskgroup;
GROUP_NUMBER NAME TOTAL_MB FREE_MB
------------ ------------------------------ ---------- ----------
1 DATA 5114 2685
---进入asmcmd查看:
grid@node1 > export ORACLE_SID=+ASM1
grid@node1 > asmcmd
ASMCMD> lsdg
State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED EXTERN N N 512 4096 1048576 5114 2685 0 2685 0 DATA/
----查看所有表空间的使用情况:
select t.*
from (select d.tablespace_name,
space "sum_space(m)",
blocks sum_blocks,
space - nvl(free_space, 0) "used_space(m)",
round((1 - nvl(free_space, 0) / space) * 100, 2) "used_rate(%)",
free_space "free_space(m)"
from (select tablespace_name,
round(sum(bytes) / (1048576), 2) space,
sum(blocks) blocks
from dba_data_files
group by tablespace_name) d,
(select tablespace_name,
round(sum(bytes) / (1048576), 2) free_space
from dba_free_space
group by tablespace_name) f
where d.tablespace_name = f.tablespace_name(+)
union all
----if have tempfile
select d.tablespace_name,
space "sum_space(m)",
blocks sum_blocks,
used_space "used_space(m)",
round(nvl(used_space, 0) / space * 100, 2) "used_rate(%)",
space - used_space "free_space(m)"
from (select tablespace_name,
round(sum(bytes) / (1048576), 2) space,
sum(blocks) blocks
from dba_temp_files
group by tablespace_name) d,
(select tablespace,
round(sum(blocks * 32768) / (1048576), 2) used_space
from v$sort_usage
group by tablespace) f
where d.tablespace_name = f.tablespace(+)) t
order by "used_rate(%)" desc;
---统计出来的数据:
TABLESPACE_NAME | sum_space(m) | SUM_BLOCKS | used_space(m) | used_rate(%) | free_space(m) | |
1 | SYSTEM | 840 | 107520 | 832.25 | 99.08 | 7.75 |
2 | SYSAUX | 770 | 98560 | 725.06 | 94.16 | 44.94 |
3 | EXAMPLE | 346.25 | 44320 | 310.19 | 89.59 | 36.06 |
4 | USERS | 42.5 | 5440 | 29.19 | 68.68 | 13.31 |
5 | MYSPACE | 50 | 6400 | 17.37 | 34.74 | 32.63 |
6 | TS_CTL | 5 | 640 | 1 | 20 | 4 |
7 | UNDOTBS1 | 100 | 12800 | 19.25 | 19.25 | 80.75 |
8 | TS_XXF | 10 | 1280 | 1 | 10 | 9 |
9 | TEMP | 100 | 12800 | 4 | 4 | 96 |
10 | TEMP3 | 10 | 1280 | 0 | ||
11 | TEMP4 | 10 | 1280 | 0 |