2019年11月22日 星期五

Oracle DB - 設定 RMAN backup


--Oracle Catalog DB: DB11G@testdb88
--Create tablespace RMAN

CREATE TABLESPACE CATALOG_TBS DATAFILE 
  '/u01/app/oracle/oradata/DB11G/catalog_tbs01.dbf' SIZE 5M AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

--Create DB user: rman_ora11g
CREATE USER RMAN_ORA11G
  IDENTIFIED BY "1qaz2wsx"
  DEFAULT TABLESPACE CATALOG_TBS
  TEMPORARY TABLESPACE TEMP
  PROFILE DEFAULT
  ACCOUNT UNLOCK;
  -- 2 Roles for RMAN_ORA11G 
  GRANT CONNECT TO RMAN_ORA11G;
  GRANT RECOVERY_CATALOG_OWNER TO RMAN_ORA11G;
  ALTER USER RMAN_ORA11G DEFAULT ROLE ALL;
  -- 1 System Privilege for RMAN_ORA11G 
  GRANT UNLIMITED TABLESPACE TO RMAN_ORA11G;



--Create Catalog

[oracle@testdb1 admin]$ rman

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Nov 1 16:56:34 2019

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect catalog rman_ora11g/xxxxxxxx@DB11G

connected to recovery catalog database

RMAN> CREATE CATALOG TABLESPACE catalog_tbs;

recovery catalog created

RMAN>



--Register Database
[oracle@testdb1 admin]$ rman target / catalog rman_ora11g/xxxxxxxx@catalog

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Nov 1 17:10:25 2019

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PRD (DBID=2086780556)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> report schema;

Report of database schema for database with db_unique_name PRD

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    750      SYSTEM               YES     /u02/oradata/PRD/system01.dbf
2    540      SYSAUX               NO      /u02/oradata/PRD/sysaux01.dbf
3    105      UNDOTBS1             YES     /u02/oradata/PRD/undotbs01.dbf
4    5        USERS                NO      /u02/oradata/PRD/users01.dbf
5    313      EXAMPLE              NO      /u02/oradata/PRD/example01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    29       TEMP                 32767       /u02/oradata/PRD/temp01.dbf



RMAN> show all
2> ;

RMAN configuration parameters for database with db_unique_name PRD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # 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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PRD.f'; # default

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> show all
2> ;

RMAN configuration parameters for database with db_unique_name PRD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PRD.f'; # default


RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>

RUN

  ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/u03/backup/%d_Full_%Y%M%D_%u.bak';
  BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/u03/backup/%d_Control_%Y%M%D_%u.bak';
  BACKUP AS BACKUPSET DATABASE; 
  RELEASE CHANNEL disk1;


released channel: ORA_DISK_1
allocated channel: disk1
channel disk1: SID=372 device type=DISK

Starting backup at 04-NOV-19
channel disk1: starting datafile copy
copying current control file
output file name=/u03/backup/PRD_Control_20191104_0bug1589.bak tag=TAG20191104T111209 RECID=5 STAMP=1023448329
channel disk1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 04-NOV-19

Starting backup at 04-NOV-19
channel disk1: starting full datafile backup set
channel disk1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u02/oradata/PRD/system01.dbf
input datafile file number=00002 name=/u02/oradata/PRD/sysaux01.dbf
input datafile file number=00005 name=/u02/oradata/PRD/example01.dbf
input datafile file number=00003 name=/u02/oradata/PRD/undotbs01.dbf
input datafile file number=00004 name=/u02/oradata/PRD/users01.dbf
channel disk1: starting piece 1 at 04-NOV-19
channel disk1: finished piece 1 at 04-NOV-19
piece handle=/u03/backup/PRD_Full_20191104_0cug158b.bak tag=TAG20191104T111211 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:35
channel disk1: starting full datafile backup set
channel disk1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel disk1: starting piece 1 at 04-NOV-19
channel disk1: finished piece 1 at 04-NOV-19
piece handle=/u03/backup/PRD_Full_20191104_0dug159e.bak tag=TAG20191104T111211 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-NOV-19

released channel: disk1

RMAN> list backup
2> ;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
463     Full    1.16G      DISK        00:00:29     04-NOV-19
        BP Key: 467   Status: AVAILABLE  Compressed: NO  Tag: TAG20191104T105948
        Piece Name: /u03/backup/PRD_Full_20191104_09ug14h4.bak
  List of Datafiles in backup set 463
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1393036    04-NOV-19 /u02/oradata/PRD/system01.dbf
  2       Full 1393036    04-NOV-19 /u02/oradata/PRD/sysaux01.dbf
  3       Full 1393036    04-NOV-19 /u02/oradata/PRD/undotbs01.dbf
  4       Full 1393036    04-NOV-19 /u02/oradata/PRD/users01.dbf
  5       Full 1393036    04-NOV-19 /u02/oradata/PRD/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
464     Full    9.36M      DISK        00:00:01     04-NOV-19
        BP Key: 468   Status: AVAILABLE  Compressed: NO  Tag: TAG20191104T105948
        Piece Name: /u03/backup/PRD_Full_20191104_0aug14i7.bak
  SPFILE Included: Modification time: 03-NOV-19
  SPFILE db_unique_name: PRD
  Control File Included: Ckp SCN: 1393229      Ckp time: 04-NOV-19

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
593     Full    1.16G      DISK        00:00:30     04-NOV-19
        BP Key: 597   Status: AVAILABLE  Compressed: NO  Tag: TAG20191104T111211
        Piece Name: /u03/backup/PRD_Full_20191104_0cug158b.bak
  List of Datafiles in backup set 593
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1394382    04-NOV-19 /u02/oradata/PRD/system01.dbf
  2       Full 1394382    04-NOV-19 /u02/oradata/PRD/sysaux01.dbf
  3       Full 1394382    04-NOV-19 /u02/oradata/PRD/undotbs01.dbf
  4       Full 1394382    04-NOV-19 /u02/oradata/PRD/users01.dbf
  5       Full 1394382    04-NOV-19 /u02/oradata/PRD/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
594     Full    9.36M      DISK        00:00:01     04-NOV-19
        BP Key: 598   Status: AVAILABLE  Compressed: NO  Tag: TAG20191104T111211
        Piece Name: /u03/backup/PRD_Full_20191104_0dug159e.bak
  SPFILE Included: Modification time: 03-NOV-19
  SPFILE db_unique_name: PRD
  Control File Included: Ckp SCN: 1394398      Ckp time: 04-NOV-19

RMAN>

RMAN> report obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           463    04-NOV-19
  Backup Piece       467    04-NOV-19          /u03/backup/PRD_Full_20191104_09ug14h4.bak
Archive Log          547    04-NOV-19          /u01/app/oracle/fast_recovery_area/PRD/archivelog/2019_11_04/o1_mf_1_25_gvz5o5ko_.arc
Backup Set           464    04-NOV-19
  Backup Piece       468    04-NOV-19          /u03/backup/PRD_Full_20191104_0aug14i7.bak
Archive Log          548    04-NOV-19          /u01/app/oracle/fast_recovery_area/PRD/archivelog/2019_11_04/o1_mf_1_26_gvz5o6py_.arc
Archive Log          549    04-NOV-19          /u01/app/oracle/fast_recovery_area/PRD/archivelog/2019_11_04/o1_mf_1_27_gvz5o851_.arc
Control File Copy     576    04-NOV-19          /u03/backup/PRD_Control_20191104_0bug1589.bak


沒有留言:

張貼留言