Vit Spinka • Working with Oracle Database since 8i • Oracle Certified Master • Principal developer of Dbvisit Replicate • … which gets its data by parsing Oracle redo logs " • @vitspinka • [email protected] • This presentation for download at http://vitspinka.cz/download.html
Dbvisit • HQ in New Zealand, US subsidiary, partners throughout the world • Used in 80+ Countries • Database Replication is our playground • Worldwide leader in DR solutions for Oracle Standard Edition • Product Engineers with “real world” DBA Experience • Regular presenters at Oracle events such as OOW, Collaborate and NZOUG • Passionate about Oracle Technology
. . . By 800+ companies. What is multitenant, after all • A kind of new naming schema" • Separate datafiles, separate schemas, separate logins" • But same instance" " • When playing around with this, don’t forget PDBs don’t open on instance startup" • SQL> alter session set container=UNITPDB1; • (12.1.0.2 adds ALTER PLUGGABLE DATABASE … SAVE STATE)
CDB$VIEW • But don’t try that with your tables*:" SQL> select * from cdb$view("SCOTT"."EMP"); select * from cdb$view("SCOTT"."EMP") * ERROR at line 1: ORA-03113: end-of-file on communication channel " Exception [type: SIGSEGV, Address not mapped to object] [ADDR:0xA] [PC: 0xB83E308, kglhdgn()+120] [flags: 0x0, count: 1] kglhdgn()+120 signal __sighandler() 7F5B34766C40 ? kglrdti() +238 call kglhdgn() 7F5B34766C40 ? qcdlgbo()+5243 call kglrdti() 7F5B34766C40 ?
Links • Metadata link – the table is in CDB as well as in PDBs" • PDB has pointers to records in CDB" • (you can check that the rows are in PDB, too, really – cf. rowids)" SQL> select rowid, name from sys.col$ where obj#=18 and name='OBJ#'; ROWID NAME ------------------ ------------ AAAAACAABAAAACSABE OBJ# ------------------ ------------ AAAAACAABAAAACRAAT OBJ#" • Object link – the table in CDB only, but visible in PDBs, too" (and query with rowid crashes in PDB ☺ )" select rowid, name from dba_hist_sga where …
Metadata Links cont’ed • PDB has pointers to records in CDB" • And you can update the different rows in PDBs" SQL> update sys.col$ set name='LENGTH_' where obj#=13 and col#=7; … SQL> select con_id, name from cdb$view(sys.col$) where obj#=13 and col#=7 CON_ID NAME ---------- ---------- 1 LENGTH# 2 LENGTH 3 LENGTH_
Redo dump • MOS Note 103181.6" • ALTER SYSTEM DUMP LOGFILE 'filename'; " • The resulting trace file is huge and contains most (but not all!) interesting information from the redo in a text format" • We will see these dumps further in this session" " • Database can dump redo from a different database, as long as the endian (big/little) match and version is the same or higher than the source db
Redo dump (non-CDB) • Each redo record and each change now has CON_ID/CON_UID" REDO RECORD - Thread:1 RBA: 0x0008e6.00000002.0118 LEN: 0x023c VLD: 0x01 CON_UID: 0 SCN: 0x0000.00f51e47 SUBSCN: 4 07/13/2014 19:17:13 CHANGE #3 CON_ID:0 TYP:0 CLS:1 AFN:2 DBA:0x028000bf OBJ:91537 SCN:0x0000.00f51e47 SEQ:1 OP:11.2 ENC:0 RBL:0
•And the global stuff:"
CHANGE #1 CON_ID:0 TYP:0 CLS:37 AFN:4 DBA:0x010001c8 OBJ:4294967295 SCN:0x0000.00f51bff SEQ:1 OP:5.2 ENC:0 RBL:0 " •So all id’s are 0" •Note: Multi-tenant does a bit of reordering of the changes, but that’s immaterial
CON_ID in redo • Oracle does not allow transactions across PDBs" alter session set container=UNITPDB1; " Session altered. " SQL> update … update … * ERROR at line 1: ORA-65023: active transaction exists in container CDB$ROOT
Many things are not unique • Tablespace names (but note that there is only CDB undo)" CON_ID TABLESPACE_NAME ---------- ------------------------------ 1 SYSAUX 1 SYSTEM 1 TEMP 1 UNDOTBS1 1 USERS 2 SYSAUX 2 SYSTEM 2 TEMP 3 EXAMPLE 3 SOE 3 SYSAUX 3 SYSTEM and so on...
Backup just PDB • Or backup each PDB, but then you have to manage the archlogs" RMAN> backup pluggable database unitpdb1 plus archivelog; current log archived input archived log thread=1 sequence=139 RECID=129 STAMP=853427615 " Starting backup at 20-JUL-14 input datafile file number=00008 name=+…/EEFFBB158E172CB0E045000000000001/ DATAFILE/system.462.835807737 input datafile file number=00010 name=+…/EEFFBB158E172CB0E045000000000001/ DATAFILE/users.352.835807833 channel ORA_DISK_1: backup set complete, elapsed time: 00:02:46 Finished backup at 20-JUL-14
Backup a PDB tablespace from root • Documentation says it cannot be done, due to inability to unambiguously identify the tablespace" RMAN> backup tablespace UNITPDB1:SYSTEM; Starting backup at 20-JUL-14 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00008 name=+DATA/UNITCDB/ EEFFBB158E172CB0E045000000000001/DATAFILE/system.462.835807737 piece handle = +DATA/UNITCDB/EEFFBB158E172CB0E045000000000001/BACKUPSET/ 2014_07_20/nnndf0_tag20140720t143449_0.333.853425291 tag=TAG20140720T143449 comment=NONE Finished backup at 20-JUL-14
DataGuard • DG is almost oblivious to existence of CDB/PDB" • DG works at CDB level, protecting datafiles" • Target is always a CDB (because we ship redo, thus again, at CDB level)" • Can skip PDB by offlining datafiles (12.1.0.2: STANDBYS clause of the SQL CREATE PLUGGABLE DATABASE) • Plugging in new PDB – need to copy files to standby, too (ADG does a copy itself if it’s a clone from another PDB)
Patching • Most/all changes in DB are at CDB container (thanks to metadata and object links) or just binaries" • Create a new OH and CDB, patch it" • Replug PDBs into the new CDB (might need some further scripts – see patch docs, e.g. 12.1.0.2 needs catupgrd.sql), no copy of datafiles needed" " • Or do it in one go (but with more downtime) – use catctl.pl to run scripts on all PDBs
One last trick and two traps • You can use TWO_TASK (instead of ORACLE_SID) for local sqlplus" " • Beware that RMAN in PDB does not see any archive logs; check and test your scripts" " • DROP PLUGGABLE DATABASE will deregister backups, too