ORA-00059: maximum number of DB_FILES exceeded 情况分析及实验处理

ORA-00059: maximum number of DB_FILES exceeded 处理

情况一:db_files 参数值 200没有超过控制文件里 maxdatafiles 对应 的大小,则可以通过直接加大参数db_files 值来防止此错误出现,以便正确加入数据文件。

清空二:如果 db_files 已经设置和超过控制文件里 maxdatafiles 对应 的大小, 报错ORA-00059, 则只有修改控制文件中的值了,所以需要重新生成控制文件。
具体步骤如下:使用 alter database backup controlfile to trace , 到你的udump 目录下找到这个刚刚生成的trc文件,去掉其中的解释部分,保留Create controlfile 部分,编辑此文件,增加MAXDATAFILES 的值,然后关闭数据库shutdown immediate , 全备份一次数据库, 将现有的控制文件备份到其他地方, 然后从控制文件目录删除,假设将编辑好的trc文件命名为rebuild_control.sql; 那么我们现在可以执行重新建立控制文件了。 注意修改的trc 文件开头都会有 STARTUP NOMOUNT 。

--查询控制文件数据文件等
SQL> select name from v$controlfile
     union all
     select member from v$logfile
     union all
     select name from v$datafile
     union all
     select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DBdb/control01.ctl
/u01/app/oracle/fast_recovery_area/DBdb/control02.ctl
/u01/app/oracle/oradata/DBdb/redo03.log
/u01/app/oracle/oradata/DBdb/redo02.log
/u01/app/oracle/oradata/DBdb/redo01.log
/u01/app/oracle/oradata/DBdb/system01.dbf
/u01/app/oracle/oradata/DBdb/sysaux01.dbf
/u01/app/oracle/oradata/DBdb/undotbs01.dbf
/u01/app/oracle/oradata/DBdb/users01.dbf
/u01/app/oracle/oradata/DBdb/example01.dbf
/u01/app/oracle/oradata/DBdb/temp01.dbf

11 rows selected.


SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name               string
db_file_name_convert                 string
db_name                              string      DBdb
db_unique_name                       string      DBdb
global_names                         boolean     FALSE
instance_name                        string      DBdb
lock_name_space                      string
log_file_name_convert                string
processor_group_name                 string
service_names                        string      service1,service2,service3

--查询db_files参数值
SQL> show parameter db_file

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_multiblock_read_count        integer     69
db_file_name_convert                 string
db_files                             integer     200
SQL>

--查询数据文件个数:这里为5,此次试验是假定为200,且达到了db_files的限制值
SQL> select count(1) from dba_data_files;

  COUNT(1)
----------
         5

--备份控制文件到trace
SQL> Alter database backup controlfile to trace;

Database altered.

--备份spfile:
SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/11.2.0
                                                 /db_1/dbs/spfileDBdb.ora
SQL>
SQL> create pfile='/home/oracle/init_dbdb.ora' from spfile;

File created.

SQL>

--备份控制文件到/home/oracle下
[oracle@wang ~]$ cat /u01/app/oracle/diag/rdbms/dbdb/DBdb/trace/DBdb_ora_8521.trc |grep -v ^#|grep -v ^-- >/home/oracle/control.bak
[oracle@wang ~]$ ls -lrt control.bak
-rw-r--r-- 1 oracle oinstall 4188 Apr 24 15:10 control.bak
[oracle@wang ~]$

