oracle数据库扩容

本文是针对数据文件不够大而磁盘空间足够的库容。而非磁盘空间不够的情况。

扩容的步骤:

1、查看需要扩容的表空间的数据文件是smallfile还是bigfile。

2、查看数据文件是否已经达到最大值上限,数据文件最大值上限见附录。

3、选择修改最大值上限或者添加数据文件的方式进行库容。


详细步骤如下:

1、查看需要扩容的表空间的文件是bigfile还是smallfile

select tablespace_name,bigfile from dba_tablespaces;

"BIG"列取值为"YES"表示表空间的文件模式为bigfile;取值为"NO"为smallfile。"YES"跳过下一步,“NO”执行下一步


2、本步骤是对应 smallfile的查看表空间的使用情况

select a.tablespace_name.a.used_space*8192/(1024*1024) used_space_mb,a.tablespace_size*8192/(1024*1024) tablespace_max_size_mb,round(a.used_percent,2) "used%" from dba_tablespace_usage_metrics a where a.tablespace_name not in (select distinct tablespace_name from dba_undo_extends);

其中used为表空间的使用率。当使用率大于90%时,建议进行扩容。


查看TEST表空间的数据文件

select tablespace_name,dba_date_file.file_name from dba_data_files where tablespace_name="TEST";

修改数据文件的最大值上限:

ALTER DATABASE DATAFILE '+DG_ORA/i2kdb/test.dbf' AUTOEXTEND ON NEXT 5M MAXSIZE 20G;

若已经突破最大值上限32G,则添加TEST表空间的数据文件,进行扩容

alter tablespace TEST add datafile '+DG_ORA/i2kdb/test_1.dbf' size 2000M;


3、本步骤对应的是bigfile的操作步骤

select a.tablespace_name.a.used_space*8192/(1024*1024) used_space_mb,a.tablespace_size*8192/(1024*1024) tablespace_max_size_mb,round(a.used_percent,2) "used%" from dba_tablespace_usage_metrics a where a.tablespace_name not in (select distinct tablespace_name from dba_undo_extends);

其中used为表空间的使用率。当使用率大于90%时,建议进行扩容。

查看TEST表空间对应的数据文件

select tablespace_name,dba_date_file.file_name from dba_data_files where tablespace_name="TEST";

修改数据文件的最大值上限

alter database datafile '+DG_ORA/i2kdb/test.dbf' resize 20000M;


注:

1)bigfile模式的表空间超过一定大小后会影响系统的性能,建议每个表空间不超过2TB。

2)对于bigfile模式的数据文件,使用resize的方式直接扩容,扩容后数据文件名称保持不变。

3)以上命令的20000m,值得是扩容后的表空间的总大小

4)bigfile模式的表空间无法通过添加数据文件的方式进行扩容


4、附录

数据文件最大值上限跟数据块大小相关,数据块大小的默认值一般都是8KB。可通过以下方式进行查看。

show parameter db_block_size;


各数据块对应的数据文件大小关系如下:


2K4K8K16K21K
小文件8G16G32G64G128G
大文件8T16T32T64T128T

各类大小的数据块对应的数据文件最大值的计算方式,见我上一篇博客:

http://blog.csdn.net/qiuyanzhen/article/details/50812152


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值