Monday, July 1, 2013

A quick dip into Oracle 12C containers and pluggable databases

I've been playing around with 12C in the evening at home (what a sad, sad life I lead). I had a look through the documentation : http://docs.oracle.com/cd/E16655_01/server.121/e17633/cdbovrvw.htm#CEGEEIJG

This is well worth reading, it explains what all this container and pluggable stuff is all about.

I don't like the way Oracle appears to be at war with DBAs - from Oracle 10g which was billed as "the self-managing database" (Ha!), to this comment in the doco:

"Figure 17-2 depicts the databases in Figure 17-1 after consolidation onto one computer. The DBA team is reduced from five to three, with one CDB administrator managing the CDB while two PDB administrators split management of the PDBs."

Anyway, on with the tale.

When you create the database, you need to specify that it's an old-fashioned one (a non-CDB), or a new-fangled Container Database.

This is either with the "enable pluggable database" clause in the "create database" statement, or by checking the appropriate box in the dbca.

I've not done much investigation, but created a CDB and then a pluggable database within that.

I used the DBCA and checked the box to create it as a container database, and called it ANDYPLG (I should really have called this ANDYCDB but I didn't).

Once created, I then restarted the DBCA and selected 'Manage Pluggable Databases" and then "Create a Pluggable Database" - called it ANDYPLG1.

That was it. I now had an Oracle 12C container database that had a pluggable database inside it.

I didn't get a chance to do too much with it, but found a few things:

The pluggable database has no OS processes.

You can see the databases using the v$services view:

SQL> select name from v$services;

NAME
----------------------------------------------------------------
andyplg1
ANDYPLGXDB
ANDYPLG
SYS$BACKGROUND
SYS$USERS

You switch from the container to the pluggable database with the alter session command:

SQL> alter session set container=andyplg1;

Session altered.

SQL> select name from v$services;

NAME
----------------------------------------------------------------
andyplg1

I then created a new container from the one I'd created earlier - this is one of the big advantages with pluggable databases, the ability to clone them very easily. However, I did notice that the source database has to be read-only:

SQL> create pluggable database andyplg2 from andyplg1;
create pluggable database andyplg2 from andyplg1
*
ERROR at line 1:
ORA-65081: database or pluggable database is not open in read only mode

SQL> alter pluggable database andyplg1 close;

Pluggable database altered.

SQL> alter pluggable database andyplg1 open read only;

Pluggable database altered.

SQL> create pluggable database andyplg2 from andyplg1;

Pluggable database created.

SQL> alter pluggable database andyplg1 close;

Pluggable database altered.

SQL> alter pluggable database andyplg1 open read write;

Pluggable database altered.



SQL> select name from v$services;

NAME
----------------------------------------------------------------
andyplg2
andyplg1
ANDYPLGXDB
ANDYPLG
SYS$BACKGROUND
SYS$USERS

Voila! The andyplg2 was created as a clone of andyplg1.

My next investigations will be around how much control we have around creating the pluggable databases - for instance, look at the datafile names of andyplg1:

/u04/oradata/ANDYPLG/E06734C67F8740C5E043161816ACD7D0/datafile/o1_mf_system_8x1b
hcnw_.dbf

Not very nice.

I'll also look into how to manage resources withing the pluggable databases.





No comments:

Post a Comment