--如下为备份的控制文件原文:发现MAXDATAFILES的值为200(默认值)
[oracle@wang ~]$
[oracle@wang ~]$ vi control_raw.ora
*** 2018-04-24 16:07:55.255
-- The following are current System-scope REDO Log Archival related
-- parameters and can be included in the database initialization file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
--
-- DB_UNIQUE_NAME="DBdb"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=4
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=?/dbs/arch
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
-- LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM EXPEDITE NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
-- LOG_ARCHIVE_DEST_STATE_1=ENABLE
--
-- Below are two sets of SQL statements, each of which creates a new
-- control file and uses it to open the database. The first set opens
-- the database with the NORESETLOGS option and should be used only if
-- the current versions of all online logs are available. The second
-- set opens the database with the RESETLOGS option and should be used
-- if online logs are unavailable.
-- The appropriate set of statements can be copied from the trace into
-- a script file, edited as necessary, and executed when there is a
-- need to re-create the control file.
--
--     Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "DBDB" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 200
    MAXINSTANCES 8
    MAXLOGHISTORY 1752
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/DBdb/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/DBdb/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/DBdb/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/u01/app/oracle/oradata/DBdb/system01.dbf',
  '/u01/app/oracle/oradata/DBdb/sysaux01.dbf',
  '/u01/app/oracle/oradata/DBdb/undotbs01.dbf',
  '/u01/app/oracle/oradata/DBdb/users01.dbf',
  '/u01/app/oracle/oradata/DBdb/example01.dbf'
CHARACTER SET ZHS16GBK
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/archivelog/2018_04_24/o1_mf_1_1_%u_.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE
-- All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
-- Database can now be opened normally.
ALTER DATABASE OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/DBdb/temp01.dbf'
     SIZE 187695104  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.
--
--     Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "DBDB" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 200
    MAXINSTANCES 8
    MAXLOGHISTORY 1752
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/DBdb/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/DBdb/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/DBdb/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/u01/app/oracle/oradata/DBdb/system01.dbf',
  '/u01/app/oracle/oradata/DBdb/sysaux01.dbf',
  '/u01/app/oracle/oradata/DBdb/undotbs01.dbf',
  '/u01/app/oracle/oradata/DBdb/users01.dbf',
n '/u01/app/oracle/oradata/DBdb/example01.dbf'
CHARACTER SET ZHS16GBK
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/archivelog/2018_04_24/o1_mf_1_1_%u_.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/DBdb/temp01.dbf'
     SIZE 187695104  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.
--
[oracle@wang ~]$


--更改controlfile中的的MAXDATAFILES值并更名为rebuild_control.sql
[oracle@wang ~]$ mv control.bak rebuild_control.sql
[oracle@wang ~]$ ls -lrt rebuild_control.sql
-rw-r--r-- 1 oracle oinstall 1817 Apr 24 15:16 rebuild_control.sql
[oracle@wang ~]$
[oracle@wang ~]$
[oracle@wang ~]$ cat rebuild_control.sql
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "DBDB" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 2100  
    MAXINSTANCES 8
    MAXLOGHISTORY 1672
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/DBdb/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/DBdb/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/DBdb/redo03.log'  SIZE 50M BLOCKSIZE 512
DATAFILE
  '/u01/app/oracle/oradata/DBdb/system01.dbf',
  '/u01/app/oracle/oradata/DBdb/sysaux01.dbf',
  '/u01/app/oracle/oradata/DBdb/undotbs01.dbf',
  '/u01/app/oracle/oradata/DBdb/users01.dbf',
  '/u01/app/oracle/oradata/DBdb/example01.dbf'
CHARACTER SET ZHS16GBK
;
RECOVER DATABASE
ALTER SYSTEM ARCHIVE LOG ALL;
ALTER DATABASE OPEN;
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/DBdb/temp01.dbf'
     SIZE 187695104  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
[oracle@wang ~]$
[oracle@wang ~]$

--关库:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

--备份整改数据库
--移除原先的控制文件:
[oracle@wang DBdb]$ mv /u01/app/oracle/oradata/DBdb/control01.ctl /home/oracle/control01.ctl
[oracle@wang DBdb]$ mv /u01/app/oracle/fast_recovery_area/DBdb/control02.ctl /home/oracle/control02.ctl
[oracle@wang DBdb]$

--执行重建控制文件脚本:
SQL> @/home/oracle/rebuild_control.sql
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2257840 bytes
Variable Size             549456976 bytes
Database Buffers          281018368 bytes
Redo Buffers                2371584 bytes

Control file created.

ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required



System altered.


Database altered.


Tablespace altered.

SQL> select host_name,instance_name,status from v$instance;

HOST_NAME       INSTANCE_NAME    STATUS
--------------- ---------------- ------------
wang            DBdb             OPEN

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31397003/viewspace-2153339/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31397003/viewspace-2153339/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值