Você está na página 1de 71

Oracle 12c Database

Upgrade Workshop
Lab Workbook 1.5

Efrain Sanchez
Adrian Galindo
Oracle Server Technologies, Platform Technology Solutions
April 2016

Page 2

Disclaimer
Unless explicitly identified as such, the sample code here is not certified or supported by
Oracle; it is intended for educational or testing purposes only. The code samples may be
modified but not redistributed.
This document is intended for attendees of the workshop for their private use. It is not to
be sold, distributed to others, or posted on internal or external web sites without the
written consent of the Oracle Corporation. Copyright 2013, Oracle. All rights reserved.
This documentation contains proprietary information of Oracle Corporation. It is provided
under a license agreement containing restrictions on use and disclosure and is also
protected by copyright law. Reverse engineering of the software is prohibited. If this
documentation is delivered to a U.S. Government Agency of the Department of Defense,
then it is delivered with Restricted Rights and the following legend is applicable:
Restricted Rights Legend
Use, duplication or disclosure by the Government is subject to restrictions for commercial
computer software and shall be deemed to be Restricted Rights software under Federal law,
as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013, Rights in Technical Data and
Computer Software (October 1988).
This material or any portion of it may not be copied in any form or by any means without
the express prior written permission of Oracle Corporation. Any other copying is a violation
of copyright law and may result in civil and/or criminal penalties. If this documentation is
delivered to a U.S. Government Agency not within the Department of Defense, then it is
delivered with Restricted Rights, as defined in FAR 52.227-14, Rights in Data-General,
including Alternate III (June 1987).
The information in this document is subject to change without notice. If you find any
problems in the documentation, please report them to the respective trainers for the
workshop.
Oracle Corporation does not warrant that this document is error-free. Oracle and all
references to Oracle Products are trademarks or registered trademarks of Oracle
Corporation. All other products or company names are used for identification purposes only,
and may be trademarks of their respective owners.

Page 3

Table of Contents
1 Overview ......................................................................................................................... 5
1.1 Workshop Environment Setup ........................................................................................... 5
1.2 Hardware and Software Requirements ................................................................................ 5
1.3 VM Installation ............................................................................................................. 6
1.4 Oracle Virtualbox Installation........................................................................................... 6
1.5 About the VM Image ...................................................................................................... 6
1.6 Database environment in the VM ....................................................................................... 6
1.7 Usernames and Passwords ............................................................................................... 7
1.8 Startup the VM............................................................................................................. 7
1.9 Convetions used ........................................................................................................... 8
2 VM Setup ......................................................................................................................... 9
2.1 Start the Database and Listener ........................................................................................ 9
3 Patch and Updates ............................................................................................................ 10
3.1 Terminology ............................................................................................................... 10
3.2 Oracle Database Security Patch Updates and Patch Set Updates ............................................... 11
3.3 Security Patch Updates are applied only on the base release version ......................................... 11
3.4 One-off Patch Conflict Detection and Resolution ................................................................. 13
3.5 Patch Installation Instructions ........................................................................................ 14
3.6 Patch Post-Installation Instructions .................................................................................. 16
3.7 Applying Conflict Resolution Patches ................................................................................ 16
3.8 Loading Modified SQL Files into the Database ..................................................................... 16
3.9 Upgrade Oracle Recovery Manager Catalog ........................................................................ 17
3.10 Patch Post-Installation Instructions ................................................................................. 17
4 RMAN Database Duplication ................................................................................................. 18
4.1 Overview................................................................................................................... 18
4.2 Steps to ACTIVE database duplication ............................................................................... 19
4.2.1 Preparing the auxiliary instance ................................................................................ 19
4.2.2 Establish Oracle Net Connectivity to the Auxiliary Instance .............................................. 20
4.2.3 Enable Archive Log on db11g ................................................................................... 23
4.2.4 Start RMAN and Connect to the Database Instances ........................................................ 24
4.2.5 Run the DUPLICATE database command : .................................................................... 24
4.3 Drop Enterprise Manager Repository and AWR ...................................................................... 31
4.4 Disable Archive Log ...................................................................................................... 32
5 Database Upgrade ............................................................................................................. 33
5.1 Pre-Upgrade .............................................................................................................. 33
5.2 Configure 12c Listener ................................................................................................. 36
5.3 Database Upgrade Assistant ............................................................................................ 38
5.4 Enterprise Manager Express Configuration ......................................................................... 40
6 Non-CDB to Pluggable Database 12c Conversion ......................................................................... 42
6.1.1 Update Compatible parameter .................................................................................. 42
6.1.2 XML Manifest........................................................................................................ 42
6.2 Merge Data Dictionaries ................................................................................................ 43
6.3 Viewing PDBs Information ............................................................................................. 44
6.4 Renaming a PDB ......................................................................................................... 45
6.5 Renaming and Relocating Online Data Files ......................................................................... 47
7 12c Patch Set Update Apply ................................................................................................. 50
7.1 Clone 12c Home .......................................................................................................... 50
7.2 Update OPatch and apply 12c PSU Jan 2014 ....................................................................... 53
7.3 Create a new CDB ........................................................................................................ 56
7.4 Unplug PDB_APP01 ....................................................................................................... 58
7.5 Plug PDB_APP01 into the new Container ............................................................................ 59

Page 4

8 Create a PDB Full Clone into new CDB .................................................................................... 64


8.1 Delete CDB03 with RMAN ............................................................................................... 68
8.2 In Place PSU Apply ....................................................................................................... 69

Page 5

Overview

The objective of this workshop is to show the upgrade process of a 11g database to 12c
version, you will apply the latest Patch Set Update (PSU), clone the database, upgrade it
and convert the non-container database to a pluggable database.

1.1 Workshop Environment Setup


The lab environment for Oracle Database 12c Multitenant Administration Workshop is a
Virtual Machine (VM) built using Oracle VirtualBox. The Oracle VirtualBox VM environment
has the complete software stack required to run all the lab modules, plus gives you the
flexibility to work with many different scenarios without the need to install additional
software on your laptop/desktop.

1.2 Hardware and Software Requirements


Below are the prerequisites to install the workshop Oracle VirtualBox VM on your
laptop/desktop:

Oracle VirtualBox 4.3.x or later


64bit OS Capable of running Virtualbox
8 GB of RAM
Minimum 100 GB of free disk space
VT-x or AMD-v enabled in BIOS

If you are using Windows 8 Pro, disable Hyper-V by running the following command in a
command prompt with administrator rights:
bcdedit /set hypervisorlaunchtype no

To enable Hyper-V back:


bcdedit /set hypervisorlaunchtype auto

You will need to reboot Windows 8 for the changes to take effect.

1.3 VM Installation
The instructor will supply the Oracle VirtualBox VM image in the class. The VM image is in
the form of an Open Virtualization Archive (OVA) file (db12cvm1.ova). Copy this file to a
Page 6

location on your machine. Ensure that the location has sufficient space to store the OVA file
and also the expanded VMDK files. The OVA archive contains an Open Virtualization Format
(OVF) file and the VMDK files.

1.4 Oracle Virtualbox Installation


Before you install the Oracle VirtualBox VM, you need to install the Oracle VirtualBox
software on the host machine. Ensure that all prerequisites specified previously are
competed prior to the installation process.

1.5 About the VM Image


The supplied Oracle VirtualBox VM is a complete and fully integrated environment, and
contains all the required software to run various scenarios for the lab modules. All labs will
be run within your VM environment.
The following software components are installed and configured within the VM.

Oracle
Oracle
Oracle
Oracle

Linux Server 6.4


Database 11.2.0.4
Database 12.0.1.0
SQL Developer 4.0.0

1.6 Database environment in the VM


The following Oracle Databases are pre-installed and configured in the Lab VM. None of the
databases or the listeners are started by default upon boot time.
An 11gR2 Database called DB11G contains the example schemes (HR, OE, SCOTT, etc.)
during the workshop you will clone this database and upgrade the cloned database to 12c
version.
The VM contains also some 12c databases:
A Database called CDB1, this container database has two databases, PDB11 and PDB12.
A Non-Container Database called NONCDB.
These databases are also used in the Multitenant Workshop.

Page 7

1.7

Usernames and Passwords


Operating System: root/oracle, oracle/oracle
Oracle Database: Passwords for all Database users is oracle.

1.8 Startup the VM


Once the import is complete, select the recently imported db12cvm1 VM in VirtualBox VM
Manager and click Start to boot the VM.
Once the VM fully boots-up, you will be presented with a login screen, Login as the user
oracle using the supplied password.
Upon a successful login with oracle user, you should see the Oracle Linux desktop.
This completes your lab setup.

Page 8

1.9 Conventions used


The following conventions are used in this lab manual:
Notice that OS prompts ($) and SQL Plus prompt (SQL>) are displayed at the beginning of
the command to help you identify where to execute the instruction.
If you copy and paste of commands between the lab manual and the Terminal window, omit
the prompt and verify if there are several lines in the document that should be treated as a
single one in the command line:
$ sqlplus / AS SYSDBA
SQL> select 1 from dual;

All output from the commands is displayed in the box with a white background (as shown
below). The output will also contain the input, and is shown only when relevant to
illustrate the concept.
$ sqlplus / as SYSDBA
SQL*Plus: Release 12.1.0.1.0 Production on Tue Nov 19 22:59:05 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 64bit
Production With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
SQL> select 1 from dual;
1
---------1

The code font used in the lab is COURIER BOLD for commands and COURIER for output.

Page 9

2 VM Setup
2.1

Start the Database and Listener

The Oracle Database processes are not setup to start automatically upon boot time.
Therefore, start the listener and the DB11G database after booting the VM for the first
time, and also at subsequent boots.
1. Double Click the Terminal icon to start a new terminal session.
2. Setup the environment variables prior to starting the listener and the database.
Hint: Type the commands displayed only in bold, make sure to type a space between
the dot and oraenv command:
$ . oraenv
ORACLE_SID = [oracle] ? db11g
The Oracle base remains unchanged with value /u01/app/oracle

3. Startup the listener using the following commands.


$ lsnrctl start

4. Startup a SQL*Plus session as the SYS user connected with the SYSDBA role.
$ sqlplus / AS SYSDBA

5. In the SQL*Plus session, start the CDB1 container database using the following
commands.
SQL> startup;
SQL> exit;

Page 10

3 Patch and Updates


3.1 Terminology
The following terminology is used in this workbook
BP Bundle Patch. An iterative, cumulative patch that is issued between patch sets. Bundle
patches usually include only fixes, but some products may include minor enhancements.
CPU Critical Patch Update patch. Prior to October 2012, Security Patch Update (SPU)
patches were called Critical Patch Update (CPU) patches. For patches that were previously
released as CPU patches, this Patch Availability Document will continue to reference them
as CPUs.
NA Not Applicable.
OR On-Request. The patch is made available through the On-Request program.
PSU Patch Set Update. An iterative, cumulative patch that contains both security fixes and
non-security critical fixes that are high-value and low-risk.
SPU Security Patch Update. An iterative, cumulative patch consisting of security fixes.
Formerly known as a Critical Patch Update. Note that Oracle's program for quarterly release
of security fixes continues to be called the Critical Patch Update. Patches released as part
of this program may be Patch Set Updates, Security Patch Updates, and Bundle Patches.
Regardless of the patch type, the patches are cumulative.
My Oracle Support patch recommendation features are available on the Patches & Update
tab. The patches announced in this document as part of the CPU program are classified as
"Security" patch recommendations in My Oracle Support. If a new patch is being announced
in this document, then the classification on any earlier patch is changed to "General",
causing it to be removed from the My Oracle Support patch recommendations. If a patch
has a "Security" classification, and a subsequent bundle, SPU, or PSU is released with a
recommendation classification, then it will be classified as a "Security" recommendation in
My Oracle Support.

