oracle数据库ORA-01654 错误的解决方法
引言:
数据库突然报: ORA-01654: unable to extend index BO.INDEX_indexname by 311072 in tablespace 错误,上网查原因,发现解决方法只有一个,就
是增加tablespace的大小.现归纳解决此问题的方法如下.
方法1:
当出现类似错误时,首先检查tablespace的空间是否足够大,如果不够大,说明tablespace的空间不够扩展了,这时候需要将tablespace的datafile的
size变大,方法很简单我就不讲了,或增加新的datafile到此tablespace中,使用alter tablespace mytablespace add datafile 'XXX' size xxxx就OK啦
.
方法2:
这就是我这此遇到的问题.我的datafile的size为2000m,而我的index的next extent为2G,pct increase为50,这样一来下一个要扩展的extent为3G,
而我的datafile的Size为2G,故无发找到连续3G的空间,当然会出错.
问题找到了,解决当然很简单,修改next extent 为128k,pct increase为0,问题解决.
不知道是谁设定的,真是个低级错误.
---------------------------------------------分割线---------------------------------------------
问题现象:
测试库使用如下方式创建索引:
create index IDX_ANA_OFFICE on ANA (OFFICE_CITY, OFFICE_NO)
tablespace IDX
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 128K
next 128K
minextents 1
maxextents unlimited
pctincrease 0
);
报错:ORA-01654: unable to extend index GALT.IDX_OFFICE by 128 in tablespace IDX
改为默认创建:
create index IDX_ANA_PNR_OFFICE on ANA (OFFICE_CITY, OFFICE_NO)
tablespace IDX;
查看SQL是:
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
问题追查:
1、首先针对1654这个报错,MOS是这样介绍的:
Error: ORA-01654
Text: unable to extend index %s.%s by %s in tablespace %s
-------------------------------------------------------------------------------
Cause: Failed to allocate extent for index segment in tablespace.
Action: Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more
files to the specified tablespace
(1)、针对表空间不足的情况,建议使用DBA_FREE_SPACE视图进行查询(Note: 121259.1提供了若干脚本)。
(2)、另外,针对索引的问题,DBA_INDEXES视图则描述了下一个分区(NEXT_EXTENT)的大小,以及所有索引的百分比增长(PCT_INCREASE)。“next_extent”指
的是试图分配的区大小(也就是报错中涉及的内容)。
区分配计算:next_extent = next_extent * (1 + (pct_increase/100))
在Concept中描述了为段分配区的算法
How Extents Are Allocated
Oracle uses different algorithms to allocate extents, depending on whether they are locally managed or dictionary managed. With
locally managed tablespaces, Oracle looks for free space to allocate to a new extent by first determining a candidate datafile in the
tablespace and then searching the datafile’s bitmap for the required number of adjacent free blocks. If that datafile does not have
enough adjacent free space, then Oracle looks in another datafile.
MOS也提出了若干可能的解决方法:
Possible solutions:
------------------
- Manually coalesce adjacent free extents:
ALTER TABLESPACE <tablespace name> COALESCE;
The extents must be adjacent to each other for this to work.
- Add a datafile:
ALTER TABLESPACE <tablespace name> ADD DATAFILE '<full path and file
name>' SIZE <integer> <k|m>;
- Resize the datafile:
ALTER DATABASE DATAFILE '<full path and file name>' RESIZE <integer> <k|m>;
- Enable autoextend:
ALTER DATABASE DATAFILE '<full path and file name>' AUTOEXTEND ON
MAXSIZE UNLIMITED;
- Defragment the Tablespace
- Lower "next_extent" and/or "pct_increase" size:
ALTER <segment_type> <segment_name> STORAGE ( next <integer> <k|m>
pctincrease <integer>);
下面这句话我认为是重点:
“这个错误并未指出表空间中是否有足够的空间,仅仅说明Oracle不能找到一个足够大的连续空间用来匹配next extent。
2、另一篇文章“TROUBLESHOOTING GUIDE (TSG) - UNABLE TO CREATE / EXTEND Errors”说明了各种关于“UNABLE TO CREATE / EXTEND”的错误。
“unable to extend"的错误是指当没有足够连续的空间用来分配段的情况。
I. 提出了解决这种错误所需要的信息:
(1)、判断报错表空间中最大的连续空间是多少。
SELECT max(bytes) FROM dba_free_space WHERE tablespace_name = '<tablespace name>';
这个SQL返回的是表空间最大允许的连续块大小。(DBA_FREE_SPACE不会返回临时表空间的信息,可以参考“DBA_FREE_SPACE Does not Show Information
about Temporary Tablespaces (文档 ID 188610.1)”这篇文章会介绍如何查看临时表空间的连续块大小)。
如果在这个报错之后立即执行上述SQL,则返回的表空间中连续的最大块会小于这个对象正在试图分配的next extent的空间。
(2)、判断NEXT_EXTENT大小。
a) 对于PCT_INCREASE=0的字典管理表空间(DMT)或者使用统一UNIFORM区管理的本地管理表空间(LMT),使用如下SQL:
SELECT NEXT_EXTENT, PCT_INCREASE
FROM DBA_SEGMENTS
WHERE SEGMENT_NAME = <segment name>
AND SEGMENT_TYPE = <segment type>
AND OWNER = <owner>
AND TABLESPACE_NAME = <tablespace name>;
其中segment_type会展示在错误信息中,可能包含如下类型的segment:
CLUSTER
INDEX
INDEX PARTITION
LOB PARTITION
LOBINDEX
LOBSEGMENT
NESTED TABLE
ROLLBACK
TABLE
TABLE PARTITION
TYPE2 UNDO
TYPE2 UNDO (ORA-1651)
同样地,segment_name可以在错误信息中找到。
b) 对于使用SYSTEM|AUTOALLOCATE区管理的本地管理表空间(LMT)。
没有方法可以查询它的next extent大小。只能查询错误信息,错误信息中的块数乘以表空间的块大小,以此来判断需要创建的区大小。
c) 对于PCT_INCREASE>0的字典管理表空间(DMT)。
SELECT EXTENT_MANAGEMENT FROM DBA_TABLESPACES WHERE TABLESPACE_NAME = '<tablespace name>';
使用如下公式计算需要分配的区大小:
extent size = next_extent * (1 + (pct_increase/100)
例如:
next_extent = 512000
pct_increase = 50
next extent size = 512000 * (1 + (50/100)) = 512000 * 1.5 = 768000
注意:
ORA-01650 Rollback Segment
pct_increase仅用于Oracle若干早期版本,后面版本中回滚段的pct_increase默认是0。
ORA-01652 Temporary Segment
临时段与表空间创建的存储默认值相同。
如果查询出现错误,则需要判断这个查询语句是否尽可能地最优以完成排序。
(3)、判断表空间是否包含了AUTOEXTENSIBLE,并已经达到MAXSIZ。
对于数据文件:
SELECT file_name, bytes, autoextensible, maxbytes FROM dba_data_files WHERE tablespace_name='<tablespace name> ';
对于临时文件:
SELECT file_name, bytes, autoextensible, maxbytes FROM dba_temp_files WHERE tablespace_name='<tablespace name> ';
(4)、判断哪种解决方法最优。
如果NEXT EXTENT的容量(步骤2或3)大于空闲空间最大的连续块,那么“Manually Coalesce Adjacent Free Extents”是个选择。如果coalesce后仍旧没有足
够的连续空间,那么可能需要其他的选项。
如果表空间的数据文件/临时文件的卷有足够的空间,那么添加数据文件/临时文件或消除表空间碎片化可能管用,将这个文件添加到新卷中。
如果表空间是AUTOEXTENSIBLE并且已经MAXSIZE,那么需要提高最大容量(确认有足够的卷空间),或者添加数据文件/临时文件,或者消除碎片化。
如果NEXT EXTENT的容量(步骤2或3)小于空闲空间最大的连续块,那么就需要联系Oracle支持。
II. 可能的解决方案:
(1)、手工合并相邻的空闲区。
ALTER TABLESPACE <tablespace name> COALESCE;
(2)、将一个或多个数据文件/临时文件修改为使用AUTOEXTEND。
ALTER DATABASE DATAFILE|TEMPFILE '<full path and name>' AUTOEXTEND ON MAXSIZE <integer> <k | m | g |
注意:强烈建议明确MAXSIZE参数,防止数据文件/临时文件消耗卷上的所有可用空间。
(3)、添加数据文件/临时文件。
ALTER TABLESPACE <tablespace name> ADD DATAFILE|TEMPFILE '<full path and file name>' SIZE <integer> <k | m | g | t | p | e>;
(4)、如果段是字典管理表空间,可以降低“next_extent”和/或“pct_increase”的大小。
对于非临时段和非分区段:
ALTER <SEGMENT TYPE> <segment_name> STORAGE ( next <integer> <k | m | g | t | p | e> pctincrease <integer>);
对于非临时段和分区段:
ALTER TABLE <table_name> MODIFY PARTITION <partition_name> STORAGE ( next <integer> <k | m | g | t | p | e> pctincrease <integer>);
对于临时段:
ALTER TABLESPACE <tablespace name> DEFAULT STORAGE (initial <integer> <k | m | g | t | p | e> next <integer> <k | m | g | t | p | e>
pctincrease <integer>);
(5)、重改数据文件/临时文件的大小。
ALTER DATABASE DATAFILE|TEMPFILE '<full path and file name>' RESIZE <integer> <k | m | g | t | p | e>;
(6)、消除表空间的碎片。
附录:和此类解决方法相关的报错:
ORA-1650: unable to extend rollback segment %s by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for a rollback segment in the tablespace.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1651: unable to extend save undo segment by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for saving undo entries for the indicated offline tablespace.
Action: Check the storage parameters for the SYSTEM tablespace. The tablespace needs to be brought back online so the undo can be
applied.
ORA-1652: unable to extend temp segment by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for a temporary segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1653: unable to extend table %s.%s by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for a table segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1654: unable to extend index %s.%s by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for an index segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1655: unable to extend cluster %s.%s by %s for tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for a cluster segment in tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1658: unable to create INITIAL extent for segment in tablespace %s
Cause: Failed to find sufficient contiguous space to allocate INITIAL extent for segment being created.
Action: Use ALTER TABLESPACE ADD DATAFILE to add additional space to the tablespace or retry with a smaller value for INITIAL
ORA-1659 unable to allocate MINEXTENTS beyond %s in tablespace %s
Cause: Failed to find sufficient contiguous space to allocate MINEXTENTS for the segment being created.
Action: Use ALTER TABLESPACE ADD DATAFILE to add additional space to the tablespace or retry with smaller value for MINEXTENTS, NEXT
or PCTINCREASE
ORA-1683: unable to extend index %s.%s partition %s by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for index segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1688: unable to extend table %s.%s partition %s by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for table segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1691: unable to extend lob segment %s.%s by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for LOB segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-1692: unable to extend lob segment %s.%s partition %s by %s in tablespace %s
Cause: Failed to allocate an extent of the required number of blocks for LOB segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-3233: unable to extend table %s.%s subpartition %s by %s in tablespace %s
Cause: Failed to allocate an extent for table subpartition segment in tablespace.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-3234: unable to extend index %s.%s subpartition %s by %s in tablespace %s
Cause: Failed to allocate an extent for index subpartition segment in tablespace.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
ORA-3238: unable to extend LOB segment %s.%s subpartition %s by %s in tablespace %s
Cause: An attempt was made to allocate an extent for LOB subpartition segment in tablespace, but the extent could not be allocated
because there is not enough space in the tablespace indicated.
Action: Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.
总结:
针对上面案例中的错误,总体讲是空间不足导致的,之所以使用第二个SQL可以,原因可能就是这种参数值设置下的满足可以空闲空间连续块的容量,上面采用的
是减小extent分配大小的方式,另外上面提到的扩大文件、修改参数值、消除碎片化等方法都可以尝试使用。
原网址:http://www.linuxidc.com/Linux/2013-12/93685.htm
oracle数据库ORA-01654 错误的解决方法的更多相关文章
- navicat连接oracle数据库报ORA-28547: connection to server failed, probable Oracle Net admin error错误的解决方法
原文:navicat连接oracle数据库报ORA-28547: connection to server failed, probable Oracle Net admin error错误的解决方法 ...
- Windows 7 64bit上安装Oracle Database 12c [INS-30131] 错误的解决方法
Windows 7 64bit上安装Oracle Database 12c,出现以下错误: 解决方法: 第一步:控制面板>所有控制面板项>管理工具>服务>SERVER 启动 ...
- oracle数据库升级dbua操作阻塞解决方法(解决ORA-32004报错)
操作环境 1.SuSE11sp3操作系统 2.oracle 11.2.0.3版本升级到11.2.0.4版本 问题现象 oracle 11.2.0.3版本升级到11.2.0.4版本时执行dbua命令 ...
- Linux删除ORACLE数据库用户失败提示ORA-01940解决方法
操作环境 SuSE11+Oracle11gR2 问题现象 删除ORACLE数据库用户失败,提示ORA-01940: cannot drop a user that is currently conne ...
- MySQL连接本地数据库时报1045错误的解决方法
navicat for MySQL 连接本地数据库出现1045错误 如下图: 说明连接mysql时数据库密码错误,需要修改密码后才可解决问题: 解决步骤如下: .首先打开命令行:开始->运行 ...
- navicat for MySQL连接本地数据库时报1045错误的解决方法
navicat for MySQL 连接本地数据库出现1045错误 如下图: 说明连接mysql时数据库密码错误,需要修改密码后才可解决问题: 解决步骤如下: 1.首先打开命令行:开始->运行- ...
- ORA-28547:connection to server failed, probable Oracle Net admin error错误,解决方法
当用navicat连接oralce数据库时报ORA-28547错误时,直接懵逼了,上网查了资料说是navicat自带的oci.dll文件的版本和服务器端的oralce数据库的版本不一致造成的. 修改O ...
- php连接Access数据库错误及解决方法
<?php $connstr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("data.m ...
- ORA-12560: TNS: 协议适配器错误的解决方法
ORA-12560: TNS: 协议适配器错误的解决方法 造成ORA-12560: TNS: 协议适配器错误的问题的原因有三个: 1.监听服务没有起起来.windows平台个一如下操作:开始---程序 ...
- Oracle数据库使用出现错误-状态: 失败 ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist
Oracle数据库使用出现错误-状态: 失败 ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist ...
随机推荐
- JS魔法堂:获取当前脚本文件的绝对路径
一.前言 当写模块加载器时,获取当前脚本文件的绝对路径作为基础路径是必不可少的一步,下面我们一起来探讨一下这个问题吧! 二.各大浏览器的实现方式 [a]. Chrome和FF 超简单的一句足矣! va ...
- TinyFox在VS2015上的调试器
这个一个TinyFox在VS2015上的调试工具 : 开源了 https://github.com/maxzhang1985/TinyFoxDEBUG 开发这个工具的初衷,是想更便捷的调试Nancy ...
- 转载:第四弹!全球首个微信小程序(应用号)开发教程!通宵吐血赶稿,每日更新!
感谢大家支持!博卡君周末休息了两天,今天又回到战斗状态了.上周五晚上微信放出官方工具和教程了,推荐程序猿小伙伴们都去试一试,结合教程和代码,写写自己的 demo 也不错. 闲话不多说,开始更新! 第七 ...
- JavaScript 按值传递 & 按引用传递
(1)值的比较--引用的比较 首先,原始值的比较是值的比较:只有在它们值相等的时候它们才相等 比如简单的 var a1 = 10; var a2 = 10; console.log(a1 === a2 ...
- 设计模式--中介(Mediator)模式
时隔很长一段时,现在又重温设计模式,上个星期学习<设计模式--代理(Proxy)模式>http://www.cnblogs.com/insus/p/4128814.html. 温故而知新, ...
- Python入门笔记(25):Python面向对象(2)
一.类 类就是一个数据结构,封装了数据和操作. 类的声明与函数的声明十分类似: class newClass(object): """class documentatio ...
- WPF中实现自定义虚拟容器(实现VirtualizingPanel)
WPF中实现自定义虚拟容器(实现VirtualizingPanel) 在WPF应用程序开发过程中,大数据量的数据展现通常都要考虑性能问题.有下面一种常见的情况:原始数据源数据量很大,但是某一时刻数据容 ...
- Oracle数据库导入导出总结(dmp文件)
Oracle 10G 管理页面(Oracle Enterprise Manager 10g): http://localhost:1158/em http://localhost:1158/em/co ...
- Java中的Set集合接口实现插入对象不重复的原理
在java的集合中,判断两个对象是否相等的规则是: 1).判断两个对象的hashCode是否相等 . 如果不相等,认为两个对象也不相等,完毕 如果相等,转入2)(这一点只是为了提 ...
- web api post注意事项
黄色笑话 近期一个项目需要使用到web api 在使用过程中,对应get请求方式的使用基本没出什么问题 但是对于post请求状况百出. 今将遇到的的问题列出.以作借鉴. 问题 -----post方式 ...