1. 恢复步骤
1.模拟故障,fuser -m -k -i /oradata,umount -f /oradata,卸载磁盘
2.启动数据库报错,查看log日志,控制文件找不到,需要重建控制文件
3.新建一个数据库数据目录,不要和之前一样,防止冲突
4. alter system set control_files='/oracle/oradata/hfzcdb/control01.ctl,/oracle/oradata/hfzcdb/control02.ctl' scope=spfile;
5.重启数据库到nomount状态,
6.进入rman状态,恢复控制文件,restore controlfile from autobackup;
7.恢复控制文件,在rman里面启动数据库到mount状态
8.查看rman备份的情况,list backup;
9.在rman里面恢复数据文件,修改新的路径newname
10.完成后,restore database,再 recover database;
11.进入数据库启动数据库,alter database open resetlogs;报错没有redo日志
12.重建控制文件alter database backup controlfile to trace as '/backup/ctl.txt';修改redo日志路径
13.启动数据库alter database open resetlogs
14.重建临时文件alter tablespace temp add tempfile '/oracle/oradata/Hfzcdb/temp01.dbf' size 100M;不建的话,应用那边会报错。
2. 实操
模拟磁盘文件丢失
[root@hfzcdb91 ~]# umount -f /oradata
[root@hfzcdb91 ~]# ps -ef |grep ora_
[root@hfzcdb91 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 72G 5.1G 67G 8% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 29M 3.8G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/backupvg-backuplv 3.0T 6.6G 3.0T 1% /backup
/dev/mapper/archivevg-archivelv 489G 498M 488G 1% /archive
/dev/mapper/oraclevg-oraclelv 196G 7.4G 188G 4% /oracle
tmpfs 781M 0 781M 0% /run/user/0
[root@hfzcdb91 ~]# ps -ef |grep ora_
root 125792 124506 0 14:33 pts/2 00:00:00 grep --color=auto ora_
[root@hfzcdb91 ~]# ps -ef |grep oracle
root 91311 91214 0 12:27 pts/0 00:00:00 su - oracle
oracle 91313 91311 0 12:27 pts/0 00:00:00 -bash
oracle 109890 91313 0 13:09 pts/0 00:00:00 rlwrap sqlplus / as sysdba
oracle 109891 109890 0 13:09 pts/1 00:00:00 sqlplus as sysdba
root 125871 124506 0 14:33 pts/2 00:00:00 grep --color=auto oracle
[root@hfzcdb91 ~]# su - oracle
Last login: Sat Apr 1 14:30:39 CST 2023 on pts/2
[oracle@hfzcdb91:/home/oracle]$sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 1 14:33:52 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
HfeduSQL> startup
ORACLE instance started.
Total System Global Area 2466249672 bytes
Fixed Size 8899528 bytes
Variable Size 671088640 bytes
Database Buffers 1778384896 bytes
Redo Buffers 7876608 bytes
ORA-00205: error in identifying control file, check alert log for more info
启动数据库到 nomount 状态
HfeduSQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@hfzcdb91:/home/oracle]$mkdir /oracle/oradata/hfzcdb
mkdir: cannot create directory ‘/oracle/oradata/hfzcdb’: No such file or directory
[oracle@hfzcdb91:/home/oracle]$mkdir -p /oracle/oradata/hfzcdb
[oracle@hfzcdb91:/home/oracle]$sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 1 14:35:13 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
HfeduSQL> show parameter control
NAME TYPE VALUE
------------------------------------ --------------------------------- ----------------------- -------
control_file_record_keep_time integer 7
control_files string /oradata/hfzcdb/control 01.ctl,
/oradata/hfzcdb/contro l02.ctl
control_management_pack_access string DIAGNOSTIC+TUNING
HfeduSQL>
[1]+ Stopped rlwrap sqlplus / as sysdba
[oracle@hfzcdb91:/home/oracle]$sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 1 14:36:57 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
HfeduSQL> alter system set control_files='/oracle/oradata/hfzcdb/control01.ctl,/oracle/oradata /hfzcdb/control02.ctl' scope=spfile;
System altered.
HfeduSQL> startup nomount force;
ORACLE instance started.
Total System Global Area 2466249672 bytes
Fixed Size 8899528 bytes
Variable Size 671088640 bytes
Database Buffers 1778384896 bytes
Redo Buffers 7876608 bytes
使用 rman 恢复控制文件
HfeduSQL> show parameter control;
NAME TYPE VALUE
------------------------------------ --------------------------------- ----------------------- -------
control_file_record_keep_time integer 7
control_files string /oracle/oradata/hfzcdb/ control
01.ctl,/oracle/oradata/ hfzcdb/
control02.ctl
control_management_pack_access string DIAGNOSTIC+TUNING
HfeduSQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@hfzcdb91:/home/oracle]$rman target/
Recovery Manager: Release 19.0.0.0.0 - Production on Sat Apr 1 14:39:41 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: HFZCDB (not mounted)
RMAN> restore controlfile from autobackup;
Starting restore at 2023-04-01 14:40:08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=3394 device type=DISK
recovery area destination: /archive
database name (or database unique name) used for search: HFZCDB
channel ORA_DISK_1: AUTOBACKUP /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1133011228_l2hhrw f6_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /archive/HFZCDB/autobackup/2023_04_ 01/o1_mf_s_1133011228_l2hhrwf6_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/oracle/oradata/hfzcdb/control01.ctl,/oracle/oradata/hfzcdb/control02.ctl
Finished restore at 2023-04-01 14:40:10
RMAN> alter database mount
2> ;
released channel: ORA_DISK_1
Statement processed
修改控制文件中数据文件的目录
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
1 Full 1.22G DISK 00:00:19 2023-03-31 17:40:21
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: HfzcDB_FULLBAK01
Piece Name: /backup/full/Hfzcdb_fullbak01_1_1_1132940402
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ------------------- ----------- ------ ----
1 Full 1415590 2023-03-31 17:38:39 NO /oradata/hfzcdb/system01.dbf
2 Full 1415590 2023-03-31 17:38:39 NO /oradata/hfzcdb/sysaux01.dbf
3 Full 1415590 2023-03-31 17:38:39 NO /oradata/hfzcdb/undotbs01.dbf
4 Full 1415590 2023-03-31 17:38:39 NO /oradata/hfzcdb/users01.dbf
5 Full 1415590 2023-03-31 17:38:39 NO /oradata/hfzcdb/Hfedu01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
2 Full 42.95M DISK 00:00:01 2023-03-31 17:40:29
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: HfzcDB_FULLBAK01
Piece Name: /backup/full/Hfzcdb_ctl_2_1_1132940428
Control File Included: Ckp SCN: 1415590 Ckp time: 2023-03-31 17:38:39
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
3 598.00K DISK 00:00:00 2023-03-31 19:31:18
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: HfzcDB_FULLBAK02
Piece Name: /backup/full/Hfzcdb_arch02_5_1_1132947078
List of Archived Logs in backup set 3
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- ------------------- ---------- ---------
1 8 1626044 2023-03-31 19:19:26 1627272 2023-03-31 19:30:40
1 9 1627272 2023-03-31 19:30:40 1627275 2023-03-31 19:30:42
1 10 1627275 2023-03-31 19:30:42 1627278 2023-03-31 19:30:44
1 11 1627278 2023-03-31 19:30:44 1627282 2023-03-31 19:30:48
1 12 1627282 2023-03-31 19:30:48 1627285 2023-03-31 19:30:50
1 13 1627285 2023-03-31 19:30:50 1627307 2023-03-31 19:31:16
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
4 Full 1.13G DISK 00:00:10 2023-03-31 19:31:29
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: HfzcDB_FULLBAK02
Piece Name: /backup/full/Hfzcdb_fullbak02_6_1_1132947079
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ------------------- ----------- ------ ----
1 Full 1627326 2023-03-31 19:31:19 NO /oradata/hfzcdb/system01.dbf
2 Full 1627326 2023-03-31 19:31:19 NO /oradata/hfzcdb/sysaux01.dbf
3 Full 1627326 2023-03-31 19:31:19 NO /oradata/hfzcdb/undotbs01.dbf
4 Full 1627326 2023-03-31 19:31:19 NO /oradata/hfzcdb/users01.dbf
5 Full 1627326 2023-03-31 19:31:19 NO /oradata/hfzcdb/Hfedu01.dbf
6 Full 1627326 2023-03-31 19:31:19 NO /oradata/hfzcdb/Hfedu02.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
5 Full 42.95M DISK 00:00:01 2023-03-31 19:31:36
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: HfzcDB_FULLBAK02
Piece Name: /backup/full/Hfzcdb_ctl02_7_1_1132947095
Control File Included: Ckp SCN: 1627331 Ckp time: 2023-03-31 19:31:35
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
6 3.50K DISK 00:00:00 2023-03-31 19:31:37
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: HfzcDB_FULLBAK02
Piece Name: /backup/full/Hfzcdb_arch02_8_1_1132947097
List of Archived Logs in backup set 6
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- ------------------- ---------- ---------
1 14 1627307 2023-03-31 19:31:16 1627338 2023-03-31 19:31:37
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
7 Full 42.98M DISK 00:00:01 2023-03-31 19:31:39
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20230331T193138
Piece Name: /archive/HFZCDB/autobackup/2023_03_31/o1_mf_s_1132947098_l2fk4vcx_.bkp
SPFILE Included: Modification time: 2023-03-31 19:29:23
SPFILE db_unique_name: HFZCDB
Control File Included: Ckp SCN: 1627367 Ckp time: 2023-03-31 19:31:38
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
8 Full 42.98M DISK 00:00:00 2023-03-31 20:00:27
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20230331T200027
Piece Name: /archive/HFZCDB/autobackup/2023_03_31/o1_mf_s_1132948827_l2fltvl0_.bkp
SPFILE Included: Modification time: 2023-03-31 19:59:24
SPFILE db_unique_name: HFZCDB
Control File Included: Ckp SCN: 1628234 Ckp time: 2023-03-31 20:00:27
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
9 Full 1.15G DISK 00:00:11 2023-04-01 10:00:50
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: Hfedu3FULL
Piece Name: /backup/full/Hfedu3_full_Hfzcdb_12_1_1132999239
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ------------------- ----------- ------ ----
1 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/system01.dbf
2 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/sysaux01.dbf
3 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/undotbs01.dbf
4 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/users01.dbf
5 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/Hfedu01.dbf
6 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/Hfedu02.dbf
7 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/Hfedu001.dbf
8 Full 1687040 2023-04-01 10:00:39 NO /oradata/hfzcdb/Hfedu002.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
10 Full 42.98M DISK 00:00:01 2023-04-01 10:00:57
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20230401T100056
Piece Name: /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1132999256_l2h42sgy_.bkp
SPFILE Included: Modification time: 2023-03-31 22:00:09
SPFILE db_unique_name: HFZCDB
Control File Included: Ckp SCN: 1687127 Ckp time: 2023-04-01 10:00:56
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
11 Full 42.98M DISK 00:00:00 2023-04-01 10:12:51
BP Key: 11 Status: AVAILABLE Compressed: NO Tag: TAG20230401T101251
Piece Name: /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1132999971_l2h4s3b1_.bkp
SPFILE Included: Modification time: 2023-04-01 10:04:24
SPFILE db_unique_name: HFZCDB
Control File Included: Ckp SCN: 1788325 Ckp time: 2023-04-01 10:12:51
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
12 Full 42.98M DISK 00:00:01 2023-04-01 11:54:33
BP Key: 12 Status: AVAILABLE Compressed: NO Tag: TAG20230401T115432
Piece Name: /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1133006072_l2hbqs3y_.bkp
SPFILE Included: Modification time: 2023-04-01 11:42:22
SPFILE db_unique_name: HFZCDB
Control File Included: Ckp SCN: 2296514 Ckp time: 2023-04-01 11:54:32
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
13 Full 96.00K DISK 00:00:00 2023-04-01 12:06:23
BP Key: 13 Status: AVAILABLE Compressed: NO Tag: Hfedu7PFILE
Piece Name: /backup/full/Hfedu7_pfile_Hfzcdb_20_1_1133006783
SPFILE Included: Modification time: 2023-04-01 11:54:40
SPFILE db_unique_name: HFZCDB
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
14 Full 42.98M DISK 00:00:00 2023-04-01 12:06:24
BP Key: 14 Status: AVAILABLE Compressed: NO Tag: TAG20230401T120624
Piece Name: /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1133006784_l2hcg0sm_.bkp
SPFILE Included: Modification time: 2023-04-01 11:54:40
SPFILE db_unique_name: HFZCDB
Control File Included: Ckp SCN: 2297824 Ckp time: 2023-04-01 12:06:24
run
{
set newname for datafile '/oradata/hfzcdb/system01.dbf' to '/oracle/oradata/hfzcdb/system01.db f';
set newname for datafile '/oradata/hfzcdb/sysaux01.dbf' to '/oracle/oradata/hfzcdb/sysaux01.db f';
set newname for datafile '/oradata/hfzcdb/undotbs01.dbf' to '/oracle/oradata/hfzcdb/undotbs01. dbf';
set newname for datafile '/oradata/hfzcdb/users01.dbf' to '/oracle/oradata/hfzcdb/users01.dbf' ;
set newname for datafile '/oradata/hfzcdb/Hfedu01.dbf' to '/oracle/oradata/hfzcdb/Hfedu01.dbf' ;
set newname for datafile '/oradata/hfzcdb/Hfedu02.dbf' to '/oracle/oradata/hfzcdb/Hfedu02.dbf' ;
set newname for datafile '/oradata/hfzcdb/Hfedu001.dbf' to '/oracle/oradata/hfzcdb/Hfedu001.db f';
set newname for datafile '/oradata/hfzcdb/Hfedu002.dbf' to '/oracle/oradata/hfzcdb/Hfedu002.db f';
restore database;
switch datafile all;
13> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 2023-04-01 14:44:51
Starting implicit crosscheck backup at 2023-04-01 14:44:51
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2 device type=DISK
Crosschecked 14 objects
Finished implicit crosscheck backup at 2023-04-01 14:44:52
Starting implicit crosscheck copy at 2023-04-01 14:44:52
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2023-04-01 14:44:52
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_l2hhskl0_.arc
File Name: /archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_2_l2hhsrhw_.arc
File Name: /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1133002247_l2h707gc_.bkp
File Name: /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1133004761_l2h9gt3q_.bkp
File Name: /archive/HFZCDB/autobackup/2023_04_01/o1_mf_s_1133011228_l2hhrwf6_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /oracle/oradata/hfzcdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oracle/oradata/hfzcdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oracle/oradata/hfzcdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oracle/oradata/hfzcdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /oracle/oradata/hfzcdb/Hfedu01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /oracle/oradata/hfzcdb/Hfedu02.dbf
channel ORA_DISK_1: restoring datafile 00007 to /oracle/oradata/hfzcdb/Hfedu001.dbf
channel ORA_DISK_1: restoring datafile 00008 to /oracle/oradata/hfzcdb/Hfedu002.dbf
channel ORA_DISK_1: reading from backup piece /backup/full/Hfedu3_full_Hfzcdb_12_1_1132999239
channel ORA_DISK_1: piece handle=/backup/full/Hfedu3_full_Hfzcdb_12_1_1132999239 tag=Hfedu3FUL L
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 2023-04-01 14:45:08
datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=13 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/Hfedu01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=14 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/Hfedu02.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=15 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/Hfedu001.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=16 STAMP=1133016308 file name=/oracle/oradata/hfzcdb/Hfedu002.dbf
RMAN>
恢复数据
RMAN> recover database;
Starting recover at 2023-04-01 14:45:32
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 4 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_4_l2h48tov_.arc
archived log for thread 1 with sequence 5 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_5_l2h5g0fw_.arc
archived log for thread 1 with sequence 6 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_6_l2h9glgd_.arc
archived log for thread 1 with sequence 7 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_7_l2h9gldl_.arc
archived log for thread 1 with sequence 8 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_8_l2h9glfq_.arc
archived log for thread 1 with sequence 1 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_1_l2hbqm2h_.arc
archived log for thread 1 with sequence 2 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_2_l2hfodsf_.arc
archived log for thread 1 with sequence 3 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_3_l2hfohr8_.arc
archived log for thread 1 with sequence 4 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_4_l2hfohs9_.arc
archived log for thread 1 with sequence 5 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_5_l2hfomkd_.arc
archived log for thread 1 with sequence 6 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_6_l2hfoxw3_.arc
archived log for thread 1 with sequence 7 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_7_l2hgmxog_.arc
archived log for thread 1 with sequence 8 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_8_l2hgmzrr_.arc
archived log for thread 1 with sequence 9 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_9_l2hgn1s1_.arc
archived log for thread 1 with sequence 10 is already on disk as file /archive/HFZCDB/archivel og/2023_04_01/o1_mf_1_10_l2hgn757_.arc
archived log for thread 1 with sequence 1 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_1_l2hhskl0_.arc
archived log for thread 1 with sequence 2 is already on disk as file /archive/HFZCDB/archivelo g/2023_04_01/o1_mf_1_2_l2hhsrhw_.arc
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_4_l2h48tov_.arc thread=1 sequence=4
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_5_l2h5g0fw_.arc thread=1 sequence=5
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_6_l2h9glgd_.arc thread=1 sequence=6
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_7_l2h9gldl_.arc thread=1 sequence=7
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_8_l2h9glfq_.arc thread=1 sequence=8
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_l2hbqm2h_.arc thread=1 sequence=1
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_l2hfocpx_.arc thread=1 sequence=1
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_2_l2hfodsf_.arc thread=1 sequence=2
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_3_l2hfohr8_.arc thread=1 sequence=3
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_4_l2hfohs9_.arc thread=1 sequence=4
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_5_l2hfomkd_.arc thread=1 sequence=5
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_6_l2hfoxw3_.arc thread=1 sequence=6
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_7_l2hgmxog_.arc thread=1 sequence=7
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_8_l2hgmzrr_.arc thread=1 sequence=8
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_9_l2hgn1s1_.arc thread=1 sequence=9
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_10_l2hgn757_.arc thread=1 sequence=10
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_l2hhskl0_.arc thread=1 sequence=1
archived log file name=/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_2_l2hhsrhw_.arc thread=1 sequence=2
unable to find archived log
archived log thread=1 sequence=3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/01/2023 14:45:38
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 3 and st arting SCN of 2302392
RMAN> exit
Recovery Manager complete.
重建控制文件
[oracle@hfzcdb91:/home/oracle]$sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 1 14:46:22 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
HfeduSQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00344: unable to re-create online log '/oradata/hfzcdb/redo01.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
HfeduSQL> select open_mode v$database;
select open_mode v$database
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
HfeduSQL> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
HfeduSQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_C HANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME CON_ID
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------- ------ ------------------- ------------ ------------------- ----------
1 1 0 209715200 512 1 NO CLEARING_CURRENT 2 301452 2023-04-01 13:20:23 1.8447E+19 0
3 1 0 209715200 512 1 YES CLEARING 0 0 0
2 1 0 209715200 512 1 YES CLEARING 0 0 0
HfeduSQL>
HfeduSQL>
HfeduSQL>
HfeduSQL> alter database backup controlfile to trace as 'backup/ctl.txt';
alter database backup controlfile to trace as 'backup/ctl.txt'
*
ERROR at line 1:
ORA-01278: error creating file '/oracle/app/oracle/product/19c/db_1/dbs/backup/ctl.txt'
ORA-27300: OS system dependent operation:open failed failed with status: 2
ORA-27301: OS failure message: No such file or directory
ORA-27302: failure occurred at: SlfFopen1
HfeduSQL> alter database backup controlfile to trace as '/backup/ctl.txt';
Database altered.
HfeduSQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@hfzcdb91:/home/oracle]$more /backup/ctl.txt
-- 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="hfzcdb"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=4
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
-- LOG_ARCHIVE_DEST_1='MANDATORY REOPEN=300 NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='NOREGISTER'
-- LOG_ARCHIVE_DEST_1='NOALTERNATE'
-- LOG_ARCHIVE_DEST_1='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.
-- WARNING! The current control file needs to be checked against
-- the datafiles to insure it contains the correct files. The
-- commands printed here may be missing log and/or data files.
-- Another report should be made after the database has been
-- successfully opened.
-- 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 "HFZCDB" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 8192
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/hfzcdb/redo01.log' SIZE 200M BLOCKSIZE 512,
GROUP 2 '/oradata/hfzcdb/redo02.log' SIZE 200M BLOCKSIZE 512,
GROUP 3 '/oradata/hfzcdb/redo03.log' SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/oracle/oradata/hfzcdb/system01.dbf',
'/oracle/oradata/hfzcdb/sysaux01.dbf',
'/oracle/oradata/hfzcdb/undotbs01.dbf',
'/oracle/oradata/hfzcdb/users01.dbf',
'/oracle/oradata/hfzcdb/Hfedu01.dbf',
'/oracle/oradata/hfzcdb/Hfedu02.dbf',
'/oracle/oradata/hfzcdb/Hfedu001.dbf',
'/oracle/oradata/hfzcdb/Hfedu002.dbf'
CHARACTER SET AL32UTF8
;
-- Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');
-- 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/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/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;
-- No tempfile entries found to add.
--
-- 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.
-- WARNING! The current control file needs to be checked against
-- the datafiles to insure it contains the correct files. The
-- commands printed here may be missing log and/or data files.
-- Another report should be made after the database has been
-- successfully opened.
-- 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 "HFZCDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 8192
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/hfzcdb/redo01.log' SIZE 200M BLOCKSIZE 512,
GROUP 2 '/oradata/hfzcdb/redo02.log' SIZE 200M BLOCKSIZE 512,
GROUP 3 '/oradata/hfzcdb/redo03.log' SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/oracle/oradata/hfzcdb/system01.dbf',
'/oracle/oradata/hfzcdb/sysaux01.dbf',
'/oracle/oradata/hfzcdb/undotbs01.dbf',
'/oracle/oradata/hfzcdb/users01.dbf',
'/oracle/oradata/hfzcdb/Hfedu01.dbf',
'/oracle/oradata/hfzcdb/Hfedu02.dbf',
'/oracle/oradata/hfzcdb/Hfedu001.dbf',
'/oracle/oradata/hfzcdb/Hfedu002.dbf'
CHARACTER SET AL32UTF8
;
-- Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');
-- 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/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/archive/HFZCDB/archivelog/2023_04_01/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;
-- No tempfile entries found to add.
--
[oracle@hfzcdb91:/home/oracle]$
[oracle@hfzcdb91:/home/oracle]$
[oracle@hfzcdb91:/home/oracle]$
[oracle@hfzcdb91:/home/oracle]$
[oracle@hfzcdb91:/home/oracle]$
[oracle@hfzcdb91:/home/oracle]$sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 1 14:52:50 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
HfeduSQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "HFZCDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 8192
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oracle/oradata/hfzcdb/redo01.log' SIZE 200M BLOCKSIZE 512,
GROUP 2 '/oracle/oradata/hfzcdb/redo02.log' SIZE 200M BLOCKSIZE 512,
GROUP 3 '/oracle/oradata/hfzcdb/redo03.log' SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/oracle/oradata/hfzcdb/system01.dbf',
'/oracle/oradata/hfzcdb/sysaux01.dbf',
'/oracle/oradata/hfzcdb/undotbs01.dbf',
'/oracle/oradata/hfzcdb/users01.dbf',
'/oracle/oradata/hfzcdb/Hfedu01.dbf',
'/oracle/oradata/hfzcdb/Hfedu02.dbf',
'/oracle/oradata/hfzcdb/Hfedu001.dbf',
'/oracle/oradata/hfzcdb/Hfedu002.dbf'
CHARACTER SET AL32UTF8
;
ORACLE instance started.
Total System Global Area 2466249672 bytes
Fixed Size 8899528 bytes
Variable Size 671088640 bytes
Database Buffers 1778384896 bytes
Redo Buffers 7876608 bytes
HfeduSQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Control file created.
HfeduSQL> HfeduSQL> select *from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_C HANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME CON_ID
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------- ------ ------------------- ------------ ------------------- ----------
1 1 0 209715200 512 1 YES UNUSED 0 0 0
3 1 0 209715200 512 1 YES CURRENT 0 0 0
2 1 0 209715200 512 1 YES UNUSED 0 0 0
HfeduSQL> select *from v$logfile;
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ------------
IS_ CON_ID
--- ----------
3 STALE ONLINE
/oracle/oradata/hfzcdb/redo03.log
NO 0
2 STALE ONLINE
/oracle/oradata/hfzcdb/redo02.log
NO 0
1 STALE ONLINE
/oracle/oradata/hfzcdb/redo01.log
NO 0
使用resetlogs 启动数据库
HfeduSQL> alter database open resetlogs;
Database altered.
HfeduSQL> select *from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_C HANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME CON_ID
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------- ------ ------------------- ------------ ------------------- ----------
1 1 1 209715200 512 1 NO CURRENT 2 302393 2023-04-01 14:54:15 1.8447E+19 0
2 1 0 209715200 512 1 YES UNUSED 0 0 0
3 1 0 209715200 512 1 YES UNUSED 0 0 0
HfeduSQL> alter system switch logfile;
System altered.
HfeduSQL> /
System altered.
HfeduSQL> select *from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_C HANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME CON_ID
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------- ------ ------------------- ------------ ------------------- ----------
1 1 1 209715200 512 1 YES ACTIVE 2 302393 2023-04-01 14:54:15 2303420 2023-04-01 14:54:38 0
2 1 2 209715200 512 1 YES ACTIVE 2 303420 2023-04-01 14:54:38 2303428 2023-04-01 14:54:42 0
3 1 3 209715200 512 1 NO CURRENT 2 303428 2023-04-01 14:54:42 1.8447E+19 0
HfeduSQL> select * from dba_temp_files;
no rows selected
检查数据文件恢复情况
HfeduSQL> alter tablespace temp add tempfile '/oracle/oradata/Hfzcdb/temp01.dbf' size 100M;
alter tablespace temp add tempfile '/oracle/oradata/Hfzcdb/temp01.dbf' size 100M
*
ERROR at line 1:
ORA-01119: error in creating database file '/oracle/oradata/Hfzcdb/temp01.dbf'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
HfeduSQL> alter tablespace temp add tempfile '/oracle/oradata/hfzcdb/temp01.dbf' size 100M;
Tablespace altered.
HfeduSQL> select * from dba_temp_files;
FILE_NAME
---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ------------
FILE_ID TABLESPACE_NAME BYTES BLOCKS STATUS RELATIVE_FNO AUT MAX BYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS SHARED INST_ID
---------- ------------------------------ ---------- ---------- ------- ------------ --- ----- ----- ---------- ------------ ---------- ----------- ------------- ----------
/oracle/oradata/hfzcdb/temp01.dbf
1 TEMP 104857600 6400 ONLINE 1 NO 0 0 0 103809024 6336 SHARED
HfeduSQL> select * from Hfedu01.Hfedu01;
ID NAME
---------- ----------------------------------------
1 Hfedu01
2 Hfedu02
3 Hfedu03
4 Hfedu04
5 Hfedu05
HfeduSQL>