Page 11

3.2 Oracle Database Security Patch Updates and Patch Set Updates
The Database Security Patch Updates(SPU) or Critical Patch Updates(CPU) and Patch Set
Updates (PSU) are released independently, PSU are released each quarter. However, they
use different patching mechanisms, and Patch Set Updates include both security/critical
and recommended bug fixes.
IMPORTANT: Consider when you are deciding to apply Patch Set Updates instead of Security
Patch Updates, applying a CPU on an installation with an installed PSU is not supported.

3.3 Security Patch Updates are applied only on the base release version
Patch Set Updates can be applied on the base release version or on any earlier Patch Set
Update. For example, 11.1.0.7.2 can be applied on 11.1.0.7.1 and 11.1.0.7.0
Once a Patch Set Update has been applied, the recommended way to obtain future security
content is to apply subsequent Patch Set Updates. Reverting from an applied Patch Set
Update to the Security Patch Update, while technically possible, requires significant time
and effort, and therefore, is not advised. You would need to determine which individual,
non-security patches that are included in the Patch Set Update are pertinent to your
deployment, and then apply them after installing the Security Patch Update.
For more information on Patch Set Updates, see My Oracle Support Note 854428.1, Patch
Set Updates (PSUs) for Oracle Products.
The Patch Set Update and Critical Patch Update January 2014 Availability (Doc ID
1594621.1) recommends the following patches:
Oracle Database 11.2.0.4
Database 11.2.0.4.1 PSU Patch 17478514
Oracle Database 12.1.0.1
Database 12.1.0.1.2 PSU Patch 17552800
GI
12.1.0.1.2 PSU Patch 17735306

Page 12

These PSU files (which contains also Jan-2014 CPU) are already copied into /download
directory for your convenience:
/download
database
11.2

11.2.0.4

PSU_Jan-2014

p17478514_112040_Linux-x86-64.zip
12.1

12.1.0.1

PSU_Jan-2014

p17552800_121010_Linux-x86-64.zip
OPatch
11.2

11.2.0.3.6

p6880880_112000_Linux-x86-64.zip
12.1
12.1.0.1.2
p6880880_112000_Linux-x86-64.zip

Page 13

3.4 One-off Patch Conflict Detection and Resolution


For an introduction to the PSU one-off patch concepts, see "Patch Set Updates Patch
Conflict Resolution" in My Oracle Support Document 854428.1 Patch Set Updates for Oracle
Products.
The fastest and easiest way to determine whether you have one-off patches in the Oracle
home that conflict with the PSU, and to get the necessary conflict resolution patches, is to
use the Patch Recommendations and Patch Plans features on the Patches & Updates tab in
My Oracle Support. These features work in conjunction with the My Oracle Support
Configuration Manager. Recorded training sessions on these features can be found in
Document 603505.1.
For this workshop we are not using My Oracle Support Patch Plans but is another tool
available for complex environments.
Review all the databases currently configured by displaying oratab file:
$ cat /etc/oratab
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
db11g:/u01/app/oracle/product/11.2.0.4/db_1:N
cdb1:/u01/app/oracle/product/12.1.0.1/db_1:N
noncdb:/u01/app/oracle/product/12.1.0.1/db_1:N

Configure environment variables for the 11g Database:


. oraenv
ORACLE_SID = [cdb1] ? db11g
The Oracle base remains unchanged with value /u01/app/oracle

Is recommended to update OPatch to the latest version, let's check which version is already
installed:
$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 11.2.0.3.4
OPatch succeeded.

Page 14

Replace OPatch with the latest version, as of February of 2014 is 11.2.0.3.6, the patch file
is already copied into /download directory on the VM.
$ mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch.11.2.0.3.4
$ unzip -d $ORACLE_HOME /download/database/OPatch/11.2/11.2.0.3.6/p6880880_112000_Linux-x86-64.zip
$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 11.2.0.3.6

Determine whether any currently installed one-off patches conflict with the PSU patch,
unzip the PSU (Patch Set Update ) first:
$ mkdir -p /install/11.2/CPU_Jan-2014
$ unzip -d /install/11.2/CPU_Jan-2014 /download/database/11.2/11.2.0.4/CPU_Jan2014/p17478514_112040_Linux-x86-64.zip
$ cd /install/11.2/CPU_Jan-2014/17478514
$ export PATH=$ORACLE_HOME/OPatch:$PATH
$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./

The report will indicate the patches that conflict with PSU 17478514 and the patches for
which PSU 17478514 is a superset, check the results and search for the word passed:
Prereq "checkConflictAgainstOHWithDetail" passed.

3.5 Patch Installation Instructions


So far you just passed the Pre-Requirements, follow the next steps to install the patch:
Shut down all instances and listeners associated with the Oracle home that you are
updating, in this case only db11g.
$ sqlplus / as sysdba
SQL> shutdown immediate
SQL> exit
$ lsnrctl stop listener

Set your current directory to the directory where the patch is located and then run the
OPatch utility by entering the following commands, make sure you enter a valid email
structure like name@email.com :
Page 15

$ cd /install/11.2/CPU_Jan-2014/17478514
$ opatch apply
Oracle Interim Patch Installer version 11.2.0.3.6
Copyright (c) 2013, Oracle Corporation. All rights reserved.
Oracle Home
: /u01/app/oracle/product/11.2.0.4/db_1
Central Inventory : /u01/app/oraInventory
from
: /u01/app/oracle/product/11.2.0.4/db_1/oraInst.loc
OPatch version
: 11.2.0.3.6
OUI version
: 11.2.0.4.0
Log file location :
/u01/app/oracle/product/11.2.0.4/db_1/cfgtoollogs/opatch/17478514_Jan_29_2014_08_06
_33/apply2014-01-29_08-06-32AM_1.log
Applying interim patch '17478514' to OH '/u01/app/oracle/product/11.2.0.4/db_1'
Verifying environment and performing prerequisite checks...
All checks passed.
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.
Email address/User Name: <<<your email here >>>
Provide your My Oracle Support password to receive security updates via your My
Oracle Support account.
Password (optional): <<<optional>>>
Please shutdown Oracle instances running out of this ORACLE_HOME on the local
system.
(Oracle Home = '/u01/app/oracle/product/11.2.0.4/db_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
...
Verifying the update...
Patch 17478514 successfully applied
OPatch Session completed with warnings.
Log file location:
/u01/app/oracle/product/11.2.0.4/db_1/cfgtoollogs/opatch/17478514_Jan_29_2014_08_06
_33/apply2014-01-29_08-06-32AM_1.log
OPatch completed with warnings.

Review the warnings in the log file.

Page 16

3.6 Patch Post-Installation Instructions


After installing the patch, perform the following actions:
Apply conflict resolution patches
Load modified SQL files into the database
Upgrade Oracle Recovery Manager catalog

3.7 Applying Conflict Resolution Patches


For this particular install there are no one-off patches that were determined to be needed

3.8 Loading Modified SQL Files into the Database


Start the database listener
$ lsnrctl start

Connect to the database using SQL*Plus. Connect as SYSDBA and run the catbundle.sql
script as follows:
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql psu apply

The catbundle.sql execution is reflected in the dba_registry_history view by a row


associated with bundle series PSU.
SQL>
SQL>
SQL>
SQL>

set linesize 100


column version format A10
column bundle_series format A10
column comments format A20

SQL> select to_char(action_time, 'DD-MM-YY') atime, version, comments from registry$history;


ATIME
-------24-08-13
22-11-13
02-02-14

VERSION
---------11.2.0.4
11.2.0.4
11.2.0.4

COMMENTS
-------------------Patchset 11.2.0.2.0
Patchset 11.2.0.2.0
PSU 11.2.0.4.1

SQL> exit

Page 17

For information about the catbundle.sql script, see My Oracle Support Document 605795.1
Introduction to Oracle Database catbundle.sql.
Check the following log files in $ORACLE_HOME/cfgtoollogs/catbundle or
$ORACLE_BASE/cfgtoollogs/catbundle for any errors:
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log
where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS.

3.9 Upgrade Oracle Recovery Manager Catalog


Don't execute it for this workshop, but If you are using the Oracle Recovery Manager in
your production servers, the RMAN catalog needs to be upgraded also.
$ rman catalog username/password@alias
RMAN> UPGRADE CATALOG;

3.10 Patch Post-Installation Instructions


There are no actions required for databases that have been upgraded or created after
installation of PSU 11.2.0.4.1.

Page 18

4 RMAN Database Duplication


4.1 Overview
This lab shows how duplicate a database using the RMAN duplicate command. The duplicate
database will have a different DBID from the source database and will function entirely
independently.
Starting from 11g you can do duplicate database in 2 ways.
1. Active database duplication
2. Backup-based duplication
Active database duplication copies the live target database over the network to the
auxiliary destination and then creates the duplicate database.The only difference is that
you don't need to have the pre-existing RMAN backups and copies, the duplication work is
performed by an auxiliary channel.This channel corresponds to a server session on the
auxiliary instance on the auxiliary host.
For more information, review Doc ID 452868.1
As part of the duplicating operation, RMAN automates the following steps:
1. Creates a control file for the duplicate database
2. Restarts the auxiliary instance and mounts the duplicate control file
3. Creates the duplicate datafiles and recovers them with incremental backups and
archived redo logs.
4. Opens the duplicate database with the RESETLOGS option
For the active database duplication, RMAN does one extra step .i.e. copy the target
database datafiles over the network to the auxiliary instance
Scope of lab is restricted to Active database duplication . For the Backup-base duplication
refer Note 259694.1

Page 19

4.2 Steps to ACTIVE database duplication


4.2.1 Preparing the auxiliary instance
1.- Creating initialization Parameter file for the Auxiliary instance
If you are using SPFILE then only parameter required for the duplicate database is DB_NAME
, required parameters are :
DB_NAME
CONTROL_FILES
DB_BLOCK_SIZE
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
DB_RECOVERY_FILE_DEST
2.- Create an Oracle Password File for the Auxiliary Instance
Password file is must for the Active database duplication.A password file is not required for
backup-based duplication. For Active database duplication it connects directly to the
auxiliary instance using the password file with the same SYSDBA password as target
database. In case you are using password file make sure to have same SYSDBA password as
the target database.Also you can specify the PASSWORD FILE option on the DUPLICATE
command.In this case, RMAN copies the source database password file to the destination
host and overwrites any existing password file for the auxiliary instance.
We are using password file option in the duplicate command.

Page 20

4.2.2 Establish Oracle Net Connectivity to the Auxiliary Instance


Auxiliary instance must be available through Oracle Net if you are duplicating from an
ACTIVE database, when using copy and paste, make sure lines are not truncated.
1. Create the parameter file:
vi $ORACLE_HOME/dbs/initdb12c.ora
DB_NAME=db12c
diagnostic_dest='/u01/app/oracle'
DB_FILE_name_CONVERT='/u01/app/oracle/oradata/db11g','/u01/app/oracle/oradata/db12c'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/db11g','/u01/app/oracle/oradata/db12c'
SGA_TARGET=262144000
CONTROL_FILES='/u01/app/oracle/oradata/db12c/control01.ctl','/u01/app/oracle/fast_recovery_area/db12c/control02.ctl'

COMPATIBLE= '11.2.0.4.0'

2. Create directories and password file :


mkdir -p /u01/app/oracle/admin/db12c/adump
mkdir -p /u01/app/oracle/oradata/db12c
mkdir -p /u01/app/oracle/fast_recovery_area/db12c
export ORACLE_SID=db12c
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
orapwd FILE=$ORACLE_HOME/dbs/orapwdb12c PASSWORD=oracle
ls -la $ORACLE_HOME/dbs/orapwdb12c

3. Start the Auxiliary instance :


$ cd $ORACLE_HOME/dbs
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 29 09:02:23 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile=initdb12c.ora
ORACLE instance started.
Total System Global Area 263049216 bytes
Fixed Size
2252336 bytes
Variable Size
113246672 bytes
Database Buffers
142606336 bytes
Redo Buffers
4943872 bytes
SQL> create spfile from pfile;
SQL> exit

Page 21

Add the following line in /etc/oratab, test oraenv script:

$ vi /etc/oratab
...
db12c:/u01/app/oracle/product/11.2.0.4/db_1:N
$ . oraenv
ORACLE_SID = [cdb1] ? db12c
The Oracle base remains unchanged with value /u01/app/oracle

4. Create the necessary oracle NET connectivity in the listener.ora and the tnsnames.ora
file (In the TARGET and AUXILIARY host, for this workshop is the same server).
Append the SID_LIST_LISTENER on listener.ora file and restart the listener:
$ vi $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = db12c)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/db_1)
(SID_NAME = db12c)
)
)
$ lsnrctl stop
$ lsnrctl start
$ vi $ORACLE_HOME/network/admin/tnsnames.ora
db11g =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db12cvm1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db11g)
)
)
db12c =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db12cvm1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db12c)
)
)

