Rman备份路径级别

 format 指定目录> db_recovery_file_dest 闪回目录>默认目录

19c 版本

 

测试 归档模式下,不开启闪回,rman备份不用 format指定

 

则rman 备份路径在哪里??

1.

--闪回路径不开启,不设置db_recovery_file_dest  ,且归档日志路径也为                初始位置   /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch

 

 

SQL> select flashback_on from v$database;

FLASHBACK_ON

------------------

NO

 

SQL> show parameter db_recovery;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string

db_recovery_file_dest_size           big integer 0

 

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch

Oldest online log sequence     40

Next log sequence to archive   42

Current log sequence           42

 

--切换redo,归档日志保存位置

SQL> alter system switch logfile;

System altered.

--此目录下

/u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch

 

 

 

 

 

 

[oracle@test ~]$ rman target /

--默认参数

 

RMAN> show all;

 

RMAN configuration parameters for database with db_unique_name TEST1 are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP ON; # default

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default

CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/19.0.0/dbhome_1/dbs/snapcf_test1.f'; # default


开始备份整个数据库,不指定format参数。


RMAN>  backup database;


Starting backup at 2023-06-10 19:52:55

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=+DATA/TEST1/DATAFILE/tbs_test.266.1137658931

input datafile file number=00002 name=+DATA/TEST1/DATAFILE/sysaux.261.1137599239

input datafile file number=00001 name=+DATA/TEST1/DATAFILE/system.260.1137599233

input datafile file number=00003 name=+DATA/TEST1/DATAFILE/undotbs1.262.1137599243

input datafile file number=00004 name=+DATA/TEST1/DATAFILE/users.264.1137599255

channel ORA_DISK_1: starting piece 1 at 2023-06-10 19:52:55

channel ORA_DISK_1: finished piece 1 at 2023-06-10 19:53:31

piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/031uclsn_1_1 tag=TAG20230610T195255 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36

Finished backup at 2023-06-10 19:53:31

 

Starting Control File and SPFILE Autobackup at 2023-06-10 19:53:31

piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-1514641594-20230610-01 comment=NONE

Finished Control File and SPFILE Autobackup at 2023-06-10 19:53:32



发现数据文件、参数文件、控制文件均备份在$ORACLE_HOME/dbs/ 目录下


--备份归档日志

RMAN> backup archivelog all;

 

Starting backup at 2023-06-10 19:56:54

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=39 RECID=1 STAMP=1139168549

input archived log thread=1 sequence=40 RECID=2 STAMP=1139169276

input archived log thread=1 sequence=41 RECID=3 STAMP=1139169414

channel ORA_DISK_1: starting piece 1 at 2023-06-10 19:56:55

channel ORA_DISK_1: finished piece 1 at 2023-06-10 19:56:58

piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/051ucm47_1_1 tag=TAG20230610T195655 comment=NONE  --归档日志也备份在dbs下

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

 

不设置闪回路径及归档路径设置, archive log 默认归档日志为

Archive destination   /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch

 

当进行rman备份时,控制文件,参数文件,归档文件,数据文件均会存放在$ORACLE_HOME/dbs/ 目录下

 

 

2.

打开闪回并设置闪回路径,rman归档参数默认,归档路径默认。

 

开启闪回,设置闪回目录。

 

SQL> shut immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area 1157627168 bytes

Fixed Size                  8895776 bytes

Variable Size             335544320 bytes

Database Buffers          805306368 bytes

Redo Buffers                7880704 bytes

Database mounted.

SQL> show parameter recover;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string

db_recovery_file_dest_size           big integer 0

db_unrecoverable_scn_tracking        boolean     TRUE

recovery_parallelism                 integer     0

remote_recovery_file_dest            string

SQL> alter system set db_recovery_file_dest='/home/oracle/flashback';

alter system set db_recovery_file_dest='/home/oracle/flashback'

*

ERROR at line 1:

