重建控制文件,并且不干净的关闭数据库测试

重建控制文件,并且不干净的关闭数据库测试:

数据库SHUTDOWN ABORT,删除CONTROLFILE

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  419430400 bytes
Fixed Size                  2021248 bytes
Variable Size             171968640 bytes
Database Buffers          243269632 bytes
Redo Buffers                2170880 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "XUEXI" RESETLOGS  ARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 100
  5      MAXINSTANCES 8
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 '/oradata/xuexi/redo01.log'  SIZE 50M,
  9    GROUP 2 '/oradata/xuexi/redo02.log'  SIZE 50M,
 10    GROUP 3 '/oradata/xuexi/redo03.log'  SIZE 50M,
 11    GROUP 4 '/oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log'  SIZE 50M,
 12    GROUP 5 (
 13      '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log',
 14      '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log'
 15    ) SIZE 50M,
 16    GROUP 7 (
 17      '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log',
 18      '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log',
 19      '/oradata/logfile07.log'
 20    ) SIZE 100M
 21  -- STANDBY LOGFILE
 22  DATAFILE
 23    '/oradata/xuexi/system01.dbf',
 24    '/oradata/xuexi/undotbs01.dbf',
 25    '/oradata/xuexi/sysaux01.dbf',
 26    '/oradata/xuexi/users01.dbf',
 27    '/oradata/xuexi/XUEXI/datafile/o1_mf_tomf_8yqwrdoj_.dbf',
 28    '/oradata/xuexi/omf2.dbf',
 29    '/oradata/xuexi/XUEXI/datafile/testimp01.dbf',
 30    '/oradata/xuexi/XUEXI/datafile/testimp011.dbf',
 31    '/oradata/xuexi/XUEXI/datafile/testo1.dbf',
 32    '/oradata/xuexi/XUEXI/datafile/testo2.dbf'
 33  CHARACTER SET AL32UTF8
 34  ;

Control file created.

SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01100: database already mounted


SQL> recover database ;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

 

SQL> RECOVER DATABASE USING BACKUP CONTROLFILE;
ORA-00279: change 1917689 generated at 10/04/2013 21:15:57 needed for thread 1
ORA-00289: suggestion : /archive/1_102_822387818.dbf
ORA-00280: change 1917689 for thread 1 is in sequence #102


Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/archive/1_102_822387818.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log '/archive/1_102_822387818.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory

显然这里缺少102这个归档,因为他是当前日志文件,所以我们需要把日志复制到归档目录下,但是那个日志是102呢,这样就可以确定
[oracle@localhost bdump]$ tail -n 4000 alert_xuexi.log |grep Current
  Current log# 4 seq# 100 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log
  Current log# 4 seq# 100 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log
  Current log# 5 seq# 101 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log
  Current log# 5 seq# 101 mem# 1: /oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log
  Current log# 7 seq# 102 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log
  Current log# 7 seq# 102 mem# 1: /oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log
  Current log# 7 seq# 102 mem# 2: /oradata/logfile07.log
  可以确认/oradata/logfile07.log就是需要的归档
cp /oradata/logfile07.log /archive/1_102_822387818.dbf

SQL> recover database using backup controlfile
ORA-00279: change 1917689 generated at 10/04/2013 21:15:57 needed for thread 1
ORA-00289: suggestion : /archive/1_102_822387818.dbf
ORA-00280: change 1917689 for thread 1 is in sequence #102

Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
完成后即可
当然也快手动输入你确认的当前归档如下:
SQL> recover database using backup controlfile
ORA-00279: change 1917689 generated at 10/04/2013 21:15:57 needed for thread 1
ORA-00289: suggestion : /archive/1_102_822387818.dbf
ORA-00280: change 1917689 for thread 1 is in sequence #102

Specify log: {=suggested | filename | AUTO | CANCEL}
/oradata/logfile07.log
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;

SQL> alter database open resetlogs;