Confirm the connection to both the target and the auxiliary instance using sqlplus. In this
Page 22

example we are creating the duplicate database in the same server (Auxiliary server).
$ tnsping db11g
$ tnsping db12c
[oracle@db12cvm1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 29-JAN-2014 09:37:27
Copyright (c) 1991, 2013, Oracle.

All rights reserved.

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db12cvm1.localdomain)(PORT=1521)))
STATUS of the LISTENER
-----------------------Alias
LISTENER
Version
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date
02-FEB-2014 00:36:24
Uptime
0 days 0 hr. 1 min. 42 sec
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF
Listener Parameter File
/u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/db12cvm1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db12cvm1.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "db11g" has 1 instance(s).
Instance "db11g", status READY, has 1 handler(s) for this service...
Service "db11gXDB" has 1 instance(s).
Instance "db11g", status READY, has 1 handler(s) for this service...
Service "db12c" has 2 instance(s).
Instance "db12c", status UNKNOWN, has 1 handler(s) for this service...
Instance "db12c", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

4.2.3 Enable Archive Log on db11g


A requirement for RMAN duplication is to have archive log active, execute the following
commands to enable it:
$ . oraenv
ORACLE_SID = [db12c] ? db11g
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 29 13:29:47 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.

Page 23

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> archive log list
Database log mode
No Archive Mode
Automatic archival
Disabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
4
Current log sequence
6
SQL> show parameter recovery_file_dest
NAME
TYPE
VALUE
------------------------------------ ----------- -----------------------------db_recovery_file_dest
string /u01/app/oracle/fast_recovery_
area
db_recovery_file_dest_size
big integer 4182M
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size
2260088 bytes
Variable Size
671089544 bytes
Database Buffers
390070272 bytes
Redo Buffers
5517312 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
4
Next log sequence to archive
6
Current log sequence
6
SQL> alter system archive log current;
SQL> alter system archive log current;
SQL> exit

Page 24

4.2.4 Start RMAN and Connect to the Database Instances


Start RMAN and connect to the source database as TARGET, the duplicate database instance
as AUXILIARY, and, if applicable, the recovery catalog database. You can start the RMAN
client on any host so long as it can connect to all of the database instances. If the auxiliary
instance requires a text-based initialization parameter file, then this file must exist on the
same host that runs the RMAN client application.
Connect to the TARGET and AUXILIARY database:
$ rman
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jan 29 19:04:22 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
RMAN> connect TARGET sys/oracle@db11g ;
connected to target database: DB11G (DBID=301826024)
RMAN> connect AUXILIARY sys/oracle@db12c ;
connected to auxiliary database: DB12C (not mounted)

4.2.5 Run the DUPLICATE database command :


For this lab, use active database duplication to duplicate the database in the same server,
but the same steps apply to clone a database on a separate server:
(Please note that the 3 lines in the document should be entered as a single line command,
ie. remove the line breaks before execute the command)
RMAN> DUPLICATE TARGET DATABASE TO 'db12C' FROM ACTIVE DATABASE
DB_FILE_NAME_CONVERT '/u01/app/oracle/oradata/db11g',
'/u01/app/oracle/oradata/db12c';
Starting Duplicate Db at 29-JAN-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}

Page 25

executing Memory Script


Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area

263049216 bytes

Fixed Size
Variable Size
Database Buffers
Redo Buffers

2252336
117440976
138412032
4943872

bytes
bytes
bytes
bytes

contents of Memory Script:


