Oracle管理监控之Oracle数据库存储空间监控
2017-04-01 16:34
741 查看
1、监控表空间使用率
基表:dba_data_files、dba_free_space
脚本:
select a.tablespace_name,
round((a.maxbytes / 1024 / 1024 / 1024), 2) "sum G",
round((a.bytes / 1024 / 1024 / 1024), 2) "datafile G",
round(((a.bytes - b.bytes) / 1024 / 1024 / 1024), 2) "used G",
round(((a.maxbytes - a.bytes + b.bytes) / 1024 / 1024 / 1024), 2) "free G",
round(((a.bytes - b.bytes) / a.maxbytes) * 100, 2) "percent_used(%)"
from (select tablespace_name, sum(sumnow) bytes, sum(summax) maxbytes
from (select t1.tablespace_name,
sum(t1.bytes) sumnow,
sum(t1.maxbytes) summax
from dba_data_files t1
where t1.maxbytes <> 0
group by t1.tablespace_name
union all
select t2.tablespace_name,
sum(t2.bytes) sumnow,
sum(t2.bytes) summax
from dba_data_files t2
where t2.maxbytes = 0
group by t2.tablespace_name)
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.maxbytes) desc;
2、创建表空间时指定最大值时查询表空间使用率脚本:
select a.tablespace_name,
round((a.maxbytes / 1024 / 1024 / 1024), 2) "sum G",
round((a.bytes / 1024 / 1024 / 1024), 2) "datafile G",
round(((a.bytes - b.bytes) / 1024 / 1024 / 1024), 2) "used G",
round(((a.maxbytes - a.bytes + b.bytes) / 1024 / 1024 / 1024), 2) "free G",
round(((a.bytes - b.bytes) / a.maxbytes) * 100, 2) "percent_used(%)"
from (select tablespace_name, sum(bytes) bytes, sum(maxbytes) maxbytes
from dba_data_files
where maxbytes != 0
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.maxbytes) desc;
3、查看数据文件状态
select t.tablespace_name,
t.file_id,
t.file_name,
t.autoextensible,
ROUND(t.maxbytes / 1024 / 1024 / 1024, 2) || 'G' AS MAXBYTES,
ROUND(t.bytes / 1024 / 1024 / 1024, 2) || 'G' AS BYTES,
ROUND(t.user_bytes / 1024 / 1024 / 1024, 2) || 'G' AS USER_BYTES
from dba_data_files t;
基表:dba_data_files、dba_free_space
脚本:
select a.tablespace_name,
round((a.maxbytes / 1024 / 1024 / 1024), 2) "sum G",
round((a.bytes / 1024 / 1024 / 1024), 2) "datafile G",
round(((a.bytes - b.bytes) / 1024 / 1024 / 1024), 2) "used G",
round(((a.maxbytes - a.bytes + b.bytes) / 1024 / 1024 / 1024), 2) "free G",
round(((a.bytes - b.bytes) / a.maxbytes) * 100, 2) "percent_used(%)"
from (select tablespace_name, sum(sumnow) bytes, sum(summax) maxbytes
from (select t1.tablespace_name,
sum(t1.bytes) sumnow,
sum(t1.maxbytes) summax
from dba_data_files t1
where t1.maxbytes <> 0
group by t1.tablespace_name
union all
select t2.tablespace_name,
sum(t2.bytes) sumnow,
sum(t2.bytes) summax
from dba_data_files t2
where t2.maxbytes = 0
group by t2.tablespace_name)
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.maxbytes) desc;
2、创建表空间时指定最大值时查询表空间使用率脚本:
select a.tablespace_name,
round((a.maxbytes / 1024 / 1024 / 1024), 2) "sum G",
round((a.bytes / 1024 / 1024 / 1024), 2) "datafile G",
round(((a.bytes - b.bytes) / 1024 / 1024 / 1024), 2) "used G",
round(((a.maxbytes - a.bytes + b.bytes) / 1024 / 1024 / 1024), 2) "free G",
round(((a.bytes - b.bytes) / a.maxbytes) * 100, 2) "percent_used(%)"
from (select tablespace_name, sum(bytes) bytes, sum(maxbytes) maxbytes
from dba_data_files
where maxbytes != 0
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.maxbytes) desc;
3、查看数据文件状态
select t.tablespace_name,
t.file_id,
t.file_name,
t.autoextensible,
ROUND(t.maxbytes / 1024 / 1024 / 1024, 2) || 'G' AS MAXBYTES,
ROUND(t.bytes / 1024 / 1024 / 1024, 2) || 'G' AS BYTES,
ROUND(t.user_bytes / 1024 / 1024 / 1024, 2) || 'G' AS USER_BYTES
from dba_data_files t;
相关文章推荐
- Oracle的表空间的存储管理与优化技术
- Oracle存储空间管理
- Oracle的表空间的存储管理与优化技术
- oracle undo 表空间的监控管理
- Oracl数据库管理方面的资料(查询sga,查看oracle数据库名称sid,查看oracle数据库名称,查看表空间,修改表空间名称,数据库管理,sqlPlus数据显示)
- Oracle数据库系列 - Oracle 表空间管理
- Oracle管理监控之段空间利用监控-oracle性能优化
- ORACLE数据存储空间的管理
- Oracl数据库管理方面的资料(查询sga,查看oracle数据库名称sid,查看oracle数据库名称,查看表空间,修改表空间名称)
- Oracle的存储结构 2013-03-26 23:22 276人阅读 评论(0) 收藏 举报 目录(?)[+] Oracle的存储结构 在ORACLE数据库中对于数据存储的管理可以从两方面来论述。
- Oracle管理监控之监控表空间使用率脚本
- oracle学习笔记-存储空间管理(4)
- 监控和管理Oracle UNDO表空间的使用
- Oracle的表空间的存储管理与优化技术
- ORACLE数据存储空间的管理
- Oracle存储空间管理
- Oracle 逻辑存储结构之表空间管理和段空间管理
- Oracle 数据库自动存储管理-安装配置
- Oracle数据库的空间管理技巧
- oracle 两台机器做RAC负载均衡共享存储空间的数据库连接字符串