目录
RMAN备份分为知识库(放在控制文件的,默認保留時間為7天)和备份集,知识库存放在控制文件,所以一般数据库控制文件的自动备份都是打开的。如果没有配置闪回区,默认是备份在$ORACLE_HOME/dbs ,如果配置了闪回区就自动备份在闪回区。
RMAN>LIST BACKUP;--------查看知识库的备份信息
RMAN>RESTORE CONTROFILE FROM AUTOBACKUP;-----恢复控制文件
如果没有控制文件的自动备份,而且丢失了所有对控制文件的备份,那么我们可以通过重建控制文件来恢复数据库。
1.将控制文件备份出来
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;-----将控制文件备份出来变成一个跟踪文件
Database altered.
[oracle@19c CDB]$ cd /u01/app/oracle/diag/rdbms/cdb/CDB/trace//在告警日志目录下
[oracle@19c trace]$ ls -lt| head -n 15 //这里面有很多文件需要一个个去找,哪一个是刚刚备份出来的控制文件,所以我们备份控制文件之后应该第一时间把这个文件保存下来,以免后面需要的时候找不到
total 24788
-rw-r----- 1 oracle oinstall 626371 Jan 2 19:26 alert_CDB.log
-rw-r----- 1 oracle oinstall 18849 Jan 2 19:26 CDB_ora_18162.trc
-rw-r----- 1 oracle oinstall 1087 Jan 2 19:26 CDB_ora_18162.trm
-rw-r----- 1 oracle oinstall 3345 Jan 2 19:26 CDB_m005_34241.trc
-rw-r----- 1 oracle oinstall 1012 Jan 2 19:26 CDB_m005_34241.trm
-rw-r----- 1 oracle oinstall 93855 Jan 2 19:26 CDB_m003_22842.trc
-rw-r----- 1 oracle oinstall 6180 Jan 2 19:26 CDB_m003_22842.trm
-rw-r----- 1 oracle oinstall 42988 Jan 2 19:26 CDB_m004_28432.trc
-rw-r----- 1 oracle oinstall 3467 Jan 2 19:26 CDB_m004_28432.trm
-rw-r----- 1 oracle oinstall 138990 Jan 2 19:26 CDB_mmon_18144.trc
-rw-r----- 1 oracle oinstall 7775 Jan 2 19:26 CDB_mmon_18144.trm
-rw-r----- 1 oracle oinstall 102349 Jan 2 19:26 CDB_m001_23385.trc
-rw-r----- 1 oracle oinstall 6341 Jan 2 19:26 CDB_m001_23385.trm
-rw-r----- 1 oracle oinstall 12288 Jan 2 19:23 CDB_dbrm_18112.trc
[oracle@19c trace]$ cat CDB_ora_18162.trc
Trace file /u01/app/oracle/diag/rdbms/cdb/CDB/trace/CDB_ora_18162.trc
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Build label: RDBMS_19.3.0.0.0DBRU_LINUX.X64_190417
ORACLE_HOME: /u01/app/oracle/product/19.2.0/db_home1
System name: Linux
Node name: 19c
Release: 3.10.0-1062.el7.x86_64
Version: #1 SMP Wed Aug 7 18:08:02 UTC 2019
Machine: x86_64
Instance name: CDB
Redo thread mounted by this instance: 1
Oracle process number: 33
Unix process pid: 18162, image: oracle@19c (TNS V1-V3)
*** 2024-01-02T19:26:42.486636+08:00 (CDB$ROOT(1))
-- 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="CDB"
--
-- 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 NOREOPEN 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.
-- 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 "CDB" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 (
'/u01/app/oracle/oradata/CDB/redo01.log',
'/u01/a