{
sql clone "alter system set db_name =
''DB11G'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''DB12C'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format
'/u01/app/oracle/oradata/db12c/control01.ctl';
restore clone controlfile to
'/u01/app/oracle/fast_recovery_area/db12c/control02.ctl' from
'/u01/app/oracle/oradata/db12c/control01.ctl';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set
duplicate'' scope=spfile

db_name =

''DB11G'' comment= ''Modified by RMAN

sql statement: alter system set


RMAN duplicate'' scope=spfile

db_unique_name =

''DB12C'' comment= ''Modified by

Oracle instance shut down


Oracle instance started
Total System Global Area

263049216 bytes

Fixed Size
Variable Size
Database Buffers
Redo Buffers

2252336
117440976
138412032
4943872

bytes
bytes
bytes
bytes

Starting backup at 29-JAN-14


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0.4/db_1/dbs/snapcf_db11g.f
tag=TAG20140129T190519 RECID=4 STAMP=838148719

Page 26

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01


Finished backup at 29-JAN-14
Starting restore at 29-JAN-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=171 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 29-JAN-14
database mounted
contents of Memory Script:
{
set newname for datafile 1 to "/u01/app/oracle/oradata/db12c/system01.dbf";
set newname for datafile 2 to "/u01/app/oracle/oradata/db12c/sysaux01.dbf";
set newname for datafile 3 to "/u01/app/oracle/oradata/db12c/undotbs01.dbf";
set newname for datafile 4 to "/u01/app/oracle/oradata/db12c/users01.dbf";
set newname for datafile 5 to "/u01/app/oracle/oradata/db12c/example01.dbf";
backup as copy reuse
datafile 1 auxiliary format "/u01/app/oracle/oradata/db12c/system01.dbf"
datafile
2 auxiliary format "/u01/app/oracle/oradata/db12c/sysaux01.dbf"
datafile
3 auxiliary format "/u01/app/oracle/oradata/db12c/undotbs01.dbf"
datafile
4 auxiliary format "/u01/app/oracle/oradata/db12c/users01.dbf"
datafile
5 auxiliary format "/u01/app/oracle/oradata/db12c/example01.dbf"
;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 29-JAN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/db11g/system01.dbf
output file name=/u01/app/oracle/oradata/db12c/system01.dbf tag=TAG20140129T190526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/db11g/sysaux01.dbf
output file name=/u01/app/oracle/oradata/db12c/sysaux01.dbf tag=TAG20140129T190526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/db11g/example01.dbf
output file name=/u01/app/oracle/oradata/db12c/example01.dbf tag=TAG20140129T190526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/db11g/undotbs01.dbf
output file name=/u01/app/oracle/oradata/db12c/undotbs01.dbf tag=TAG20140129T190526

Page 27

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03


channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/db11g/users01.dbf
output file name=/u01/app/oracle/oradata/db12c/users01.dbf tag=TAG20140129T190526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 29-JAN-14
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like
"/u01/app/oracle/fast_recovery_area/DB11G/archivelog/2014_01_29/o1_mf_1_8_9gm9d9rb_
.arc" auxiliary format
"/u01/app/oracle/product/11.2.0.4/db_1/dbs/arch1_8_832156459.dbf"
;
catalog clone archivelog
"/u01/app/oracle/product/11.2.0.4/db_1/dbs/arch1_8_832156459.dbf";
switch clone datafile all;
}
executing Memory Script
Starting backup at 29-JAN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=8 RECID=3 STAMP=838148778
output file name=/u01/app/oracle/product/11.2.0.4/db_1/dbs/arch1_8_832156459.dbf
RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 29-JAN-14
cataloged archived log
archived log file
name=/u01/app/oracle/product/11.2.0.4/db_1/dbs/arch1_8_832156459.dbf RECID=3
STAMP=838148779
datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=838148779 file
name=/u01/app/oracle/oradata/db12c/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=5 STAMP=838148779 file
name=/u01/app/oracle/oradata/db12c/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=838148779 file
name=/u01/app/oracle/oradata/db12c/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=838148779 file
name=/u01/app/oracle/oradata/db12c/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=8 STAMP=838148779 file
name=/u01/app/oracle/oradata/db12c/example01.dbf
contents of Memory Script:
{
set until scn 1021799;
recover
clone database

Page 28

delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 29-JAN-14
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file
/u01/app/oracle/product/11.2.0.4/db_1/dbs/arch1_8_832156459.dbf
archived log file
name=/u01/app/oracle/product/11.2.0.4/db_1/dbs/arch1_8_832156459.dbf thread=1
sequence=8
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-JAN-14
Oracle instance started
Total System Global Area

263049216 bytes

Fixed Size
Variable Size
Database Buffers
Redo Buffers

2252336
117440976
138412032
4943872

bytes
bytes
bytes
bytes

contents of Memory Script:


{
sql clone "alter system set db_name =
''DB12C'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set
value by RMAN'' scope=spfile
sql statement: alter system reset

db_name =

''DB12C'' comment= ''Reset to original

db_unique_name scope=spfile

Oracle instance shut down


connected to auxiliary database (not started)
Oracle instance started
Total System Global Area

263049216 bytes

Fixed Size
2252336 bytes
Variable Size
117440976 bytes
Database Buffers
138412032 bytes
Redo Buffers
4943872 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DB12C" RESETLOGS ARCHIVELOG
MAXLOGFILES
16

Page 29

MAXLOGMEMBERS
3
MAXDATAFILES
100
MAXINSTANCES
8
MAXLOGHISTORY
292
LOGFILE
GROUP
1 ( '/u01/app/oracle/oradata/db12c/redo01.log' ) SIZE 50 M
GROUP
2 ( '/u01/app/oracle/oradata/db12c/redo02.log' ) SIZE 50 M
GROUP
3 ( '/u01/app/oracle/oradata/db12c/redo03.log' ) SIZE 50 M
DATAFILE
'/u01/app/oracle/oradata/db12c/system01.dbf'
CHARACTER SET AL32UTF8

REUSE,
REUSE,
REUSE

contents of Memory Script:


{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/db12c/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/db12c/sysaux01.dbf",
"/u01/app/oracle/oradata/db12c/undotbs01.dbf",
"/u01/app/oracle/oradata/db12c/users01.dbf",
"/u01/app/oracle/oradata/db12c/example01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/db12c/temp01.dbf in control file
cataloged datafile copy datafile copy file
name=/u01/app/oracle/oradata/db12c/sysaux01.dbf RECID=1 STAMP=838148793
cataloged datafile copy datafile copy file
name=/u01/app/oracle/oradata/db12c/undotbs01.dbf RECID=2 STAMP=838148793
cataloged datafile copy datafile copy file
name=/u01/app/oracle/oradata/db12c/users01.dbf RECID=3 STAMP=838148793
cataloged datafile copy datafile copy file
name=/u01/app/oracle/oradata/db12c/example01.dbf RECID=4 STAMP=838148793
datafile 2 switched to datafile copy input datafile copy
file name=/u01/app/oracle/oradata/db12c/sysaux01.dbf
datafile 3 switched to datafile copy input datafile copy
file name=/u01/app/oracle/oradata/db12c/undotbs01.dbf
datafile 4 switched to datafile copy input datafile copy
file name=/u01/app/oracle/oradata/db12c/users01.dbf
datafile 5 switched to datafile copy input datafile copy
file name=/u01/app/oracle/oradata/db12c/example01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 29-JAN-14

Page 30

RECID=1 STAMP=838148793
RECID=2 STAMP=838148793
RECID=3 STAMP=838148793
RECID=4 STAMP=838148793

You should see the words Finished Duplicate, now that the duplication is completed, exit
Recovery Manager:
RMAN> exit

Page 31

4.3 Drop Enterprise Manager Repository and AWR


11g Enterprise Manager repository is not supported in 12c, so we need to drop the
repository first, we will configure the new Enterprise Manager Express after the upgrade
process.
In case you want to keep AWR information, create a backup with AWREXTR.SQL script.
Execute SQLPLUS and drop the sysman account and management objects on db12c
database:
$ . oraenv
ORACLE_SID = [db11g] ? db12c
The Oracle base remains unchanged with value /u01/app/oracle
# Drop EM Repository
$ sqlplus / as sysdba
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>

EXEC
EXEC
drop
drop
drop
drop
drop

sysman.emd_maintenance.remove_em_dbms_jobs;
sysman.setEMUserContext('',5);
user sysman cascade;
role MGMT_USER;
user MGMT_VIEW cascade;
public synonym MGMT_TARGET_BLACKOUTS;
public synonym SETEMVIEWUSERCONTEXT;

# Clean up and rebuild AWR repository to free some space:


SQL> @?/rdbms/admin/catnoawr.sql
SQL> @?/rdbms/admin/catawrtb.sql

Modify db12c pfile and spfile


$ . oraenv
ORACLE_SID = [db11g] ? db12c
The Oracle base remains unchanged with value /u01/app/oracle
$ cd $ORACLE_HOME/dbs/
$ sqlplus / as sysdba
SQL> show parameter instance_name
NAME
TYPE
VALUE
------------------------------------ ----------- -----------------------------instance_name
string db12c
SQL> create pfile from memory;
SQL> exit

Page 32

We need to modify the parameter file and delete all the lines starting with "_", which are
the hidden parameters, sed command is perfect for this task:
$ mv initdb12c.ora initdb12c.bak
$ sed /^_/d initdb12c.bak > initdb12c.ora

Append the following lines to initdb12c.ora file:


vi initdb12c.ora
db_recovery_file_dest=/u01/app/oracle/fast_recovery_area
db_recovery_file_dest_size=4182M
l

Still using vi on file initdb12c.ora, delete the lines containing the following parameters
which are deprecated :
BACKGROUND_DUMP_DEST
USER_DUMP_DEST
Otherwise you will get these errors:
ORA-32006: BACKGROUND_DUMP_DEST initialization parameter has been deprecated
ORA-32006: USER_DUMP_DEST initialization parameter has been deprecated

Connect to the database and create the SPFile


$ sqlplus / as sysdba
SQL> shutdown immediate
SQL> startup pfile=initdb12c.ora
SQL> create spfile from pfile;

4.4 Disable Archive Log


Disable Archive Log only for this LAB, don't disable it for production databases.
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>

shutdown immediate;
startup mount
alter database noarchivelog;
alter database open;
archive log list;
exit

$ rm -rf /u01/app/oracle/fast_recovery_area/db12c/arch*.dbf
$ rm -rf $ORACLE_HOME/dbs/arch*.dbf

Page 33

5 Database Upgrade
5.1 Pre-Upgrade
Certain steps are needed for the upgrade, execute the following commands to know which
actions need to be executed before:
$ export ORACLE_SID=db12c
$ cd /u01/app/oracle/product/12.1.0.1/db_1/rdbms/admin
$ sqlplus / as sysdba
$ @preupgrd.sql
Loading Pre-Upgrade Package...
Executing Pre-Upgrade Checks...
Pre-Upgrade Checks Complete.
************************************************************
Results of the checks are located at:
/u01/app/oracle/cfgtoollogs/DB12C/preupgrade/preupgrade.log
Pre-Upgrade Fixup Script (run in source database environment):
/u01/app/oracle/cfgtoollogs/DB12C/preupgrade/preupgrade_fixups.sql
Post-Upgrade Fixup Script (run shortly after upgrade):
/u01/app/oracle/cfgtoollogs/DB12C/preupgrade/postupgrade_fixups.sql
************************************************************
Fixup scripts must be reviewed prior to being executed.
************************************************************
************************************************************
====>> USER ACTION REQUIRED
<<====
************************************************************
The following are *** ERROR LEVEL CONDITIONS *** that must be addressed
prior to attempting your upgrade.
Failure to do so will result in a failed upgrade.
You MUST resolve the above errors prior to upgrade
************************************************************

Execute the fixups script to find out what specific changes need to be done :
SQL> @/u01/app/oracle/cfgtoollogs/DB12C/preupgrade/preupgrade_fixups.sql

Page 34

Pre-Upgrade Fixup Script Generated on 2014-01-29 22:58:58


006
Beginning Pre-Upgrade Fixups...

Version: 12.1.0.1 Build:

**********************************************************************
Check Tag:
DEFAULT_PROCESS_COUNT
Check Summary: Verify min process count is not too low
Fix Summary:
Review and increase if needed, your PROCESSES value.
**********************************************************************
Fixup Returned Information:
WARNING: --> Process Count may be too low
Database has a maximum process count of 200 which is lower than the
default value of 300 for this release.
You should update your processes value prior to the upgrade
to a value of at least 300.
For example:
ALTER SYSTEM SET PROCESSES=300 SCOPE=SPFILE
or update your init.ora file.
**********************************************************************
**********************************************************************
Check Tag:
DBMS_LDAP_DEPENDENCIES_EXIST
Check Summary: Check for dependency on DBMS_LDAP package
Fix Summary:
Network Objects must be reviewed manually.
**********************************************************************
Fixup Returned Information:
WARNING: --> Existing DBMS_LDAP dependent objects
Database contains schemas with objects dependent on DBMS_LDAP package.
Refer to the Upgrade Guide for instructions to configure Network ACLs.
USER APEX_030200 has dependent objects.
**********************************************************************
**********************************************************************
Check Tag:
AMD_EXISTS
Check Summary: Check to see if AMD is present in the database
Fix Summary:
Manually execute ORACLE_HOME/oraolap/admin/catnoamd.sql script to
remove OLAP.
**********************************************************************
Fixup Returned Information:
INFORMATION: --> OLAP Catalog(AMD) exists in database
Starting with Oracle Database 12c, OLAP is desupported.
If you are not using the OLAP Catalog component and want
to remove it, then execute the
ORACLE_HOME/oraolap/admin/catnoamd.sql script before or
after the upgrade.
**********************************************************************
**********************************************************************
[Pre-Upgrade Recommendations]
**********************************************************************
*****************************************
********* Dictionary Statistics *********
*****************************************
Please gather dictionary statistics 24 hours prior to

Page 35

upgrading the database.


To gather dictionary statistics execute the following command
while connected as SYSDBA:
EXECUTE dbms_stats.gather_dictionary_stats;
^^^ MANUAL ACTION SUGGESTED ^^^
**************************************************
************* Fixup Summary ************
3 fixup routines generated INFORMATIONAL messages that should be reviewed.
**************** Pre-Upgrade Fixup Script Complete *********************

Review the output, some manual actions are needed.


The first recommendation is to increase the processes parameter to 300, execute the
following command using sqlplus;
SQL> ALTER SYSTEM SET PROCESSES=300 SCOPE=SPFILE;

Only for this workshop, and as an example to delete a database option, drop OLAP and
APEX, is recommended to drop all the options that are not in use, this will reduce the total
time needed to execute the upgrade:
SQL> @?/olap/admin/catnoamd.sql
SQL> @?/apex/apxremov.sql
SQL> drop package htmldb_system;
SQL> drop public synonym htmldb_system;

Recompile Invalid objects in parallel degree of 2 and purge recycle bin:


SQL> @?/rdbms/admin/utlprp.sql 2
# Verify invalid objects:
SQL> COLUMN object_name FORMAT A30
SQL> SELECT owner, object_type, object_name, status
FROM dba_objects
WHERE status = 'INVALID'
ORDER BY owner, object_type, object_name;
# Purge the Recycle bin
SQL> PURGE RECYCLEBIN;
SQL> PURGE DBA_RECYCLEBIN;

Page 36

Stop db11g and 11g Listener to free available memory:


$ . oraenv
ORACLE_SID = [db12c] ? db11g
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@db12cvm1 db12c]$ sqlplus / as sysdba
SQL> shutdown immediate;
SQL> exit
$ lsnrctl stop listener

5.2 Configure 12c Listener


Is recommended to use the latest listener version, 12c Database software is already
installed but the listener is not configured, execute the following commands:
$ cd /home/oracle
$ . 12c_env
$ netca

On the graphical interface, execute the following actions:


Listener configuration, Create listener in port 1521
Naming Methods configuration, select Local Naming and Easy Connect Naming
Finish
Verify that the listener is up and running:
$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 30-JAN-2014 00:16:55
Copyright (c) 1991, 2013, Oracle.

All rights reserved.

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db12cvm1.localdomain)(PORT=1521)))
STATUS of the LISTENER
-----------------------Alias
LISTENER
Version
TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date
30-JAN-2014 00:14:33
Uptime
0 days 0 hr. 2 min. 22 sec
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF

