oracle数据库扩容

来源:互联网 发布:淘宝二级页面怎么做 编辑:程序博客网 时间:2024/06/05 20:31

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

扩容的步骤:

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 0