过程如下:
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
备份目标目录为/u01/backup/ORCLCDB。然后查看需要的空间为1.4G:
SQL> select sum(bytes) from dba_data_files;
SUM(BYTES)
----------
1415577600
别急,这只是CDB$ROOT的,还有ORCLPDB1的:
SQL> alter session set container=orclpdb1;
Session altered.
SQL> select sum(bytes) from dba_data_files;
SUM(BYTES)
----------
739246080
确认需备份的文件以及与tablespace的关联:
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/ORCLCDB/system01.dbf
/opt/oracle/oradata/ORCLCDB/sysaux01.dbf
/opt/oracle/oradata/ORCLCDB/undotbs01.dbf
/opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf
/opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf
/opt/oracle/oradata/ORCLCDB/users01.dbf
/opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
11 rows selected.
SQL> col file_name format a60
SQL> select tablespace_name, file_name from dba_data_files order by 1,2;
TABLESPACE_NAME FILE_NAME
------------------------------ ------------------------------------------------
SYSAUX /opt/oracle/oradata/ORCLCDB/sysaux01.dbf
SYSTEM /opt/oracle/oradata/ORCLCDB/system01.dbf
UNDOTBS1 /opt/oracle/oradata/ORCLCDB/undotbs01.dbf
USERS /opt/oracle/oradata/ORCLCDB/users01.dbf
SQL> alter session set container=orclpdb1;
Session altered.
SQL> set linesize 100
SQL> select tablespace_name, file_name from dba_data_files order by 1,2;
TABLESPACE_NAME FILE_NAME
------------------------------ --------------------------------------------------
SYSAUX /opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
SYSTEM /opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
UNDOTBS1 /opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
USERS /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
SQL> show con_name;
CON_NAME
------------------------------
CDB$ROOT
SQL> select thread#, max(sequence#) from v$log group by thread# order by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 5
由于CDB和PDB共享redo log,因此在cdb$root中执行就可以了。
到这里有一个疑问,就是是否需要为每一个PDB去设置备份模式。答案是不需要。我们后面可以看V$backup的输出。
SQL> alter database begin backup;
Database altered.
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME CON_ID
---------- ------------------ ---------- --------- ----------
1 ACTIVE 1585088 09-APR-19 1
3 ACTIVE 1585088 09-APR-19 1
4 ACTIVE 1585088 09-APR-19 1
5 NOT ACTIVE 0 2
6 NOT ACTIVE 0 2
7 ACTIVE 1585088 09-APR-19 1
8 NOT ACTIVE 0 2
9 ACTIVE 1585088 09-APR-19 3
10 ACTIVE 1585088 09-APR-19 3
11 ACTIVE 1585088 09-APR-19 3
12 ACTIVE 1585088 09-APR-19 3
11 rows selected.
在以上输出中, status为Active表示已置于备份状态。其中CON_ID=1表示orclcdb,CON_ID=3表示orclpdb1。
SQL> select pdb_id, pdb_name from dba_pdbs;
3 ORCLPDB1
2 PDB$SEED
2 rows selected.
SQL> show con_name;
CDB$ROOT
SQL> show con_id;
1
con_id为1是cdb$root,2是pdb$seed,3是orclpdb1。
SQL> show con_id
CON_ID
------------------------------
1
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ WRITE NO
写入数据:
SQL> show con_name;
CDB$ROOT
SQL> create table cc(cc varchar2(20)) tablespace users;
Table created.
SQL> insert into cc values('DBWR does write');
1 row created.
SQL> alter system checkpoint;
System altered.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
验证更改已写入数据文件:
$ strings /opt/oracle/oradata/ORCLCDB/users01.dbf | grep "DBWR does write"
DBWR does write
包括cdb$root和orclpdb1:
[oracle@oracle-12201-vagrant ~]$ cp $ORACLE_BASE/oradata/ORCLCDB/*.dbf /u01/backup/ORCLCDB
[oracle@oracle-12201-vagrant ~]$ cp $ORACLE_BASE/oradata/ORCLCDB/ORCLPDB1/*.dbf /u01/backup/ORCLCDB/ORCLPDB1
cp: target ‘/u01/backup/ORCLCDB/ORCLPDB1’ is not a directory
[oracle@oracle-12201-vagrant ~]$ mkdir /u01/backup/ORCLCDB/ORCLPDB1
[oracle@oracle-12201-vagrant ~]$ cp $ORACLE_BASE/oradata/ORCLCDB/ORCLPDB1/*.dbf /u01/backup/ORCLCDB/ORCLPDB1
[oracle@oracle-12201-vagrant ~]$ du -sh /u01/backup/ORCLCDB
2.1G /u01/backup/ORCLCDB
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter database end backup;
Database altered.
SQL> alter session set nls_date_format = 'DD-MON-RRRR HH24:MI:SS';
Session altered.
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME CON_ID
---------- ------------------ ---------- -------------------- ----------
1 NOT ACTIVE 1600206 22-APR-2019 18:04:46 1
3 NOT ACTIVE 1600206 22-APR-2019 18:04:46 1
4 NOT ACTIVE 1600206 22-APR-2019 18:04:46 1
5 NOT ACTIVE 0 2
6 NOT ACTIVE 0 2
7 NOT ACTIVE 1600206 22-APR-2019 18:04:46 1
8 NOT ACTIVE 0 2
9 NOT ACTIVE 1600206 22-APR-2019 18:04:46 3
10 NOT ACTIVE 1600206 22-APR-2019 18:04:46 3
11 NOT ACTIVE 1600206 22-APR-2019 18:04:46 3
12 NOT ACTIVE 1600206 22-APR-2019 18:04:46 3
11 rows selected.
[oracle@oracle-12201-vagrant ~]$ tree /u01/fra
/u01/fra
└── ORCLCDB
└── archivelog
├── 2019_04_08
│ ├── control.sql
│ ├── o1_mf_1_1_gbps0c30_.arc
│ ├── o1_mf_1_2_gbps0c3y_.arc
│ └── o1_mf_1_3_gbps2ps1_.arc
└── 2019_04_09
4 directories, 4 files
SQL> alter system archive log current;
System altered.
[oracle@oracle-12201-vagrant ~]$ tree /u01/fra
/u01/fra
└── ORCLCDB
└── archivelog
├── 2019_04_08
│ ├── control.sql
│ ├── o1_mf_1_1_gbps0c30_.arc
│ ├── o1_mf_1_2_gbps0c3y_.arc
│ └── o1_mf_1_3_gbps2ps1_.arc
├── 2019_04_09
│ └── o1_mf_1_4_gbrtc78t_.arc
└── 2019_04_22
└── o1_mf_1_5_gcv4t94v_.arc
5 directories, 6 files
归档文件名的格式说明用了OMF。
看一下归档的文件格式:
SQL> show parameter log_archive_format
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_format string %t_%s_%r.dbf
记录序列号:
SQL> select thread#, max(sequence#) from v$log group by thread# order by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 6
SQL> alter database backup controlfile to '/u01/backup/ORCLCDB/controlbk.ctl' reuse;
Database altered.
SQL> !ls -l /u01/backup/ORCLCDB/controlbk.ctl
-rw-r-----. 1 oracle oinstall 19054592 Apr 9 17:48 /u01/backup/ORCLCDB/controlbk.ctl
以下是自己琢磨的,反正不多,就全备份了。
$ cp -r /u01/fra/ORCLCDB/archivelog/ /u01/backup/ORCLCDB/
$ du -sh /u01/backup/ORCLCDB/archivelog/
368M /u01/backup/ORCLCDB/archivelog/
或者也许备份以下文件就够了:
SQL> select name from V$ARCHIVED_LOG;
NAME
--------------------------------------------------------------------------------
/u01/fra/ORCLCDB/archivelog/2019_04_08/o1_mf_1_2_gbps0c3y_.arc
/u01/fra/ORCLCDB/archivelog/2019_04_08/o1_mf_1_1_gbps0c30_.arc
/u01/fra/ORCLCDB/archivelog/2019_04_08/o1_mf_1_3_gbps2ps1_.arc
/u01/fra/ORCLCDB/archivelog/2019_04_09/o1_mf_1_4_gbrtc78t_.arc
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_5_gcv4t94v_.arc
SQL> alter session set container=orclpdb1;
Session altered.
SQL> create table foo(foo number) tablespace users;
Table created.
SQL> insert into foo values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database
SQL> alter session set container=cdb$root;
Session altered.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> alter session set container=orclpdb1;
Session altered.
SQL> select file_name from dba_data_files where tablespace_name='USERS';
FILE_NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
在操作系统下,更名文件模拟错误:
$ mv /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf.old
关闭数据库,然后打开为mount状态:
SQL> shutdown immediate;
ORA-01116: error in opening database file 12
ORA-01110: data file 12: '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1207959552 bytes
Fixed Size 8792152 bytes
Variable Size 436209576 bytes
Database Buffers 754974720 bytes
Redo Buffers 7983104 bytes
Database mounted.
从备份中恢复文件:
$ cp /u01/backup/ORCLCDB/ORCLPDB1/users01.dbf /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
记录SCN:
SQL> select checkpoint_change# from v$datafile where file#=4;
CHECKPOINT_CHANGE#
------------------
1602881
检查数据文件中记录的SCN:
select file#, fuzzy, checkpoint_change#
from v$datafile_header
3 where file#=4;
FILE# FUZ CHECKPOINT_CHANGE#
---------- --- ------------------
4 YES 1602881
打开数据库:
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 12 needs media recovery
ORA-01110: data file 12: '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf'
恢复过程如下:
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED MOUNTED
3 ORCLPDB1 MOUNTED
SQL> alter session set container=orclpdb1;
Session altered.
SQL> recover tablespace users;
ORA-00279: change 1600206 generated at 04/22/2019 18:04:46 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_5_gcv4t94v_.arc
ORA-00280: change 1600206 for thread 1 is in sequence #5
Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 1601454 generated at 04/22/2019 18:11:21 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_6_gcv5d0m7_.arc
ORA-00280: change 1601454 for thread 1 is in sequence #6
ORA-00279: change 1602872 generated at 04/22/2019 18:20:48 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_7_gcv5d2vh_.arc
ORA-00280: change 1602872 for thread 1 is in sequence #7
Log applied.
Media recovery complete.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 ORCLPDB1 MOUNTED
SQL> alter database open
2 ;
alter database open
*
ERROR at line 1:
ORA-65054: Cannot open a pluggable database in the desired mode.
SQL> alter session set container=cdb$root;
Session altered.
SQL> alter database open;
Database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ WRITE NO
SQL> select NAME, DECODE(CDB, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option ?" , OPEN_MODE, CON_ID from V$DATABASE;
NAME Multitenant Option ? OPEN_MODE CON_ID
--------- -------------------------- -------------------- ----------
ORCLCDB Multitenant Option enabled READ WRITE 0
验证数据已恢复:
SQL> alter session set container=orclpdb1;
Session altered.
SQL> select * from foo;
FOO
----------
1
首先模拟错误:
mv /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf.old
插入数据:
SQL> alter session set container=orclpdb1;
Session altered.
SQL> insert into foo values(2);
insert into foo values(2)
*
ERROR at line 1:
ORA-01116: error in opening database file 12
ORA-01110: data file 12: '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
将数据文件置于离线:
SQL> alter database datafile '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf' offline;
Database altered.
SQL> show con_name;
CON_NAME
------------------------------
ORCLPDB1
SQL>
从备份中恢复数据文件:
$ cp /u01/backup/ORCLCDB/ORCLPDB1/users01.dbf /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
恢复数据文件:
SQL> recover datafile '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf';
ORA-00279: change 1600206 generated at 04/22/2019 18:04:46 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_5_gcv4t94v_.arc
ORA-00280: change 1600206 for thread 1 is in sequence #5
Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 1601454 generated at 04/22/2019 18:11:21 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_6_gcv5d0m7_.arc
ORA-00280: change 1601454 for thread 1 is in sequence #6
ORA-00279: change 1602872 generated at 04/22/2019 18:20:48 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_7_gcv5d2vh_.arc
ORA-00280: change 1602872 for thread 1 is in sequence #7
ORA-00279: change 1602875 generated at 04/22/2019 18:20:50 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_8_gcv5d504_.arc
ORA-00280: change 1602875 for thread 1 is in sequence #8
ORA-00279: change 1602878 generated at 04/22/2019 18:20:52 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_9_gcv5d639_.arc
ORA-00280: change 1602878 for thread 1 is in sequence #9
Log applied.
Media recovery complete.
将数据文件置于在线:
SQL> alter database datafile '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf' online;
Database altered.
SQL> select * from foo;
FOO
----------
1
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /opt/oracle/oradata/ORCLCDB/co
ntrol01.ctl, /opt/oracle/orada
ta/ORCLCDB/control02.ctl
模拟控制文件1损坏:
$ > /opt/oracle/oradata/ORCLCDB/control01.ctl
恢复过程很简单,就是将未损坏的文件拷贝一份即可:
[oracle@oracle-12201-vagrant ~]$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Mon Apr 22 20:41:15 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
SQL> alter session set container=orclpdb1
2 ;
alter session set container=orclpdb1
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
SQL> startup
ORACLE instance started.
Total System Global Area 1207959552 bytes
Fixed Size 8792152 bytes
Variable Size 436209576 bytes
Database Buffers 754974720 bytes
Redo Buffers 7983104 bytes
ORA-00205: error in identifying control file, check alert log for more info
SQL> shutdown abort
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@oracle-12201-vagrant ~]$ cp /opt/oracle/oradata/ORCLCDB/control02.ctl /opt/oracle/oradata/ORCLCDB/control01.ctl
[oracle@oracle-12201-vagrant ~]$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Mon Apr 22 20:42:41 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1207959552 bytes
Fixed Size 8792152 bytes
Variable Size 436209576 bytes
Database Buffers 754974720 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ WRITE NO
首先模拟所有控制文件损坏:
> /opt/oracle/oradata/ORCLCDB/control01.ctl
> /opt/oracle/oradata/ORCLCDB/control02.ctl
查询数据报错:
SQL> select * from v$database;
select * from v$database
*
ERROR at line 1:
ORA-03135: connection lost contact
Process ID: 7571
Session ID: 17 Serial number: 63926
shutdown实例:
SQL> shutdown abort;
ORACLE instance shut down.
从备份恢复所有控制文件:
cp /u01/backup/ORCLCDB/controlbk.ctl /opt/oracle/oradata/ORCLCDB/control01.ctl
cp /u01/backup/ORCLCDB/controlbk.ctl /opt/oracle/oradata/ORCLCDB/control02.ctl
启动数据库到mount状态:
SQL> startup mount
ORACLE instance started.
Total System Global Area 1207959552 bytes
Fixed Size 8792152 bytes
Variable Size 436209576 bytes
Database Buffers 754974720 bytes
Redo Buffers 7983104 bytes
Database mounted.
然后恢复:
SQL> recover database using backup controlfile;
ORA-00279: change 1601481 generated at 04/22/2019 18:11:21 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_6_gcv5d0m7_.arc
ORA-27072: File I/O error
Linux-x86_64 Error: 25: Inappropriate ioctl for device
Additional information: 4
Additional information: 1
ORA-27048: skgfifi: file header information is invalid
Additional information: 2
ORA-27048: skgfifi: file header information is invalid
Additional information: 2
ORA-00280: change 1601481 for thread 1 is in sequence #6
Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 1602872 generated at 04/22/2019 18:20:48 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_7_gcv5d2vh_.arc
ORA-00280: change 1602872 for thread 1 is in sequence #7
ORA-00278: log file
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_6_gcv5d0m7_.arc' no longer
needed for this recovery
ORA-00279: change 1602875 generated at 04/22/2019 18:20:50 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_8_gcv5d504_.arc
ORA-00280: change 1602875 for thread 1 is in sequence #8
ORA-00278: log file
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_7_gcv5d2vh_.arc' no longer
needed for this recovery
ORA-00279: change 1602878 generated at 04/22/2019 18:20:52 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_9_gcv5d639_.arc
ORA-00280: change 1602878 for thread 1 is in sequence #9
ORA-00278: log file
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_8_gcv5d504_.arc' no longer
needed for this recovery
ORA-00279: change 1602881 generated at 04/22/2019 18:20:54 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_10_gcv5xbm0_.arc
ORA-00280: change 1602881 for thread 1 is in sequence #10
ORA-00278: log file
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_9_gcv5d639_.arc' no longer
needed for this recovery
ORA-00279: change 1802961 generated at 04/22/2019 18:30:02 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_11_gcvdtyp1_.arc
ORA-00280: change 1802961 for thread 1 is in sequence #11
ORA-00278: log file
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_10_gcv5xbm0_.arc' no longer
needed for this recovery
ORA-00279: change 1904184 generated at 04/22/2019 20:28:14 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_12_gcvfpcs0_.arc
ORA-00280: change 1904184 for thread 1 is in sequence #12
ORA-00278: log file
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_11_gcvdtyp1_.arc' no longer
needed for this recovery
ORA-00279: change 2005927 generated at 04/22/2019 20:42:51 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_13_%u_.arc
ORA-00280: change 2005927 for thread 1 is in sequence #13
ORA-00278: log file
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_12_gcvfpcs0_.arc' no longer
needed for this recovery
ORA-00308: cannot open archived log
'/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_13_%u_.arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
继续恢复:
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/opt/oracle/oradata/ORCLCDB/system01.dbf'
查询redo log:
select a.sequence#, a.status, a.first_change#, b.member
from v$log a, v$logfile b
where a.group# = b.group#
4 order by a.sequence#;
SEQUENCE# STATUS FIRST_CHANGE#
---------- ---------------- -------------
MEMBER
--------------------------------------------------------------------------------
4 INACTIVE 1576056
/opt/oracle/oradata/ORCLCDB/redo01.log
5 ACTIVE 1586001
/opt/oracle/oradata/ORCLCDB/redo02.log
6 CURRENT 1601454
/opt/oracle/oradata/ORCLCDB/redo03.log
然后尝试用online redo log 恢复,需要逐个尝试:
SQL> recover database using backup controlfile;
ORA-00279: change 2005927 generated at 04/22/2019 20:42:51 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_13_%u_.arc
ORA-00280: change 2005927 for thread 1 is in sequence #13
Specify log: {=suggested | filename | AUTO | CANCEL}
/opt/oracle/oradata/ORCLCDB/redo03.log
ORA-00310: archived log contains sequence 12; sequence 13 required
ORA-00334: archived log: '/opt/oracle/oradata/ORCLCDB/redo03.log'
SQL> recover database using backup controlfile;
ORA-00279: change 2005927 generated at 04/22/2019 20:42:51 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_13_%u_.arc
ORA-00280: change 2005927 for thread 1 is in sequence #13
Specify log: {=suggested | filename | AUTO | CANCEL}
/opt/oracle/oradata/ORCLCDB/redo02.log
ORA-00310: archived log contains sequence 11; sequence 13 required
ORA-00334: archived log: '/opt/oracle/oradata/ORCLCDB/redo02.log'
SQL> recover database using backup controlfile;
ORA-00279: change 2005927 generated at 04/22/2019 20:42:51 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_13_%u_.arc
ORA-00280: change 2005927 for thread 1 is in sequence #13
Specify log: {=suggested | filename | AUTO | CANCEL}
/opt/oracle/oradata/ORCLCDB/redo01.log
Log applied.
Media recovery complete.
最后打开数据库,这一步时间较长,大概几十秒:
SQL> alter database open resetlogs;
Database altered.
恢复成功:
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ WRITE NO
首先插入一些数据:
SQL> alter session set container=orclpdb1;
Session altered.
SQL> select * from foo;
FOO
----------
1
SQL> insert into foo values(2);
1 row created.
SQL> commit;
Commit complete.
SQL> alter session set nls_date_format = 'DD-MON-RRRR HH24:MI:SS';
Session altered.
SQL> select sysdate from dual;
SYSDATE
--------------------
22-APR-2019 21:13:51
SQL> select to_char(sysdate, 'dd-mon-rrrr hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'DD-MON-RRRRH
-----------------------------
25-apr-2019 15:28:21
关闭数据库:
SQL> shutdown abort;
ORACLE instance shut down.
从备份中恢复数据(此处仅恢复orclpdb1):
$ cp /u01/backup/ORCLCDB/ORCLPDB1/*.dbf /opt/oracle/oradata/ORCLCDB/ORCLPDB1
启动数据库并恢复:
SQL> recover database until cancel;
ORA-00279: change 1600206 generated at 04/22/2019 18:04:46 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_5_gcv4t94v_.arc
ORA-00280: change 1600206 for thread 1 is in sequence #5
Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '/opt/oracle/oradata/ORCLCDB/system01.dbf'
ORA-01112: media recovery not started
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '/opt/oracle/oradata/ORCLCDB/system01.dbf'
SQL> shutdown abort
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@oracle-12201-vagrant ~]$ cp /u01/backup/ORCLCDB/system01.dbf /opt/oracle/oradata/ORCLCDB/system01.dbf
[oracle@oracle-12201-vagrant ~]$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Mon Apr 22 21:22:33 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1207959552 bytes
Fixed Size 8792152 bytes
Variable Size 436209576 bytes
Database Buffers 754974720 bytes
Redo Buffers 7983104 bytes
Database mounted.
SQL> recover database until cancel;
ORA-00279: change 1600206 generated at 04/22/2019 18:04:46 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_5_gcv4t94v_.arc
ORA-00280: change 1600206 for thread 1 is in sequence #5
Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/opt/oracle/oradata/ORCLCDB/system01.dbf'
ORA-01112: media recovery not started
SQL> recover /opt/oracle/oradata/ORCLCDB/system01.dbf;
ORA-00905: missing keyword
SQL> recover data file 1;
ORA-00905: missing keyword
SQL> recover database;
ORA-00279: change 1600206 generated at 04/22/2019 18:04:46 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_5_gcv4t94v_.arc
ORA-00280: change 1600206 for thread 1 is in sequence #5
Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> recover database;
ORA-00279: change 1600206 generated at 04/22/2019 18:04:46 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_5_gcv4t94v_.arc
ORA-00280: change 1600206 for thread 1 is in sequence #5
Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 1601454 generated at 04/22/2019 18:11:21 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_6_gcv5d0m7_.arc
ORA-00280: change 1601454 for thread 1 is in sequence #6
ORA-00279: change 1602872 generated at 04/22/2019 18:20:48 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_7_gcv5d2vh_.arc
ORA-00280: change 1602872 for thread 1 is in sequence #7
ORA-00279: change 1602875 generated at 04/22/2019 18:20:50 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_8_gcv5d504_.arc
ORA-00280: change 1602875 for thread 1 is in sequence #8
ORA-00279: change 1602878 generated at 04/22/2019 18:20:52 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_9_gcv5d639_.arc
ORA-00280: change 1602878 for thread 1 is in sequence #9
ORA-00279: change 1602881 generated at 04/22/2019 18:20:54 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_10_gcv5xbm0_.arc
ORA-00280: change 1602881 for thread 1 is in sequence #10
ORA-00279: change 1802961 generated at 04/22/2019 18:30:02 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_11_gcvgpr1s_.arc
ORA-00280: change 1802961 for thread 1 is in sequence #11
ORA-00279: change 1904184 generated at 04/22/2019 20:28:14 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_12_gcvgpr2n_.arc
ORA-00280: change 1904184 for thread 1 is in sequence #12
ORA-00279: change 2005927 generated at 04/22/2019 20:42:51 needed for thread 1
ORA-00289: suggestion :
/u01/fra/ORCLCDB/archivelog/2019_04_22/o1_mf_1_13_gcvgpr0g_.arc
ORA-00280: change 2005927 for thread 1 is in sequence #13
ORA-00283: recovery session canceled due to errors
ORA-00338: log 1 of thread 1 is more recent than control file
ORA-00312: online log 1 thread 1: '/opt/oracle/oradata/ORCLCDB/redo01.log'
ORA-01112: media recovery not started
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 3 needs more recovery to be consistent
ORA-01110: data file 3: '/opt/oracle/oradata/ORCLCDB/sysaux01.dbf'
SQL> recover datafile 3;
Media recovery complete.
实验没有成功,还得继续做。