Page 37

Listener Parameter File


/u01/app/oracle/product/12.1.0.1/db_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/db12cvm1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db12cvm1.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "db12c" has 1 instance(s).
Instance "db12c", status READY, has 1 handler(s) for this service...
The command completed successfully

Page 38

5.3 Database Upgrade Assistant


You are ready to perform the upgrade process using the Database Upgrade Assistant, must
have the 12c environment variables already set (12c_env script), execute the dbua
command and follow the instructions:
$ dbua

1.- Select Operation


Select the operation that you want to perform:
2.- Select Database
Source Oracle Home Release 11.2.0.4.0:

Upgrade Oracle Database

db12c

3.- Prerequisite Checks


Expand Pre Upgrade Utility Checks and review the problems
Click on Apply Action button
Click on Check Again button
4.- Upgrade Options
Upgrade Parallelism
2
Upgrade Options
Check Recompile Invalid Options with Parallelism: 2
Check Upgrade Timezone Data
Check Gather Statistics Before Upgrade
Check Set User Tablespaces Read Only During Upgrade
5.- Management Option
Check Configure Enterprise Manager (EM) Database Express
6.- Move Database Files
Leave un-checked
7.- Network Configuration
Check Listener on 12c Home
8.- Recovery Options
Select I have my own backup and restore strategy
9.- Summary
Review the Summary

Page 39

10.- When Finished


Click on Results
Click on Close
Depending on the host processor and disk speed, the upgrade takes 45 minutes on a server,
and up to two 90 minutes on a laptop virtualized environment.
Once the upgrade is completed, use SQLPLUS to display the Upgrade Summary, check that
all components are VALID and review upgrade time:
SQL> @?/rdbms/admin/utlu121s.sql
.
Oracle Database 12.1 Post-Upgrade Status Tool
02-12-2014 07:13:55
.
Component
Current
Version Elapsed Time
Name
Status
Number
HH:MM:SS
.
Oracle Server
.
VALID
12.1.0.1.0 00:13:17
JServer JAVA Virtual Machine
.
VALID
12.1.0.1.0 00:03:00
Oracle Workspace Manager
.
VALID
12.1.0.1.0 00:01:08
OLAP Analytic Workspace
.
VALID
12.1.0.1.0 00:00:25
Oracle OLAP API
.
VALID
12.1.0.1.0 00:00:17
Oracle XDK
.
VALID
12.1.0.1.0 00:00:53
Oracle Text
.
VALID
12.1.0.1.0 00:00:42
Oracle XML Database
.
VALID
12.1.0.1.0 00:04:23
Oracle Database Java Packages
.
VALID
12.1.0.1.0 00:00:17
Oracle Multimedia
.
VALID
12.1.0.1.0 00:02:56
Spatial
.
VALID
12.1.0.1.0 00:06:18
Final Actions
.
00:01:56
Total Upgrade Time: 00:35:52
PL/SQL procedure successfully completed.

Note that this time does not count Post-Upgrade time, selections on Step 4 Upgrade
Options in dbua.

Page 40

5.4 Enterprise Manager Express Configuration


There are certain configuration steps in order to configure EM Express, the first one is to
enable the TCP dispatcher service for the database, in this case db12cXDB , connect to
db12c and using SQLPLUS, execute the following commands:
SQL> alter system set dispatchers ="(PROTOCOL=TCP)(SERVICE=db12cXDB)" scope=both;

Restart the database so that the changes take effect.


SQL> shutdown immediate
SQL> startup

Use the PL/SQL procedure DBMS_XDB_CONFIG.SETHTTPSPORT to disable HTPP and set the
HTTPS port for EM Express, this will update the Oracle XML DB Repository and the changes
are immediate.
SQL> exec dbms_xdb_config.sethttpport(0);
SQL> exec dbms_xdb_config.sethttpsport(5555);

The listener is now configured to use port 5555 for https protocol, to display EM Express
port configuration, use the following command:
SQL> select dbms_xdb_config.getHttpsPort() from dual;

exit SQLPLUS
Display the listener configuration and filter the output by tcp using grep command:
$ lsnrctl status | grep tcp
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db12cvm1.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=db12cvm1.localdomain)(PORT=5555))(Securi
ty=(my_wallet_directory=/u01/app/oracle/admin/DB12C/xdb_wallet))(Presentation=HTTP)
(Session=RAW))

Page 41

To access EM Express, enter the following URL using FireFox:


https://db12cvm1:5555/em/login
Explore the different tabs and options in the new graphical user interface.

Page 42

6 Non-CDB to Pluggable Database 12c Conversion


6.1.1 Update Compatible parameter
Now that you upgraded the database to 12c as "non-cdb", convert it to a pluggable database
and plug it to CDB1, a container database is already configured for the lab.
You cannot use the new Oracle Database 12c features, unless the COMPATIBLE
initialization parameter is set to the default value of 12.0.0.
Oracle recommends increasing the COMPATIBLE parameter only after complete testing of
the upgraded database has been performed. After you increase the COMPATIBLE
parameter, you cannot subsequently downgrade the database.
First, display and change the compatible parameter from 11.2. to 12.1
SQL> show parameter compatible
NAME
TYPE
VALUE
------------------------------------ ----------- -----------------------------compatible
string 11.2.0.4.0
noncdb_compatible
boolean
FALSE
SQL> alter system set compatible='12.1.0.0.0' scope=spfile;

Second, shutdown the database instance and open it in read only mode.
SQL> shutdown immediate;
SQL> startup open read only

6.1.2 XML Manifest


To create the XML manifest file, execute DBMS_PDB.describe stored procedure and then
close the non-cdb
SQL> execute dbms_pdb.describe('/home/oracle/db12c.xml');
SQL> shutdown immediate;
SQL> exit

Review db12c.xml file created in /home/oracle/db12c.xml


A Container Database named cdb1 is already configured, container and non-container
Page 43

databases are created with the Database Configuration Assistant.


Start database cdb1 and plug database db12c using the manifest file, all datafiles will
remain in the same directory because of nocopy option.
$ . oraenv
ORACLE_SID = [db12c] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus / as sysdba
SQL> startup
SQL> create pluggable database db12c using '/home/oracle/db12c.xml' nocopy tempfile
reuse;
Pluggable database created.

6.2 Merge Data Dictionaries


Execute noncdb_to_pdb.sql script to merge both data dictionaries.
SQL> alter session set container=db12c;
SQL> @?/rdbms/admin/noncdb_to_pdb.sql
SQL> alter pluggable database db12c open;

Validate if any issues occurred during the plug-in process.


SQL> select time,name,status,message from PDB_PLUG_IN_VIOLATIONS;
no rows selected

Page 44

6.3 Viewing PDBs Information


The CDB_PDBS view and DBA_PDBS view provide information about the PDBs associated
with a CDB, including the status of each PDB. To view this information, the query must be
run by a common user whose current container is the root. When the current container is a
PDB, all queries on these views return no results.
To view information about PDBs:
SQL> COLUMN NAME FORMAT A15
SQL> COLUMN RESTRICTED FORMAT A10
SQL> COLUMN OPEN_TIME FORMAT A30
SQL> SELECT NAME, OPEN_MODE, RESTRICTED, OPEN_TIME FROM V$PDBS;
NAME
OPEN_MODE RESTRICTED OPEN_TIME
--------------- ---------- ---------- -----------------------------DB12C
READ WRITE NO
30-JAN-14 08.30.39.336 AM

Notice that the query only displays information about db12c pluggable database, reconnect
to container cdb1 and execute the query again.
SQL> conn / as sysdba
SQL> SELECT CON_ID, NAME, OPEN_MODE, RESTRICTED, OPEN_TIME FROM V$PDBS;
NAME
--------------PDB$SEED
PDB11
PDB12
DB12C

OPEN_MODE
---------READ ONLY
MOUNTED
MOUNTED
READ WRITE

RESTRICTED OPEN_TIME
---------- -----------------------------NO
30-JAN-14 06.25.59.041 AM
NO

30-JAN-14 08.30.39.336 AM

Now, all the PDBs on his container are displayed, notice PDB11 and PDB12 are only mounted
which is the default behavior, you can open each pluggable database pdb11 with the
following command:
SQL> alter pluggable database PDB11 open;
Pluggable database altered.

There are several options to open an close one, a list or all PDBs, for more information
review the database documentation library.
Page 45

Change the session to PDB11 and display the container ID and NAME:
SQL> alter session set container=PDB11;
SQL> SHOW CON_ID
CON_ID
-----------------------------3
SQL> SHOW CON_NAME
CON_NAME
-----------------------------PDB11

6.4 Renaming a PDB


Connect to the container cdb1 and open the db12c PDB in restricted mode, review the state
of all pluggable databases in the container:
SQL> conn / as sysdba
SQL> alter pluggable database db12c close immediate;
SQL> alter pluggable database db12c open restricted;
SQL> select name, restricted from v$pdbs;

Rename the PDB. You must be connected to the PDB to rename it.
SQL> alter session set container=db12c;
SQL> alter pluggable database db12c rename global_name to pdb_app01;
SQL> alter pluggable database close immediate;
SQL> alter pluggable database open;
SQL> select name, open_mode from v$pdbs;
NAME
OPEN_MODE
--------------- ---------PDB_APP01
READ WRITE
SQL> exit

Page 46

Append TNS alias in tnsnames.ora file


$ vi $ORACLE_HOME/network/admin/tnsnames.ora
PDB_APP01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db12cvm1.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB_APP01)
)
)

Ping and connect to the database using the new alias:


$ tnsping pdb_app01
TNS Ping Utility for Linux: Version 12.1.0.1.0 - Production on 30-JAN-2014 09:58:42
Copyright (c) 1997, 2013, Oracle.

All rights reserved.

Used parameter files:


/u01/app/oracle/product/12.1.0.1/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =
db12cvm1.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = PDB_APP01)))
OK (10 msec)
$ sqlplus system@pdb_app01
SQL*Plus: Release 12.1.0.1.0 Production on Thu Jan 30 09:58:53 2014
Copyright (c) 1982, 2013, Oracle.

All rights reserved.

Enter password:
Last Successful login time: Thu Jan 30 2014 07:41:39 -06:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options

Page 47

Modify the tnsnames.ora file in 11gR2 Home and test the connection:
$ . oraenv
ORACLE_SID = [db11g] ? db11g
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus system@pdb_app01
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 30 10:14:12 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options

I you need to enable client connections from a previous version client, for example Net8,
add the following lines in sqlnet.ora on the server and client accordingly:
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
SQLNET.ALLOWED_LOGON_VERSION_VERSION=8

6.5 Renaming and Relocating Online Data Files


