Sunday, March 15, 2015

SYSBACKUP role plus container-level (CDB) and local (PDB) users

First lets setup a CDB container=all user (i.e. from the root/cdb containter) with sysbackup privilege:


SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT


SQL> CREATE USER c##bkp_user IDENTIFIED BY qwe123 CONTAINER=ALL;
User created.


SQL> GRANT CONNECT, CREATE SESSION, SYSBACKUP TO c##bkp_user CONTAINER=ALL;
Grant succeeded.


and also another local sysbackup user for just at just the PDB3 Pluggable Database level (i.e. from the PDB3 container)


SQL> alter session set CONTAINER = PDB3;
Session altered.


SQL> show con_name
CON_NAME
------------------------------
PDB3


SQL> CREATE USER pdb3_bkp_user IDENTIFIED BY qwe123;
User created.


SQL> GRANT CREATE SESSION, SYSBACKUP TO pdb3_bkp_user;
Grant succeeded.

As we are not running in archivelog mode, I put the the databases in mount mode for backup:


SQL> SELECT name, open_mode FROM v$pdbs;
NAME       OPEN_MODE
------------------------------ ----------
PDB$SEED       READ ONLY
PDB1       READ WRITE
PDB2       MOUNTED
PDB3       MOUNTED


SQL> ALTER PLUGGABLE DATABASE pdb1 CLOSE IMMEDIATE;
Pluggable database altered.


SQL> ALTER DATABASE cdborcl CLOSE IMMEDIATE;
Database altered.


SQL> SELECT name, open_mode FROM v$pdbs;
NAME       OPEN_MODE
------------------------------ ----------
PDB$SEED       MOUNTED
PDB1       MOUNTED
PDB2       MOUNTED
PDB3       MOUNTED

Now backing up the CDB and the PDBs via the container level c##bkp_user


RMAN> connect target "c##bkp_user/qwe123 as sysbackup";


connected to target database: CDBORCL (DBID=2859091572, not open)


RMAN> backup database;


Starting backup at 14-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/oradata/cdborcl/sysaux01.dbf
input datafile file number=00001 name=/u01/oradata/cdborcl/system01.dbf
input datafile file number=00004 name=/u01/oradata/cdborcl/undotbs01.dbf
input datafile file number=00006 name=/u01/oradata/cdborcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 14-MAR-15
channel ORA_DISK_1: finished piece 1 at 14-MAR-15
piece handle=/u01/fast_recovery_area/CDBORCL/backupset/2015_03_14/o1_mf_nnndf_TAG20150314T200825_bj959syf_.bkp tag=TAG20150314T200825 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=/u01/oradata/cdborcl/pdb3/system01.dbf
input datafile file number=00015 name=/u01/oradata/cdborcl/pdb3/sysaux01.dbf
input datafile file number=00016 name=/u01/oradata/cdborcl/pdb3/users01.dbf
channel ORA_DISK_1: starting piece 1 at 14-MAR-15
channel ORA_DISK_1: finished piece 1 at 14-MAR-15
piece handle=/u01/fast_recovery_area/CDBORCL/113D000B83CC49F7E0530100007FA366/backupset/2015_03_14/o1_mf_nnndf_TAG20150314T200825_bj95bm30_.bkp tag=TAG20150314T200825 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/u01/oradata/cdborcl/pdb1/sysaux01.dbf
input datafile file number=00011 name=/u01/oradata/cdborcl/pdb1/example01.dbf
input datafile file number=00008 name=/u01/oradata/cdborcl/pdb1/system01.dbf
input datafile file number=00010 name=/u01/oradata/cdborcl/pdb1/SAMPLE_SCHEMA_users01.dbf
channel ORA_DISK_1: starting piece 1 at 14-MAR-15
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/14/2015 20:09:31
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 67108864 bytes disk space from 5033164800 limit
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/oradata/cdborcl/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/u01/oradata/cdborcl/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 14-MAR-15
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/14/2015 20:09:46
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 67108864 bytes disk space from 5033164800 limit
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00013 name=/u01/oradata/cdborcl/pdb2/sysaux01.dbf
input datafile file number=00012 name=/u01/oradata/cdborcl/pdb2/system01.dbf
channel ORA_DISK_1: starting piece 1 at 14-MAR-15
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/14/2015 20:10:01
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 67108864 bytes disk space from 5033164800 limit

This is a bit odd, as the backup size is about 2600M


[oracle@ora12c66 fast_recovery_area]$ du -hs *
18M cdborcl
2.6G CDBORCL
[oracle@ora12c66 fast_recovery_area]$ cd CDBORCL/
[oracle@ora12c66 CDBORCL]$ du -hs *
12K 11043883E1AC1CBAE0530100007F7552
12K 110457F368D61EC4E0530100007FAABF
12K 113065F11B2B3357E0530100007F557D
1.3G 113D000B83CC49F7E0530100007FA366
1.4G backupset
[oracle@ora12c66 CDBORCL]$

and the limit is 4800M:

SQL> show parameter recovery


NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest     string /u01/fast_recovery_area
db_recovery_file_dest_size     big integer 4800M

and we have a backup of pdb3 so let's try breaking it


[oracle@ora12c66 CDBORCL]$ rm /u01/oradata/cdborcl/pdb3/users01.dbf


So yes it now is broken:


SQL> ALTER PLUGGABLE DATABASE pdb3 open;
ALTER PLUGGABLE DATABASE pdb3 open
*
ERROR at line 1:
ORA-01113: file 16 needs media recovery
ORA-01110: data file 16: '/u01/oradata/cdborcl/pdb3/users01.dbf'


now as the PDB3 local sysbackup user:


RMAN> connect target "pdb3_bkp_user/qwe123 as sysbackup";


connected to target database: CDBORCL (DBID=2859091572)


RMAN> RESTORE PLUGGABLE DATABASE PDB3;


Starting restore at 14-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=56 device type=DISK


skipping datafile 14; already restored to file /u01/oradata/cdborcl/pdb3/system01.dbf
skipping datafile 15; already restored to file /u01/oradata/cdborcl/pdb3/sysaux01.dbf
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 00016 to /u01/oradata/cdborcl/pdb3/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/fast_recovery_area/CDBORCL/113D000B83CC49F7E0530100007FA366/backupset/2015_03_14/o1_mf_nnndf_TAG20150314T200825_bj95bm30_.bkp
channel ORA_DISK_1: piece handle=/u01/fast_recovery_area/CDBORCL/113D000B83CC49F7E0530100007FA366/backupset/2015_03_14/o1_mf_nnndf_TAG20150314T200825_bj95bm30_.bkp tag=TAG20150314T200825
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 14-MAR-15


RMAN> RECOVER PLUGGABLE DATABASE PDB3;


Starting recover at 14-MAR-15
using channel ORA_DISK_1


starting media recovery
media recovery complete, elapsed time: 00:00:00   << recovery still required for DB in noarchivelog mode (although very quick)


Finished recover at 14-MAR-15


RMAN>

No comments:

Post a Comment