Explore Oracle Database Upgrade 7 11gR2to12c after the upgrade is completed, insert PDB
Explore Oracle Database Upgrade 7
Insert PDB after 11gR2 to 12c upgrade is complete
Preface:
Since Oracle 12c, the concept of container database has been introduced to enable database plugging, for example:
Now let's take a look at how to insert the 11.2.0.4 database to the 12c CDP to make it a PDB
Database.
1. view database information:
SQL> col BANNER format a80SQL> set line 300SQL> select * from v$version;BANNER CON_ID-------------------------------------------------------------------------------- ----------Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0PL/SQL Release 12.1.0.1.0 - Production 0CORE 12.1.0.1.0 Production 0TNS for Linux: Version 12.1.0.1.0 - Production 0NLSRTL Version 12.1.0.1.0 - ProductionSQL> select cdb,name,dbid from v$database;CDB NAME DBID--- --------- ----------NO WOO 4199532651
From this we can see that the database after upgrading is still a non-CDB database, not a CDB database, at this time, we need to generate the pdb xml file in the none-CDB database, and then create the CDB database for insertion.
2. View table space and data file information:
SQL> select * from v$tablespace; TS# NAME INC BIG FLA ENC CON_ID---------- ------------------------------ --- --- --- --- ---------- 0 SYSTEM YES NO YES 0 1 SYSAUX YES NO YES 0 2 UNDOTBS1 YES NO YES 0 4 USERS YES NO YES 0 3 TEMP NO NO YES 0SQL> set line 300SQL> col file_name format a40SQL> col tablespace_name format a10SQL> select tablespace_name,file_name from dba_data_files;TABLESPACE FILE_NAME---------- ----------------------------------------USERS /DBData/woo/woo/users01.dbfUNDOTBS1 /DBData/woo/woo/undotbs01.dbfSYSAUX /DBData/woo/woo/sysaux01.dbfSYSTEM /DBData/woo/woo/system01.dbf
3. Create an XML file used to generate PDB
SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startup mountORACLE instance started.Total System Global Area 2772574208 bytesFixed Size 2292240 bytesVariable Size 2533361136 bytesDatabase Buffers 218103808 bytesRedo Buffers 18817024 bytesDatabase mounted.SQL> alter database open read only;Database altered.SQL> exec dbms_pdb.describe(pdb_descr_file => \'/home/oracle/woo_ora11g.xml\');PL/SQL procedure successfully completed.SQL> host ls -rtl /home/oracle/woo*.xml-rw-r--r-- 1 oracle oinstall 4147 Nov 27 19:17 /home/oracle/woo_ora11g.xmlSQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down
4. Check whether the upgraded database is suitable for insertion into the CDB in the PDB mode.
SQL> set serveroutput on;SQL> declare 2 compat boolean := FALSE; 3 begin 4 compat := dbms_pdb.check_plug_compatibility(pdb_descr_file => \'/home/oracle/woo_ora11g.xml\'); 5 if compat 6 then 7 dbms_output.put_line(\'YES\'); 8 else 9 dbms_output.put_line(\'No\'); 10 end if; 11 end; 12 /NoPL/SQL procedure successfully completed.
Because this is the first insert, the execution result is displayed as NO. you can ignore this operation.
5. Create a CDB Database
5.1 run dbca to create a cdb Database
5.2 specify the name of the cdb database to be created.
5.3 check before creating CDB
5.4 Summar Click Finish to start Creation
5.5 creating now
5.6 now the database has been created. Let us know about the CDB database.
5.7 click Close to Close the creation page
6. view the current pdb Information
[oracle@db01 ~]$ export ORACLE_SID=woo12cSQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB01 READ WRITE NOSQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 2 4107385256 PDB$SEED READ ONLY 3 3926295770 PDB01 READ WRITE
7. Insert the non-cdb database into cdb to become a pdb.
SQL> CREATE PLUGGABLE DATABASE woo_ora11g USING \'/home/oracle/woo_ora11g.xml\';Pluggable database created.
8. View alert log information
Insert Non-CDB into CDB to form an Alert Log output by PDB.
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- tables ---------- 2 PDB $ SEED READ ONLY NO 3 PDB01 READ WRITE NO 4 WOO_ORA11G MOUNTEDSQL> select con_id, dbid, NAME, OPEN_MODE from v $ pdbs; CON_ID dbid name OPEN_MODE ---------- consume ---------- 2 4107385256 PDB $ seed read only 3 3926295770 PDB01 read write 4 4199532651 WOO_ORA11G MOUNTED the first no-cdb plug cdb is in the mount state, you need to open it; SQL> alter pluggable database open; Pluggable database altered. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- 2 PDB $ SEED READ ONLY NO 3 PDB01 MOUNTED 4 WOO_ORA11G READ WRITE YES
After the insertion is complete, executeNoncdb_to_pdbScript to fix the originalNon-cdbNewPdbIncompatibility issues:
10. Execute the noncdb_pdb script
SQL> alter session set container = WOO_ORA11G; Session altered. SQL> @ $ ORACLE_HOME/rdbms/admin/noncdb_to_pdb. SQL ......... #### In case of warning, the script automatically ignores the error and continues to execute it. These problems will be fixed during the final script compilation. After the update, you must synchronize the pdb information. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- begin ---------- 4 WOO_ORA11G MOUNTEDSQL> alter pluggable database open restricted; Pluggable database altered. SQL> show pdbs CON_ID CON_NAME open mode restricted ---------- browse ---------- 4 WOO_ORA11G read write yessql> exec dbms_pdb.sync_pdb (); PL/SQL procedure successfully completed. SQL> alter pluggable database close immediate; Pluggable database altered. SQL> alter pluggable database open; Pluggable database altered.
11. no-cdb plug to cdb is successful now
SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB01 MOUNTED 4 WOO_ORA11G READ WRITE NOSQL>