All datafiles for pdb_app01 still remain in oradata/db12c directory, you can use ALTER
DATABASE MOVE DATAFILE SQL statement to rename or relocate data files online.
This statement enables you to rename or relocate a data file while the database is open
and users are accessing the data file. When you rename or relocate online data files, the
pointers to the data files, as recorded in the database control file, are changed. The files
are also physically renamed or relocated at the operating system level.
Display all datafiles, notice the undo tablespace is shared with the ROOT container cdb1.
SQL> SELECT name FROM v$datafile;
NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/CDB1/datafile/o1_mf_undotbs1_98zkfs8g_.dbf
/u01/app/oracle/oradata/db12c/system01.dbf
/u01/app/oracle/oradata/db12c/sysaux01.dbf
/u01/app/oracle/oradata/db12c/users01.dbf
/u01/app/oracle/oradata/db12c/example01.dbf

Page 48

Create the destination directory and move system, sysaux, users and example datafiles,
make sure you have enough space available on the destination directory, the command will
create a new file on the destination before deleting the source datafile.
SQL> !mkdir /u01/app/oracle/oradata/CDB1/PDB_APP01
SQL> ALTER DATABASE MOVE DATAFILE '/u01/app/oracle/oradata/db12c/system01.dbf'
TO '/u01/app/oracle/oradata/CDB1/PDB_APP01/system01.dbf';
SQL> ALTER DATABASE MOVE DATAFILE '/u01/app/oracle/oradata/db12c/sysaux01.dbf'
TO '/u01/app/oracle/oradata/CDB1/PDB_APP01/sysaux01.dbf';
SQL> ALTER DATABASE MOVE DATAFILE '/u01/app/oracle/oradata/db12c/users01.dbf'
TO '/u01/app/oracle/oradata/CDB1/PDB_APP01/users01.dbf';
SQL> ALTER DATABASE MOVE DATAFILE '/u01/app/oracle/oradata/db12c/example01.dbf'
TO '/u01/app/oracle/oradata/CDB1/PDB_APP01/example01.dbf';

Query v$datafile view to review the changes:


SQL> SELECT name FROM v$datafile;
NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/CDB1/datafile/o1_mf_undotbs1_98zkfs8g_.dbf
/u01/app/oracle/oradata/CDB1/PDB_APP01/system01.dbf
/u01/app/oracle/oradata/CDB1/PDB_APP01/sysaux01.dbf
/u01/app/oracle/oradata/CDB1/PDB_APP01/users01.dbf
/u01/app/oracle/oradata/CDB1/PDB_APP01/example01.dbf

The ALTER DATABASE MOVE DATAFILE syntax is not available for temporary files, so you need
to create a new temporary tablespace and delete the original temp tablespace.
SQL> CREATE TEMPORARY TABLESPACE pdb_app01_temp
TEMPFILE '/u01/app/oracle/oradata/CDB1/PDB_APP01/pdb_app01_temp01.dbf'
SIZE 30M REUSE EXTENT MANAGEMENT LOCAL UNIFORM;
Tablespace created.
SQL> ALTER DATABASE TEMPFILE
'/u01/app/oracle/oradata/CDB1/PDB_APP01/pdb_app01_temp01.dbf'
AUTOEXTEND ON NEXT 100M;
Database altered.

Page 49

SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE pdb_app01_temp;


Database altered.
SQL> DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
SQL> SELECT file_name FROM dba_temp_files;
FILE_NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/CDB1/PDB_APP01/pdb_app01_temp01.dbf
SQL> SELECT * from DBA_TEMP_FREE_SPACE;
TABLESPACE_NAME
TABLESPACE_SIZE ALLOCATED_SPACE FREE_SPACE
------------------------------ --------------- --------------- ---------PDB_APP01_TEMP
31457280
2097152
29360128

Now you can delete the control files, redo logs and undo datafile remaining from the
upgraded db12c which are no longer needed for a pluggable database.
SQL> !ls -la /u01/app/oracle/oradata/db12c
total 901168
drwxr-xr-x. 2
drwxr-x---. 7
-rw-r-----. 1
-rw-r-----. 1
-rw-r-----. 1
-rw-r-----. 1
-rw-r-----. 1

oracle
oracle
oracle
oracle
oracle
oracle
oracle

oinstall
4096
oinstall
4096
oinstall 10502144
oinstall 52429312
oinstall 52429312
oinstall 52429312
oinstall 754982912

Feb
Feb
Feb
Feb
Feb
Feb
Feb

6
2
6
6
6
6
6

Review the changes in Enterprise Manager Express.

Page 50

22:09
00:28
20:01
19:44
19:59
19:44
20:01

.
..
control01.ctl
redo01.log
redo02.log
redo03.log
undotbs01.dbf

7 12c Patch Set Update Apply


Using the concepts learned, install 12c PSU, the corresponding PSU and OPatch zip files are
located in the /download directory, is recommended for you to review the README html or
txt file first.
The files we are going to use are highlighted in bold.
/download
database
11.2

11.2.0.4

PSU_Jan-2014

p17478514_112040_Linux-x86-64.zip
12.1

12.1.0.1

PSU_Jan-2014

p17552800_121010_Linux-x86-64.zip
OPatch
11.2

11.2.0.3.6

p6880880_112000_Linux-x86-64.zip
12.1
12.1.0.1.2
p6880880_121010_Linux-x86-64.zip

In this lab you will execute the following process:


Clone the current 12c Home
Apply 12c January PSU on the new Home
Create a new CDB
Unplug PDB_APP01
Plug PDB_APP01 it into the new container

7.1 Clone 12c Home


First you need to stop all databases and listener in order to clone the 12c database home,
execute the following commands. Note the export command have to be type or pasted in
the same line.
$ lsnrctl stop
$ cd /u01/app/oracle/product/12.1.0.1
$ cp -rp db_1 db_2

Page 51

$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/db_2
$ export PATH=$ORACLE_HOME/bin:/usr/sbin:/usr/sbin:/usr/lib64/qt3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

To clone the oracle home, execute the following


$ perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE=$ORACLE_BASE ORACLE_HOME=$ORACLE_HOME
ORACLE_HOME_NAME=db_2_PSU_Jan_2014

./runInstaller -clone -waitForCompletion "ORACLE_BASE=/u01/app/oracle"


"ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/db_2"
"ORACLE_HOME_NAME=db_2_PSU_Jan_2014" -silent -paramFile
/u01/app/oracle/product/12.1.0.1/db_2/clone/clone_oraparam.ini
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB.
Actual 50809 MB
Passed
Checking swap space: must be greater than 500 MB.
Actual 4031 MB
Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-02-19_0219-09PM. Please wait ...You can find the log of this install session at:
/u01/app/oraInventory/logs/cloneActions2014-02-19_02-19-09PM.log
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
Copy files in progress.
Copy files successful.
Link binaries in progress.
Link binaries successful.
Setup files in progress.
Setup files successful.
Setup Inventory in progress.
Setup Inventory successful.
Finish Setup in progress.
Finish Setup successful.

Page 52

5% Done.
10% Done.
15% Done.
20% Done.
25% Done.
30% Done.
35% Done.
40% Done.
45% Done.
50% Done.
55% Done.
60% Done.
65% Done.
70% Done.
75% Done.
80% Done.
85% Done.
90% Done.
95% Done.
100% Done.

The cloning of db_2_PSU_Jan_2014 was successful.


Please check '/u01/app/oraInventory/logs/cloneActions2014-02-19_02-19-09PM.log' for
more details.

To finish the cloning process, execute the following scripts as root user:
$ su Password:
# /u01/app/oracle/product/12.1.0.1/db_2/root.sh
Check /u01/app/oracle/product/12.1.0.1/db_2/install/root_db12cvm1.localdomain_201402-19_14-22-33.log for the output of root script

At this point, the cloned Oracle home is ready to support a database. You can create a new
database for this Oracle home by running Oracle Database Configuration Assistants or point
an existing database to the new Oracle home.
The following steps can be used to point an existing database to the new Oracle home.
Create a 12c_env2.sh file from 12c_env.sh environment file and modify the path for the
new Oracle Home.
$ cd /home/oracle
$ cp 12c_env 12c_env2
$ vi 12c_env2
PATH=/usr/sbin:/usr/lib64/qt3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/b
in:$HOME/bin
export
export
export
export
export
export
export
export
export
export
export
export

ORACLE_HOSTNAME=db12cvm1.localdomain
ORACLE_UNQNAME=cdb1
ORACLE_BASE=/u01/app/oracle
GRID_HOME=/u01/app/12.1.0.1/grid
DB_HOME=$ORACLE_BASE/product/12.1.0.1/db_2
ORACLE_HOME=$DB_HOME
ORACLE_SID=cdb1
ORACLE_TERM=xterm
BASE_PATH=/usr/sbin:$PATH
PATH=$ORACLE_HOME/bin:$BASE_PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

$ . 12c_env2
$ echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0.1/db_2

Page 53

7.2 Update OPatch and apply 12c PSU Jan 2014


Is recommended to update OPatch to the latest version, let's check which version is already
installed:
$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 12.1.0.1.0
OPatch succeeded.

Replace OPatch with the latest version, as of February of 2014 is 11.2.0.3.6, the patch file
is already copied into /download directory on the VM.
$ mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch.12.1.0.1.0
$ unzip -d $ORACLE_HOME /download/database/OPatch/12.1/12.1.0.1.2/p6880880_121010_Linux-x8664.zip

$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 12.1.0.1.2
OPatch succeeded.

To install the PSU 12.1.0.1.2 patch, the Oracle home must be the 12.1.0.1.0 Database
installed. Subsequent PSU patches can be installed on Oracle Database 12.1.0.1.0 or any
PSU with a lower 5th numeral version than the one being installed.
Determine whether any currently installed one-off patches conflict with the PSU patch,
unzip the PSU (Patch Set Update ) first:
$ mkdir -p /install/12.1/CPU_Jan-2014
$ unzip -d /install/12.1/CPU_Jan-2014 /download/database/12.1/12.1.0.1/CPU_Jan2014/p17552800_121010_Linux-x86-64.zip
$ cd /install/12.1/CPU_Jan-2014/17552800/
$ export PATH=$ORACLE_HOME/OPatch:$PATH
$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.1.0.1.2
Copyright (c) 2013, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home
: /u01/app/oracle/product/12.1.0.1/db_2
Central Inventory : /u01/app/oraInventory
from
: /u01/app/oracle/product/12.1.0.1/db_2/oraInst.loc

Page 54

OPatch version
: 12.1.0.1.2
OUI version
: 12.1.0.1.0
Log file location :
/u01/app/oracle/product/12.1.0.1/db_2/cfgtoollogs/opatch/opatch2014-02-21_10-0209AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.

