Oracle rman backup and restore normal operation

1 file backup and recovery parameters

RMAN> backup spfile format '/tmp/bak/spfile_%U_%T.ora'

Close the database and delete the parameter files (ora files ... in the / dbs path)

RMAN> shutdown immediate;

rm $ORACLE_HOME/dbs/*.ora

Start the database error, restore configuration files

RMAN> startup nomount

RMAN> startup mount
database is already started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/15/2019 13:47:50
ORA-00205: error in identifying control file, check alert log for more info

RMAN> restore spfile from '/tmp/bak/spfile_08u45o34_1_1_20190615.ora';

Starting restore at 15-JUN-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=3 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /tmp/bak/spfile_08u45o34_1_1_20190615.ora
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 15-JUN-19

Restart the database successfully

RMAN> startup force

2 backup and recovery control file

RMAN> backup current controlfile format '/tmp/bak/control_%U_%T.ctl';

Close control database delete files

RMAN> select name from v$controlfile;
/fdisk1/data/ordata1400/ORCL1400/controlfile/o1_mf_gh6v41fk_.ctl
/fdisk1/data/fast_recovery/ORCL1400/controlfile/o1_mf_gh6v41gz_.ctl

[mingjie.gmj@ecs /tmp/bak]$ rm /fdisk1/data/ordata1400/ORCL1400/controlfile/o1_mf_gh6v41fk_.ctl
[mingjie.gmj@ecs /tmp/bak]$ rm /fdisk1/data/fast_recovery/ORCL1400/controlfile/o1_mf_gh6v41gz_.ctl

Restart the database error began to recover

RMAN> startup force;
Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/15/2019 14:00:36
ORA-00205: error in identifying control file, check alert log for more info

RMAN> restore controlfile from '/tmp/bak/control_09u45omg_1_1_20190615.ctl';

Starting restore at 15-JUN-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=122 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/fdisk1/data/ordata1400/ORCL1400/controlfile/o1_mf_gh6v41fk_.ctl
output file name=/fdisk1/data/fast_recovery/ORCL1400/controlfile/o1_mf_gh6v41gz_.ctl
Finished restore at 15-JUN-19

RMAN> startup mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open RESETLOGS;

Data backup and recovery 3 (fully restored)

日志都在

RMAN> backup database format '/tmp/bak/database_%U_%T.dbf';

Create a table in the test table space

RMAN> select name from v$datafile;

RMAN> create tablespace test_tbl datafile '/fdisk1/data/ordata1400/ORCL1400/datafile/test_tbl.dbf' size 10M;

RMAN> create table scott.t2(id number) tablespace test_tbl;

RMAN> insert into scott.t2 values (1);

RMAN> select file_name from dba_data_files where TABLESPACE_NAME='TEST_TBL';

/fdisk1/data/ordata1400/ORCL1400/datafile/test_tbl.dbf

Query log and the current log file sequence

SQL> alter system switch logfile;

SQL> archive log list;
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       /tmp/
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence	       2

Delete data files, start the database, using basic backup + log to restore data files

RMAN> startup force
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;

4 backup and recovery data (after dbca recover deleted)

Backup parameter files, control files, the whole library

RMAN> backup spfile format '/tmp/bak/spfile_%U_%T.ora';
RMAN> backup current controlfile format '/tmp/bak/control_%U_%T.ctl';
RMAN> backup database format '/tmp/bak/database_%U_%T.dbf';

DBCA delete instance (or to manually delete all files DATA below)

RMAN starts examples

mkdir $ORACLE_BASE/ORCL1400/adump
rlwrap rman target /

RMAN> startup

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/home/mingjie.gmj/databases/oracle1400/base/dbhome_1/dbs/initorcl1400.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/15/2019 14:47:07
ORA-00205: error in identifying control file, check alert log for more info

RMAN> restore spfile from '/tmp/bak/spfile_0du45qp9_1_1_20190615.ora';

RMAN> restore controlfile from '/tmp/bak/control_0eu45qq1_1_1_20190615.ctl';

RMAN> restore database;

RMAN> recover database;

RMAN> alter database open resetlogs;

ps. manually modify the spfile

-- 有静态lsnrctl的话删掉,缺什么目录看这个文件
strings spfileorcl1400.ora >1.ora
vi 1.ora
sqlplus / as sysdba
startup nomount pfile='?/dbs/1.ora'
create spfile from pfile='?/dbs/1.ora';

5 backup strategy

5.1 concept

RMAN backup points and all equipment by equipment, by Backup 0,1,2 grade.

Differences incremental backup (Differential Incremental Backup) mode (default):
the LV0: all equipment.
LV1: changes in the last LV0 or LV1 so far.
LV2: changes in the last LV0 or LV1 or LV2 so far.
Advantages and disadvantages: faster, because only a small change in the storage block, but it takes longer to recover

Accumulated incremental backup (Cumulative Incremental Backup) mode:
the LV0: all equipment.
LV1: LV0 since last change (whether LV0 to this LV1 LV1 whether there are other backup).
LV2: Last LV0 LV1 or date changes (equivalent to dirfferential incremental backup of LV1).
Advantages and disadvantages: The main advantage is a shorter recovery time, the disadvantage is long backup times and large disk overhead

备份命令如下:
零级备份
backup incremental level 0 database;
一级差异增量
backup incremental level 1 database;
一级累计增量
backup incremental level 1 cumulative database;

5.2 Full backup script library

--校验日志的可用性
RMAN>crosscheck archivelog all;

--核对所有备份集
RMAN>crosscheck backup;

--删除保存策略过过期的,包括备份集和归档日志,有交互式操作。
RMAN>delete obsolete;

--删除保存策略过过期的,包括备份集和归档日志,无交互式操作。
RMAN>delete noprompt obsolete;

--删除7天前的归档日志备份
RMAN> delete archivelog all completed before 'sysdate-7';
Published 27 original articles · won praise 2 · views 50000 +

Guess you like

Origin blog.csdn.net/jackgo73/article/details/92084210