ORA-02097: parameter cannot be modified because specified value is invalid

ORA-19802: cannot use DB_RECOVERY_FILE_DEST without DB_RECOVERY_FILE_DEST_SIZE

--要先设置db_recovery_file_dest_size 闪回目录大小,再设置闪回目录

 

SQL> alter system set db_recovery_file_dest_size=200m scope=both;

System altered.

 

SQL> alter system set db_recovery_file_dest='/home/oracle/flashback';

System altered.

--开启闪回

SQL> alter database flashback on;

Database altered.

--打开数据库

SQL> alter database open;

 

SQL> show parameter recover;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string      /home/oracle/flashback

db_recovery_file_dest_size           big integer 200M

 

 

 

开始rman 备份

[oracle@test ~]$ rman target /

RMAN> backup database;

 

Starting backup at 2023-06-10 20:35:43

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=+DATA/TEST1/DATAFILE/tbs_test.266.1137658931

input datafile file number=00002 name=+DATA/TEST1/DATAFILE/sysaux.261.1137599239

input datafile file number=00001 name=+DATA/TEST1/DATAFILE/system.260.1137599233

input datafile file number=00003 name=+DATA/TEST1/DATAFILE/undotbs1.262.1137599243

input datafile file number=00004 name=+DATA/TEST1/DATAFILE/users.264.1137599255

channel ORA_DISK_1: starting piece 1 at 2023-06-10 20:35:44

channel ORA_DISK_1: finished piece 1 at 2023-06-10 20:36:29

piece handle=/home/oracle/flashback/TEST1/backupset/2023_06_10/o1_mf_nnndf_TAG20230610T203543_l88vk01w_.bkp tag=TAG20230610T203543 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

Finished backup at 2023-06-10 20:36:29

 

Starting Control File and SPFILE Autobackup at 2023-06-10 20:36:29

piece handle=/home/oracle/flashback/TEST1/autobackup/2023_06_10/o1_mf_s_1139171789_l88vlfms_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2023-06-10 20:36:30

 

RMAN>  backup archivelog all;

 

Starting backup at 2023-06-10 20:37:06

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=39 RECID=1 STAMP=1139168549

input archived log thread=1 sequence=40 RECID=2 STAMP=1139169276

input archived log thread=1 sequence=41 RECID=3 STAMP=1139169414

input archived log thread=1 sequence=42 RECID=4 STAMP=1139171826

channel ORA_DISK_1: starting piece 1 at 2023-06-10 20:37:07

channel ORA_DISK_1: finished piece 1 at 2023-06-10 20:37:10

piece handle=/home/oracle/flashback/TEST1/backupset/2023_06_10/o1_mf_annnn_TAG20230610T203706_l88vmm0f_.bkp tag=TAG20230610T203706 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 2023-06-10 20:37:10

 

Starting Control File and SPFILE Autobackup at 2023-06-10 20:37:10

piece handle=/home/oracle/flashback/TEST1/autobackup/2023_06_10/o1_mf_s_1139171830_l88vmpgc_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2023-06-10 20:37:11

 

 

当我们设置闪回目录时,rman进行备份,所有的归档日志,参数文件,数据文件,控制文件 都将自动备份在闪回区目录。

 

/home/oracle/flashback/实例名/

自动生成如下目录

[oracle@test TEST1]$ ll

total 0

drwxr-x--- 3 oracle asmadmin 24 Jun 10 20:37 archivelog

drwxr-x--- 3 oracle asmadmin 24 Jun 10 20:36 autobackup

drwxr-x--- 3 oracle asmadmin 24 Jun 10 20:34 backupset

drwxr-x--- 2 oracle asmadmin 33 Jun 10 20:32 flashback

归档日志目录此时也会变化

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     41

Next log sequence to archive   43

Current log sequence           43

SQL> alter system switch logfile;

手动归档的文件也会放在闪回目录自动创建的archivelog目录中。