The report will list all the patches that might have a conflict with PSU 17552800 and the
patches for which PSU 17552800 is a superset, note that Oracle pro-actively provides PSU
12.1.0.1.2 one-off patches for common conflicts.
Check the results and search for the word passed:
So far you just passed the Pre-Requirements, follow the next steps to install the patch:
Shut down all instances and listeners associated with the Oracle home that you are
updating. Set your current directory to the directory where the patch is located
(/install/12.1/CPU_Jan-2014/17552800) and then run the OPatch utility by entering the
following commands, make sure you enter a valid email structure like name@email.com :
$ cd /install/12.1/CPU_Jan-2014/17552800
$ opatch apply
Oracle Interim Patch Installer version 12.1.0.1.2
Copyright (c) 2013, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home
: /u01/app/oracle/product/12.1.0.1/db_2
Central Inventory : /u01/app/oraInventory
from
: /u01/app/oracle/product/12.1.0.1/db_2/oraInst.loc
OPatch version
: 12.1.0.1.2
OUI version
: 12.1.0.1.0
Log file location :
/u01/app/oracle/product/12.1.0.1/db_2/cfgtoollogs/opatch/opatch2014-02-21_10-0209AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
[oracle@db12cvm1 17552800]$ cd /install/12.1/CPU_Jan-2014/17552800
[oracle@db12cvm1 17552800]$ opatch apply
Oracle Interim Patch Installer version 12.1.0.1.2

Page 55

Copyright (c) 2013, Oracle Corporation.

All rights reserved.

Oracle Home
: /u01/app/oracle/product/12.1.0.1/db_2
Central Inventory : /u01/app/oraInventory
from
: /u01/app/oracle/product/12.1.0.1/db_2/oraInst.loc
OPatch version
: 12.1.0.1.2
OUI version
: 12.1.0.1.0
Log file location :
/u01/app/oracle/product/12.1.0.1/db_2/cfgtoollogs/opatch/17552800_Feb_21_2014_10_06
_27/apply2014-02-21_10-06-27AM_1.log
Applying interim patch '17552800' to OH '/u01/app/oracle/product/12.1.0.1/db_2'
Verifying environment and performing prerequisite checks...
Patch 17552800: Optional component(s) missing : [ oracle.network.cman, 12.1.0.1.0 ]
All checks passed.
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.
Email address/User Name: email@oracle.com
Provide your My Oracle Support password to receive security updates via your My
Oracle Support account.
Password (optional):
Please shutdown Oracle instances running out of this ORACLE_HOME on the local
system.
(Oracle Home = '/u01/app/oracle/product/12.1.0.1/db_2')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Patching
Patching
Patching
Patching
Patching
Patching
Patching
Patching

component
component
component
component
component
component
component
component

oracle.network.rsf, 12.1.0.1.0...
oracle.rdbms, 12.1.0.1.0...
oracle.rdbms.rsf, 12.1.0.1.0...
oracle.ldap.rsf, 12.1.0.1.0...
oracle.ldap.rsf.ic, 12.1.0.1.0...
oracle.rdbms.util, 12.1.0.1.0...
oracle.rdbms.dbscripts, 12.1.0.1.0...
oracle.rdbms.rman, 12.1.0.1.0...

Verifying the update...


Patch 17552800 successfully applied
Log file location:
/u01/app/oracle/product/12.1.0.1/db_2/cfgtoollogs/opatch/17552800_Feb_21_2014_10_06
_27/apply2014-02-21_10-06-27AM_1.log
OPatch succeeded.

Page 56

7.3 Create a new CDB


Oracle provides response file templates for each product and installation type, and for each
configuration tool. These files are located in the ORACLE_BASE\ORACLE_HOME\assistants
directory, and the database\response directory on the Oracle Database installation media.
Keep in mind that the response file may contain plain text passwords, ownership of the
response file should be given to the Oracle software installation owner only.
Copy the response file template to the home directory and modify only these parameters:
$ cp $ORACLE_HOME/assistants/dbca/dbca.rsp /home/oracle/cdb_apps.rsp
$ vi cdb_apps.rsp
GDBNAME = "CDB03"
SID = "CDB03"
CREATEASCONTAINERDATABASE = "true"
NUMBEROFPDBS = 0
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
DATAFILEDESTINATION = $ORACLE_BASE/oradata
RECOVERYAREADESTINATION = $ORACLE_BASE/flash_recovery_area
CHARACTERSET = "AL32UTF8"
NATIONALCHARACTERSET= "AL16UTF16"
LISTENERS = "listener"
DATABASETYPE = "MULTIPURPOSE"
TOTALMEMORY = "1024"

Now you are ready to run Database Configuration Assistant in response file mode, you must
use the -responseFile flag in combination with either the -silent or -progressOnly flag. In
the silent mode, Database Configuration Assistant uses values that you specify, in the
response file or as command-line options, to create a database.
Create the CDB03 directory and execute dbca
$ mkdir -p /u01/app/oracle/oradata/CDB03
$ dbca -silent -createDatabase -cloneTemplate -responseFile cdb03.rsp
Copying database files
1% complete
3% complete
37% complete
Creating and starting Oracle instance
40% complete

Page 57

45% complete
46% complete
47% complete
52% complete
57% complete
58% complete
59% complete
62% complete
Completing Database Creation
66% complete
70% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/CDB03/CDB03.log" for further
details.

Page 58

7.4 Unplug PDB_APP01


To unplug a PDB, you first have to close it and then generate an XML manifest file. The XML
file contains information about the names and the full paths of the tablespaces, as well as
data files of the unplugged PDB. The information will be used later by the plugging
operation.
Unplug the closed PDB specifying the path and name of the XML file, then drop the closed
PDB and keep the data files.
Use SQL*Plus to close the PDBs before they can be unplugged.
$ . oraenv
ORACLE_SID = [cdb1] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Sat Feb 22 12:24:00 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options
SQL> alter pluggable database PDB_APP01 close immediate;
Pluggable database altered.
SQL> alter pluggable database PDB_APP01 unplug into '/home/oracle/pdb_app01.xml';
Pluggable database altered.
SQL> drop pluggable database PDB_APP01 keep datafiles;
Pluggable database dropped.
SQL> select pdb_name, status from cdb_pdbs where pdb_name = 'PDB_APP01';
no rows selected
SQL> exit

The unplugging operation makes changes in the PDB data files to record that the PDB was
properly and successfully unplugged. Because the PDB is still part of the CDB, you can back
it up in Oracle Recovery Manager (Oracle RMAN). This backup provides a convenient way to
archive the unplugged PDB. After backing it up, you then remove it from the CDB catalog.
But, of course, you must preserve the data files for the subsequent plugging operation.
Page 59

7.5 Plug PDB_APP01 into the new Container


Before starting the plugging operation, make sure that the to-be-plugged-in PDB is
compatible with the new host CDB. Execution of the following PL/SQL block raises an error
if it is not compatible.
$ . oraenv
[enter CDB03 at the prompt]
$ sqlplus / as sysdba
SQL> set serveroutput on
SQL> DECLARE
SQL> compatible BOOLEAN := FALSE;
SQL> BEGIN
SQL> compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file =>
'/home/oracle/pdb_app01.xml');
SQL> if compatible then
SQL>
DBMS_OUTPUT.PUT_LINE('Is PDB compatible? YES');
SQL> else
SQL>
DBMS_OUTPUT.PUT_LINE('Is PDB compatible? NO');
SQL> end if;
SQL> END;
SQL> /

Create the destination directory for the new data files and then execute the following
command to Plug the PDB into the CDB03 and move the data files to a new location, all in a
single command, make sure lines don't get truncated.

SQL> ! mkdir /u01/app/oracle/oradata/CDB03/PDB_APP01


SQL> create pluggable database PDB_APP01
using '/home/oracle/pdb_app01.xml'
move file_name_convert = ('/u01/app/oracle/oradata/CDB1/PDB_APP01',
'/u01/app/oracle/oradata/CDB03/PDB_APP01');
Pluggable database created.

Page 60

Verify the status and open mode of the plugged PDB and list the data files of the plugged
PDB.
SQL> show pdbs;
CON_ID CON_NAME
OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ---------2 PDB$SEED
READ ONLY NO
3 PDB_APP01
MOUNTED
SQL> select name from v$datafile where con_id=3;
NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/CDB03/PDB_APP01/system01.dbf
/u01/app/oracle/oradata/CDB03/PDB_APP01/sysaux01.dbf
/u01/app/oracle/oradata/CDB03/PDB_APP01/users01.dbf
/u01/app/oracle/oradata/CDB03/PDB_APP01/example01.dbf

Open PDB_APP01 database and connect to it using easy connect string:


SQL> alter pluggable database PDB_APP01 open;
Pluggable database altered.
SQL> connect sys/oracle@localhost:1521/PDB_APP01 as sysdba
Connected.
SQL> show pdbs
CON_NAME
-----------------------------PDB_APP01

The last step is to update the PDB Data Dictionary using the datapatch utility, this tool will
run the necessary apply scripts to load the modified SQL files into the databases. An entry
will be added to the dba_registry_history and dba_registry_sqlpatch views reflecting the
patch application.
$ cd $ORACLE_HOME/OPatch
$ ./datapatch -verbose
SQL Patching tool version 12.1.0.1.0 on Sat Feb 22 14:57:56 2014
Copyright (c) 2013, Oracle. All rights reserved.
Connecting to database...OK

Page 61

Determining current state...


Currently installed SQL Patches:
PDB CDB$ROOT:
PDB PDB$SEED:
PDB PDB_APP01:
Currently installed C Patches: 17552800
For the following PDBs: CDB$ROOT
Nothing to roll back
The following patches will be applied: 17552800
For the following PDBs: PDB$SEED
Nothing to roll back
The following patches will be applied: 17552800
For the following PDBs: PDB_APP01
Nothing to roll back
The following patches will be applied: 17552800
Adding patches to installation queue...
Installing patches...
Validating logfiles...
Patch 17552800 apply (pdb CDB$ROOT): SUCCESS
logfile:
/u01/app/oracle/product/12.1.0.1/db_2/sqlpatch/17552800/17552800_apply_CDB03_CDBROO
T_2014Feb22_14_58_27.log (no errors)
catbundle generate logfile:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_CDB03_CDBROOT_GENERATE_2014Feb2
2_14_58_28.log (no errors)
catbundle apply logfile:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_CDB03_CDBROOT_APPLY_2014Feb22_1
4_58_30.log (no errors)
Patch 17552800 apply (pdb PDB$SEED): SUCCESS
logfile:
/u01/app/oracle/product/12.1.0.1/db_2/sqlpatch/17552800/17552800_apply_CDB03_PDBSEE
D_2014Feb22_14_58_36.log (no errors)
catbundle generate logfile:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_CDB03_PDBSEED_GENERATE_2014Feb2
2_14_58_38.log (no errors)
catbundle apply logfile:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_CDB03_PDBSEED_APPLY_2014Feb22_1
4_58_42.log (no errors)
Patch 17552800 apply (pdb PDB_APP01): SUCCESS
logfile:
/u01/app/oracle/product/12.1.0.1/db_2/sqlpatch/17552800/17552800_apply_CDB03_PDB_AP
P01_2014Feb22_14_58_43.log (no errors)
catbundle generate logfile:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_CDB03_PDB_APP01_GENERATE_2014Fe
b22_14_58_45.log (no errors)
catbundle apply logfile:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_CDB03_PDB_APP01_APPLY_2014Feb22
_14_58_50.log (no errors)
SQL Patching tool complete on Sat Feb 22 14:59:07 2014

Page 62

Query dba_registry_sqlpatch view, verify that the Status for the PSU APPLY is "SUCCESS".
SQL>
SQL>
SQL>
from