Database altered.
Log applied.
Media recovery complete.


alter database backup controlfile to trace 全文
/opt/oracle/admin/xuexi/udump/xuexi_ora_5686.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /opt/oracle/product/10.2.0/db_1
System name:    Linux
Node name:      localhost.localdomain
Release:        2.6.18-164.el5
Version:        #1 SMP Tue Aug 18 15:51:48 EDT 2009
Machine:        x86_64
Instance name: xuexi
Redo thread mounted by this instance: 1
Oracle process number: 18
Unix process pid: 5686, image: oracle@localhost.localdomain (TNS V1-V3)

*** SERVICE NAME:(SYS$USERS) 2013-10-04 21:38:20.304
*** SESSION ID:(146.91) 2013-10-04 21:38:20.304
*** 2013-10-04 21:38:20.304
-- 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="xuexi"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=2
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=?/dbs/arch
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=/archive'
-- LOG_ARCHIVE_DEST_1='OPTIONAL REOPEN=300 NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOEXPEDITE NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='REGISTER 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 "XUEXI" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/oradata/xuexi/redo01.log'  SIZE 50M,
  GROUP 2 '/oradata/xuexi/redo02.log'  SIZE 50M,
  GROUP 3 '/oradata/xuexi/redo03.log'  SIZE 50M,
  GROUP 4 '/oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log'  SIZE 50M,
  GROUP 5 (
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log'
  ) SIZE 50M,
  GROUP 7 (
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log',
    '/oradata/logfile07.log'
  ) SIZE 100M
-- STANDBY LOGFILE
DATAFILE
  '/oradata/xuexi/system01.dbf',
  '/oradata/xuexi/undotbs01.dbf',
  '/oradata/xuexi/sysaux01.dbf',
  '/oradata/xuexi/users01.dbf',
  '/oradata/xuexi/XUEXI/datafile/o1_mf_tomf_8yqwrdoj_.dbf',
  '/oradata/xuexi/omf2.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp01.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp011.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo1.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo2.dbf'
CHARACTER SET AL32UTF8
;
-- 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 '/archive/1_1_822350387.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350760.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822330757.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350003.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822349246.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350252.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822374325.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822387818.dbf';
-- 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 TEMP1 ADD TEMPFILE '/oradata/xuexi/temp011.dbf'
     SIZE 19922944  REUSE AUTOEXTEND ON NEXT 8192  MAXSIZE 5120M;
-- 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 "XUEXI" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/oradata/xuexi/redo01.log'  SIZE 50M,
  GROUP 2 '/oradata/xuexi/redo02.log'  SIZE 50M,
  GROUP 3 '/oradata/xuexi/redo03.log'  SIZE 50M,
  GROUP 4 '/oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log'  SIZE 50M,
  GROUP 5 (
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log'
  ) SIZE 50M,
  GROUP 7 (
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log',
    '/oradata/logfile07.log'
  ) SIZE 100M
-- STANDBY LOGFILE
DATAFILE
  '/oradata/xuexi/system01.dbf',
  '/oradata/xuexi/undotbs01.dbf',
  '/oradata/xuexi/sysaux01.dbf',
  '/oradata/xuexi/users01.dbf',
  '/oradata/xuexi/XUEXI/datafile/o1_mf_tomf_8yqwrdoj_.dbf',
  '/oradata/xuexi/omf2.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp01.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp011.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo1.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo2.dbf'
CHARACTER SET AL32UTF8
;
-- 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 '/archive/1_1_822350387.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350760.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822330757.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350003.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822349246.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350252.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822374325.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822387818.dbf';
-- 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 TEMP1 ADD TEMPFILE '/oradata/xuexi/temp011.dbf'
     SIZE 19922944  REUSE AUTOEXTEND ON NEXT 8192  MAXSIZE 5120M;
-- End of tempfile additions.
--

上一篇:shell提取sql数据库文件里的单个表


下一篇:利用容器实现字符串的权值