The wait is over and Oracle 12c has finally arrived. Of course there is a lot of interesting and useful looking new features, but one of the eye-catchers is the major architectural shift to multi-tenancy with the Container Database and Pluggable Database features.
To actually create a container database with pluggable databases is really straightforward as shown here by Matthew Walden. I must say I’m liking the new dbca, it feels just that little bit incrementally nicer to use.
Of course, one of the big ideas behind the multi-tenancy idea is to ramp up the amount of consolidation you can squeeze out of a given server. Using a multi-tenant database you can consolidate more databases onto a given amount of server memory and cpu. I’m doing a lot of that on Exadata at the moment, and I can see that it’s going to be really useful in certain scenarios for this. However, I’m not expecting 12c Exadata support anytime soon!
The other big driver for multi-tenancy is in manageability – the abstraction of user data from the oracle supplied metadata enables a lot of possibilities that did not exist previously. What I wanted to show in this post was how easy it is to create a clone of a pluggable database.
I’ve worked a lot with developers in the past, and one of the things I learned during this time is that developers can’t get enough copies of the database they working on. I don’t think this is a bad thing. In fact, I always took it as read that as the DBA it was my role to actually help the developer develop the best code they could. Certainly makes for less painful releases. So, I was all in favour of giving developers the tools and resources they needed to develop good code, and this very much included copies of the databases they were working on. Testing is a great thing!
[oracle@localhost orcl]$ sq SQL*Plus: Release 22.214.171.124.0 Production on Wed Jul 3 09:05:10 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 126.96.36.199.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> select CON_ID, NAME, OPEN_MODE from V$PDBS; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBORCL READ ONLY
So I’ve connected to my container database and I’m looking at what pluggable databases exist already. It just happens I have 2 at the moment. We see that both these happen to be read-only. We have the SEED database which is always present in a container database, and we currently have 1 pluggable database PDBORCL. That database just happens to be read only at the moment, but this is handy because:
Currently you can only create a clone of a pluggable database if that pluggable database is read only. This to me seems a bit of a limitation. I expect in a future release this limitation will be lifted.
However, apart from that I can’t emphasise enough how simple and trivial it is to create a clone of a pluggable database. It’s a simple one command:
SQL> create pluggable database PDB1 from PDBORCL FILE_NAME_CONVERT= ('/oradata/orcl/pdborcl', '/oradata/orcl/pdb1'); Pluggable database created. Elapsed: 00:00:10.67
Simple. This clone took 10 secs. The size of the database that was being cloned was 1.3G. The create pluggable database command has a lot options, but this was the simplest syntax I could see to create a clone of a pluggable database. You need the file_name_convert so that the datafiles from the pluggable database you are cloning can be put somewhere else. And this is something to bear in mind. It really is copying the datafiles from the pluggable database you are cloning. That could be a lot of space required.
SQL> select CON_ID, NAME, OPEN_MODE from V$PDBS; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBORCL READ ONLY 4 PDB1 MOUNTED Elapsed: 00:00:00.00
We can see the pluggable database PDB1 above is created in the mounted state, but it’s easy to get it opened:
SQL> alter pluggable database PDB1 open; Pluggable database altered. Elapsed: 00:00:03.88 SQL> select CON_ID, NAME, OPEN_MODE from V$PDBS; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBORCL READ ONLY 4 PDB1 READ WRITE Elapsed: 00:00:00.01
How I can see this being used for developers is you have cloned your production environment onto your test environment. All masking etc being done. You have this copy as your “Master Developer Copy” and make it read only, from this you can create as many copies for your developers as you wish. If a developer makes a mistake it’s easy to drop the pluggable database and create another one:
SQL> drop pluggable database PDB1 including datafiles; drop pluggable database PDB1 including datafiles * ERROR at line 1: ORA-65025: Pluggable database PDB1 is not closed on all instances. Elapsed: 00:00:00.05 SQL> alter pluggable database PDB1 close; Pluggable database altered. Elapsed: 00:00:00.31 SQL> drop pluggable database PDB1 including datafiles; Pluggable database dropped. Elapsed: 00:00:00.15
So we can see we have to have the pluggable database closed before we can drop it. To actually drop it took hardly any time at all, subsecond!
As I eluded to earlier on of the big drawbacks of using this method is that the space requirements can become vast if you start making lots of clones of large databases. What I’ve used in the past is using snapshots to drastically reduce the storage requirements when creating 10′s of copies of the same database. You essentially store 1 copy of the full datafiles and deltas of changes for each of the copies.
It’s great to see there is a snapshot option on the create pluggable database command! However you’ve got to be on the right storage ACFS or Direct NFS. I’m looking forward to testing this soon.
The new multi-tenancy architecture is a major shift for the Oracle database, and this just one of them.