Posted in 2016

Recovering a PDB

I have to continue my DBA journey even though I don’t have the possibility to use multitenant. (I wanted a RAC, now I have a RAC, now I need an Exadata, Multitenant, a private cloud, maybe goldengate and an environment where I can use storage snapshots for cloning. ) Well, no job is in this world really perfect, maybe only working for Oracle in a DBA team would open the true door to Oracle’s features, but there must be a complication too, because as written at the beginning, nothing is perfect.

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 RCAT 			  READ WRITE NO

[oracle@test ~]$ rman target=/

Recovery Manager: Release 12.1.0.2.0 - Production on Tue Jun 14 13:59:37 2016

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

connected to target database: RCLOUD (DBID=3718501809)

RMAN> backup as compressed backupset database plus archivelog delete input ;

RMAN> list backup summary ;

List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
20      B  A  A DISK        14.06.2016 14:00:04 1       1       YES        TAG20160614T140004
21      B  F  A DISK        14.06.2016 14:00:16 1       1       YES        TAG20160614T140006
22      B  F  A DISK        14.06.2016 14:00:27 1       1       YES        TAG20160614T140006
23      B  F  A DISK        14.06.2016 14:00:34 1       1       YES        TAG20160614T140006
24      B  A  A DISK        14.06.2016 14:00:35 1       1       YES        TAG20160614T140035
25      B  F  A DISK        14.06.2016 14:00:36 1       1       NO         TAG20160614T140036

[oracle@test ~]$ sqlplus psorger@rcat

SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 14 14:01:04 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter password:
Last Successful login time: Tue Jun 14 2016 13:52:15 +02:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> create table test (id number) ;

Table created.

SQL> select timestamp_to_scn(systimestamp) from dual ;

TIMESTAMP_TO_SCN(SYSTIMESTAMP)
------------------------------
		       1008446

SQL> insert into test values (1) ;
insert into test values (1)
            *
ERROR at line 1:
ORA-01950: no privileges on tablespace 'USERS'
SQL> connect / as sysdba
Connected.
SQL> alter session set container=rcat ;

Session altered.

SQL> alter user psorger quota unlimited on users ;

User altered.

SQL> insert into psorger.test values (1) ;

1 row created.

SQL> commit ;

Commit complete.

SQL> select timestamp_to_scn(systimestamp) from dual ;

TIMESTAMP_TO_SCN(SYSTIMESTAMP)
------------------------------
		       1008513

[oracle@test ~]$ rman target=/

Recovery Manager: Release 12.1.0.2.0 - Production on Tue Jun 14 14:04:08 2016

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

connected to target database: RCLOUD (DBID=3718501809)

RMAN> backup as compressed backupset database plus archivelog delete input ;

RMAN> list backup summary ;

List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
20      B  A  A DISK        14.06.2016 14:00:04 1       1       YES        TAG20160614T140004
21      B  F  A DISK        14.06.2016 14:00:16 1       1       YES        TAG20160614T140006
22      B  F  A DISK        14.06.2016 14:00:27 1       1       YES        TAG20160614T140006
23      B  F  A DISK        14.06.2016 14:00:34 1       1       YES        TAG20160614T140006
24      B  A  A DISK        14.06.2016 14:00:35 1       1       YES        TAG20160614T140035
25      B  F  A DISK        14.06.2016 14:00:36 1       1       NO         TAG20160614T140036
26      B  A  A DISK        14.06.2016 14:04:29 1       1       YES        TAG20160614T140429
27      B  F  A DISK        14.06.2016 14:04:41 1       1       YES        TAG20160614T140430
28      B  F  A DISK        14.06.2016 14:04:52 1       1       YES        TAG20160614T140430
29      B  A  A DISK        14.06.2016 14:04:53 1       1       YES        TAG20160614T140453
30      B  F  A DISK        14.06.2016 14:04:54 1       1       NO         TAG20160614T140454

RMAN> alter pluggable database rcat close ;

Statement processed

RMAN> run {
2> set until scn 1008446 ;
3> restore pluggable database rcat ;
4> recover pluggable database rcat ;
5> alter pluggable database rcat open resetlogs ;
6> }
Advertisements

Author:

Database administrator who loves to work with Oracle software. (Sometimes not)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s