ORA-00059: maximum number of DB_FILES exceeded 情況分析及實驗處理

不一樣的天空w發表於2018-04-25
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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章