set linesize 100


column description format A10
select patch_id, action, status, substr(description,1,10)
dba_registry_sqlpatch;

PATCH_ID ACTION
STATUS
SUBSTR(DESCRIPTION,1,10)
---------- --------------- --------------- ---------------------------------------17552800 APPLY
SUCCESS
bundle:PSU

For any other status, refer to the following My Oracle Support note for additional
information and actions: Document 1609718.1 What to do if the status of a datapatch
action was not SUCCESS.
Review the patch history applied:
SQL> column version format A10
SQL> column bundle_series format A10
SQL> column comments format A20
SQL> select to_char(action_time, 'DD-MM-YY') atime, version, comments
from registry$history;
ATIME VERSION
COMMENTS
-------- ------------------------------ -------------------24-05-13 12.1.0.1
Patchset 12.1.0.0.0
22-02-14 12.1.0.1
PSU 12.1.0.1.2
22-02-14 12.1.0.1
PSU 12.1.0.1.2

Check the following log files in $ORACLE_HOME/sqlpatch/17552800 directory, where


database SID is the database SID, CDB name is the name of the multitenant container
database, and timestamp is of the form YYYYMMMDD_HH_MM_SS.
[oracle@db12cvm1 OPatch]$ ls -la $ORACLE_HOME/sqlpatch/17552800/
total 28
drwxr-xr-x. 2 oracle oinstall 4096 Feb 22 14:58 .
drwxr-xr-x. 3 oracle oinstall 4096 Feb 21 10:07 ..
-rw-r--r--. 1 oracle oinstall 1518 Feb 22 14:58
17552800_apply_CDB03_CDBROOT_2014Feb22_14_58_27.log

Page 63

-rw-r--r--. 1 oracle oinstall 1520 Feb 22 14:58


17552800_apply_CDB03_PDB_APP01_2014Feb22_14_58_43.log
-rw-r--r--. 1 oracle oinstall 1518 Feb 22 14:58
17552800_apply_CDB03_PDBSEED_2014Feb22_14_58_36.log
-rw-r--r--. 1 oracle oinstall 2214 Jan 3 05:21 17552800_apply.sql
-rw-r--r--. 1 oracle oinstall 2240 Jan 3 05:21 17552800_rollback.sql

Look that the PSU was applyied to the CDB and PDB as well. In addition, you can check the
log files for catbundle in $ORACLE_HOME/cfgtoollogs/catbundle or
$ORACLE_BASE/cfgtoollogs/catbundle for any errors, where TIMESTAMP is of the form
YYYYMMMDD_HH_MM_SS:
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log

Page 64

8 Create a PDB Full Clone into new CDB


In this section you will create a full clone of pdb1 using the COPY Method and then apply
the new PSU since PDB11 is connected to CDB1 which doesn't have the latest PSU.
Unplug pdb1 from cdb1:
. oraenv
<cdb1>
sqlplus / as sysdba
SQL> alter pluggable database PDB11 close immediate;
Pluggable database altered.
SQL> alter pluggable database PDB11 unplug into '/home/oracle/pdb11.xml';
Pluggable database altered.
SQL> drop pluggable database PDB11 keep datafiles;
Pluggable database dropped.
SQL> exit

Now use the data files of the unplugged PDB to plug the PDB into the CDB and copy the
data files to a new location, but first review the current location of the datafiles from the
XML Manifest, there is a directory named with the guid of the PDB:
$ cat /home/oracle/pdb11.xml| grep path
<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
system_98zldmcb_.dbf</path>
<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
sysaux_98zldm8q_.dbf</path>
<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
temp_98zlg781_.dbf</path>
<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
users_98zlgq7b_.dbf</path>
<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
soe_98zm1nfb_.dbf</path>

Page 65

<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
sh_98znt6cb_.dbf</path>
<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
pdb11_us_9hm83w3b_.dbf</path>
<path>/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_
pdb11_te_9hm8dxht_.tmp</path>

Create a simple backup to later restore the files to their original CDB
$ zip -r /home/oracle/pdb11.zip
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A
adding: u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/ (stored 0%)
adding: u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/
(stored 0%)
adding:
u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sysaux_
98zldm8q_.dbf (deflated 79%)
adding:
u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_pdb11_u
s_9hm83w3b_.dbf (deflated 100%)
adding:
u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_soe_98z
m1nfb_.dbf (deflated 78%)
adding:
u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_system_
98zldmcb_.dbf (deflated 82%)
adding:
u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sh_98zn
t6cb_.dbf (deflated 68%)
adding:
u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_users_9
8zlgq7b_.dbf (deflated 100%)

Now that you know where is the source directory located, create the target directory and
connect to CDB03 in order to plug the new PDB_APP02.
$ mkdir /u01/app/oracle/oradata/CDB03/PDB_APP02
$ . oraenv
[enter CDB03 at the prompt]
$ sqlplus / as sysdba
SQL> create pluggable database CDB_APP02 AS CLONE using '/home/oracle/pdb11.xml'
COPY
file_name_convert
=('/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A');

Page 66

ERROR at line 1:
ORA-01276: Cannot add file
/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sy
stem_98zldmcb_.dbf. File has an Oracle Managed Files file name.

Because this PDB was created using managed files you will have to specify each datafile to
move to the new Managed Directory. Since we are not creating a clone, the GUID remains
the same:
SQL> create pluggable database PDB_APP02
using '/home/oracle/pdb11.xml'
NOCOPY ;
SQL>
create pluggable database CDB_APP02
using '/home/oracle/pdb11.xml'
COPY file_name_convert = (
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_system_98zldmcb_.dbf',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_system_98zldmcb_.dbf'
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sysaux_98zldm8q_.dbf',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sysaux_98zldm8q_.dbf',
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_users_98zlgq7b_.dbf',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_users_98zlgq7b_.dbf',
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_soe_98zm1nfb_.dbf',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_soe_98zm1nfb_.dbf',
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sh_98znt6cb_.dbf',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sh_98znt6cb_.dbf',
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_pdb11_us_9hm83w3b_.dbf',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_pdb11_us_9hm83w3b_.dbf',
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_temp_98zlg781_.dbf',
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_temp_98zlg781_.dbf'
);

create pluggable database olakits from ola


file_name_convert =
(
+DATA/PCDB/E4EC78AE66805408E04332C8A8C0160B/DATAFILE/system.273.829388755,+DATA/
PCDB/OLAKITS/DATAFILE/system01.dbf,
+DATA/PCDB/E4EC78AE66805408E04332C8A8C0160B/DATAFILE/users.268.829388341,+DATA/P
CDB/OLAKITS/DATAFILE/users01.dbf,
+DATA/PCDB/E4EC78AE66805408E04332C8A8C0160B/DATAFILE/sysaux.272.829388715,+DATA/
PCDB/OLAKITS/DATAFILE/sysaux01.dbf,
+DATA/PCDB/E4EC78AE66805408E04332C8A8C0160B/DATAFILE/edge_010_data.266.829388045,
+DATA/PCDB/OLAKITS/DATAFILE/edge_01.dbf,
+DATA/PCDB/E4EC78AE66805408E04332C8A8C0160B/DATAFILE/apex_space.271.829388439,+D
ATA/PCDB/OLAKITS/DATAFILE/apex_space01.dbf,
/u00/oracle/oradata/PCDB/OLA/temp01.dbf, +DATA/PCDB/OLAKITS/TEMPFILE/temp01.dbf
);

Page 67

SQL> select guid, name from v$pdbs where name='PDB_APP02';


GUID
NAME
-------------------------------- -----------------------------EBCB85864E6B12DCE0430F02000AC14A PDB_APP02

Verify the status and open mode of the plugged PDB and open it.
SQL> show pdbs
CON_ID CON_NAME
OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ---------2 PDB$SEED
READ ONLY NO
3 PDB_APP01
READ WRITE NO
4 PDB_APP02
MOUNTED

List the datafiles, becasue of the NOCOPY clause, all the files still remain in the original
CDB directory, we will move them later.
SQL> alter session set container=PDB_APP02;
Session altered.
SQL> set linesize 100
SQL> select name from v$datafile;
NAME
---------------------------------------------------------------------------------------------------/u01/app/oracle/oradata/CDB03/undotbs01.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_system_98zldmcb_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sysaux_98zldm8q_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_users_98zlgq7b_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_soe_98zm1nfb_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sh_98znt6cb_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_pdb11_us_9hm83w3b_.dbf
SQL> mkdir -p /u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile
SQL> ALTER DATABASE MOVE DATAFILE
'/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_system_98zldmcb_.dbf'
TO
'/u01/app/oracle/oradata/CDB03/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_system_98zldmcb_.dbf';

Create the target directory target directory if it's note already created and move the
datafiles while the PDF is mounted, this will be faster than executing it on read-write
mode.

Page 68

SQL>
SQL> select name from v$datafile where con_id=4;
NAME
---------------------------------------------------------------------------------------------------/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_system_98zldmcb_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sysaux_98zldm8q_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_users_98zlgq7b_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_soe_98zm1nfb_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_sh_98znt6cb_.dbf
/u01/app/oracle/oradata/CDB1/EBCB85864E6B12DCE0430F02000AC14A/datafile/o1_mf_pdb11_us_9hm83w3b_.dbf

8.1 Delete CDB03 with RMAN


SQL> drop pluggable database PDB_APP02 including datafiles;
Pluggable database dropped.

Page 69

8.2 In Place PSU Apply


First upgrade Opatch and Install the PSU on db_1 oracle home.
As Post-Installation Instructions, follow these steps to load the modified SQL files into the
database repository for each CDB running on the Oracle home being patched, start the
corresponding container and run the datapatch utility.
$ . oraenv
[enter CDB01 at the prompt]
$ sqlplus / as sysdba
SQL> startup
SQL> exit
$ cd $ORACLE_HOME/OPatch
$ ./datapatch -verbose

The datapatch utility executes the necessary apply scripts to load the modified SQL files
into the database. An entry will be added to the dba_registry_history and
dba_registry_sqlpatch views reflecting the patch application. In the dba_registry_sqlpatch
view, verify the Status for the APPLY is "SUCCESS".
For any other status, refer to the following My Oracle Support note for additional
information and actions: Document 1609718.1 What to do if the status of a datapatch
action was not SUCCESS.
Check the following log files in $ORACLE_HOME/sqlpatch/17552800/ for errors:
17552800_apply_<database SID>_<CDB name>_<timestamp>.log

Where database SID is the database SID, CDB name is the name of the multitenant
container database, and timestamp is of the form YYYYMMMDD_HH_MM_SS.
In addition, you can check the log files for catbundle in
$ORACLE_HOME/cfgtoollogs/catbundle or $ORACLE_BASE/cfgtoollogs/catbundle.
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log

NOTE: If you are using the Oracle Recovery Manager, the catalog needs to be upgraded.
Page 70

Enter the following command to upgrade it:


$ rman catalog username/password@alias
RMAN> UPGRADE CATALOG;
There are no actions required for databases that have been upgraded or created after
installation of PSU 12.1.0.1.2.

Page 71

Você também pode gostar