Академический Документы
Профессиональный Документы
Культура Документы
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n ul Ka lic
hs a
A
Oracle Database 12c: RAC
Administration
Activity Guide
D81250GC11
Edition 1.1 | April 2015 | D90918
Learn more from Oracle University at oracle.com/education/
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Disclaimer
This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and
print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way.
Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display,
perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization
of Oracle.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
The information contained in this document is subject to change without notice. If you find any problems in the document, please
report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United
States Government, the following notice is applicable:
Publishers
Syed Imtiaz Ali, Joseph Fernandez
o m ui
Practices for Lesson 6: Overview ...................................................................................................................6-2
c
a il ent G
ฺ
Practice 6-1: Configuring ARCHIVELOG Mode .............................................................................................6-3
Practice 6-2: Configuring RMAN and Performing Parallel
@ gmBackups t u d
...............................................................6-7
b
Practices for Lesson 7: Global Resource Management d i s S
Concepts ..............................................................7-1
i r h
h k ab se t
Practices for Lesson 7: Overview ...................................................................................................................7-2
a t
Practice 7-1: Buffer Cache Fusion u
.................................................................................................................7-3
t o
Practice 7-2: Row Cache
i m
r (CacheeCoordination
se for Procedure and Packages ........................................................7-28
Coordination for Sequences ..................................................................................7-12
b
Practice 7-3: Library
a n
Practice K
u l lic Coordination ...................................................................................................7-34
7-4: Global Enqueue
ble
fe r a
an s
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
For operating system (Linux) usernames and passwords, see the following:
• If you are attending a classroom-based or live virtual class, ask your instructor or LVC
producer for OS credential information.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
• If you are using a self-study format, refer to the communication that you received from
Oracle University for this course.
For product-specific credentials used in this course, see the following table:
Product-Specific Credentials
Product/Application Username Password
ble
Enterprise Manager Database Express SYS oracle_4U
fe r a
ans
Database (orcl) SYS oracle_4U
n - t r
Database (orcl) no
SYSTEM
a
oracle_4U
Database (orcl) ASMSNMP
h a s oracle_4U
DBSNMP m
) i d eฺ
Database (orcl)
l ฺ c o G u oracle_4U
Database (orcl) JMW i
a den t JMW
g m tu
d @ s S
a b irb thi
t h k u se
( m a to
e
a bir icens
u l K l
n
Ahsa
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 1: Grid
Lesson
m )
Infrastructure
o u i de
Overview
a ilฺc ent G
@ gm
Chapter 1 d
tu
d s S
a b irb thi
t h k u se
( m a to
e
a bir icens
n u lK l
hs a
A
Practices Overview
In this practice, you will install and configure a new Cluster. You will install it to three nodes:
host01, host02, and host03.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
1. As the root user, confirm your three nodes are up and running with the xm list
command. Then restart the NAMED service to ensure viability and availability of the service
for the software installation.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
[vncuser@classroom_pc ~]$ su –
) a
h deฺ
[root@classroom_pc ~]#
c o m u i
ฺ
ail dent G
2. Open an ssh session as root to host01.
m
g Start the
tulocal naming cache daemon on all
d @ s S
a b irb nscd
three cluster nodes with the service
thicommand.
nscd start command. To make sure nscd starts
at reboot, execute the chkconfig
h k u s e Perform these steps on all three of
your nodes. a t o
t~]#
i ( m
r ens
[root@classroom_pc e ssh host01
b
u l Ka lic password:
root@host01's
[root@host01 ~]#
fi
PATH=$PATH:$HOME/bin
export PATH
umask 022
Ah
EUID=`id -u`
UID=`id -ru`
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
if [ -x /usr/bin/id ]; then
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
INPUTRC=/etc/inputrc
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
ble
fe r a
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
ans
umask 022
n - t r
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384 a no
ulimit -n 65536 h a s ฺ
else
o m )
u i de
ulimit -u 16384 -n 65536
a ilฺc ent G
gm tud
fi
fi
b d @ s S
unset i
i r h i
unset pathmunge
h k ab se t
[root@host01 m a t o u
t cat /stage/RAC/labs/less_01/limits.conf
r ( ense
~]#
b i
#
u l Ka -- priority
lic - max - the priority to run user process with
a
s #n
# locks number of file locks the user can hold
Ah
- sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues
# - nice - max nice priority allowed to raise to
# - rtprio - max realtime priority
#<domain> <type> <item> <value>
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
# End of file
oracle soft nofile 131072
oracle hard nofile 131072
oracle soft nproc 131072
oracle hard nproc 131072
oracle soft core unlimited
5. Next, establish a terminal session connected to host01 as the grid OS user. Ensure that
you specify the –X option for ssh to configure the X environment properly for the grid
user.
[root@classroom_pc ~]$ ssh –X grid@host01
grid@host01's password:
[grid@host01 ~]$
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
b
9. On the Select Installation Typei r
page, t h
choose Advanced installation and click Next.
k a e
a th to us
i r (m nse
l K ab lice
a n u
s
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
16. On the Create ASM Disk Grouprb d click
screen, i s S Discovery Path to customize the ASM
Change
Disk Discovery Path.
i
ab se t h
t h k u
m a t o
b i r ( ense
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
• /dev/asmdisk1p12
• /dev/asmdisk1p2
• /dev/asmdisk1p3
• /dev/asmdisk1p4
• /dev/asmdisk1p5
• /dev/asmdisk1p6
• /dev/asmdisk1p7
ble
fe r a
Select Normal for the Redundancy and click Next to continue. ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
i r h
t click Next to accept the default setting (Do not use
h k ab screen,
20. On the Failure Isolation Support
s e
IPMI).
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S click Next to proceed.
i r h
25. On the Root script execution configuration screen,
h k ab se t
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
29. Examine the Summary screen. When
b S Install to begin the installation. Oracle
d ready,isclick
b i
Grid Infrastructure release 12.1 rwill nowt h
install on the cluster nodes.
k a e
a th to us
i r (m nse
l K ab lice
a n u
s
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i deand displays the
lฺcroot nterminal
30. Toward the end of the installation, Oracle Universal
to ithe
Execute Configuration scripts dialog box. Go a
Installer
t
pauses
G opened earlier on host01
and execute the orainstRoot.sh scripts u denodes. When finished, execute the
gmon alltthree
root.sh scripts on all three nodesb @
dalso. is S
b i r th
k a e
a th to us
i r (m nse
l K ab lice
a n u
s
Ah
u l K ORACLE_HOME=
l /u01/app/12.1.0/grid
san
Ah Enter the full pathname of the local bin directory:
[/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
a t t o u
Successful addition of voting disk
m
r ( ense
c1f6a060817e4fcebfcea451c7b23364.
i
b
l Ka
Successfully replaced voting disk group with +DATA.
u lic
CRS-4256: Updating the profile
a n
Ahs CRS-4266: Voting file(s) successfully replaced
## STATE File Universal Id File Name Disk
group
-- ----- ----------------- --------- ---------
1. ONLINE 725fb3575cf44f7cbf69f841110f675d (/dev/asmdisk1p1)
[DATA]
2. ONLINE a4f5ddfc663a4f5ebfa319690cd60fb0 (/dev/asmdisk1p10)
[DATA]
3. ONLINE c1f6a060817e4fcebfcea451c7b23364 (/dev/asmdisk1p11)
[DATA]
Located 3 voting disk(s).
CRS-2791: Starting shutdown of Oracle High Availability Services-
managed resources on 'host01'
CRS-2673: Attempting to stop 'ora.crsd' on 'host01'
CRS-2677: Stop of 'ora.crsd' on 'host01' succeeded
CRS-2673: Attempting to stop 'ora.ctssd' on 'host01'
CRS-2673: Attempting to stop 'ora.mdnsd' on 'host01'
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
@ gm tud
b
CRS-2672: Attemptingirto
S
dstart is'ora.asm'
a b e t h on 'host01'
CRS-2676: Start kof 'ora.asm'
a th totousstarton'ora.DATA.dg'
'host01' succeeded
( m
CRS-2672: Attempting
e on 'host01'
a bir iStart
CRS-2676:
c e nsof 'ora.DATA.dg' on 'host01' succeeded
u l K
2015/01/22l 11:06:44 CLSRSC-325: Configure Oracle Grid
sa n Infrastructure for a Cluster ... succeeded
Ah
[root@host01 ~]# ssh host02 /u01/app/12.1.0/grid/root.sh
Performing root user operation.
u l K
managed
liAttempting to stop 'ora.drivers.acfs' on 'host02'
'host02'
sa n CRS-2673:
Ah CRS-2677:
CRS-2793:
Stop of 'ora.drivers.acfs' on 'host02' succeeded
Shutdown of Oracle High Availability Services-managed
resources on 'host02' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Starting Oracle High Availability Services-managed
resources
CRS-2672: Attempting to start 'ora.mdnsd' on 'host02'
CRS-2672: Attempting to start 'ora.evmd' on 'host02'
CRS-2676: Start of 'ora.mdnsd' on 'host02' succeeded
CRS-2676: Start of 'ora.evmd' on 'host02' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'host02'
CRS-2676: Start of 'ora.gpnpd' on 'host02' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on 'host02'
CRS-2676: Start of 'ora.gipcd' on 'host02' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'host02'
CRS-2676: Start of 'ora.cssdmonitor' on 'host02' succeeded
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
'host02'
CRS-2672: Attempting to start 'ora.ctssd' on 'host02'
CRS-2676: Start of 'ora.ctssd' on 'host02' succeeded
CRS-2676: Start of 'ora.cluster_interconnect.haip' on 'host02'
succeeded
CRS-2672: Attempting to start 'ora.asm' on 'host02'
CRS-2676: Start of 'ora.asm' on 'host02' succeeded
CRS-2672: Attempting to start 'ora.storage' on 'host02'
ble
CRS-2676: Start of 'ora.storage' on 'host02' succeeded
fe r a
CRS-2672: Attempting to start 'ora.crf' on 'host02'
ans
CRS-2676: Start of 'ora.crf' on 'host02' succeeded
n - t r
o
CRS-2672: Attempting to start 'ora.crsd' on 'host02'
s an
CRS-2676: Start of 'ora.crsd' on 'host02' succeeded
) ha deฺ
c o m ui
CRS-6017: Processing resource auto-start for servers: host02
il ent G
ฺ
CRS-2672: Attempting to start 'ora.net1.network' on 'host02'
a
gm tud
CRS-2676: Start of 'ora.net1.network' on 'host02' succeeded
@
b d i s S
CRS-2672: Attempting to start 'ora.ons' on 'host02'
i r h
h k ab se t
CRS-2676: Start of 'ora.ons' on 'host02' succeeded
a t t o u
CRS-2673: Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on
'host01'
i m
r ( ense
b
l Ka
CRS-2677: Stop of 'ora.LISTENER_SCAN1.lsnr' on 'host01' succeeded
u lic
CRS-2673: Attempting to stop 'ora.scan1.vip' on 'host01'
a n
Ahs CRS-2677: Stop of 'ora.scan1.vip' on 'host01' succeeded
CRS-2672: Attempting to start 'ora.scan1.vip' on 'host02'
CRS-2676: Start of 'ora.scan1.vip' on 'host02' succeeded
CRS-2672: Attempting to start 'ora.LISTENER_SCAN1.lsnr' on
'host02'
CRS-2676: Start of 'ora.LISTENER_SCAN1.lsnr' on 'host02'
succeeded
CRS-6016: Resource auto-start has completed for server host02
CRS-6024: Completed start of Oracle Cluster Ready Services-
managed resources
CRS-4123: Oracle High Availability Services has been started.
2015/01/22 11:18:37 CLSRSC-343: Successfully started Oracle
Clusterware stack
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/12.1.0/grid
a t
Analyzer (TFA) Collector.
t o u
i m
r ( 11:31:29
se CLSRSC-4002: Successfully installed
b e n
Ka FilelicAnalyzer (TFA) Collector.
2015/01/22 Oracle
n u l
Trace
sa
Ah 2015/01/22 11:31:33 CLSRSC-363: User ignored prerequisites during
installation
n u lK
CRS-2676: lStart of 'ora.asm' on 'host03' succeeded
hs a CRS-2672: Attempting to start 'ora.storage' on 'host03'
A CRS-2676: Start of 'ora.storage' on 'host03' succeeded
CRS-2672: Attempting to start 'ora.crf' on 'host03'
CRS-2676: Start of 'ora.crf' on 'host03' succeeded
CRS-2672: Attempting to start 'ora.crsd' on 'host03'
CRS-2676: Start of 'ora.crsd' on 'host03' succeeded
CRS-6017: Processing resource auto-start for servers: host03
CRS-2673: Attempting to stop 'ora.LISTENER_SCAN2.lsnr' on
'host01'
CRS-2672: Attempting to start 'ora.net1.network' on 'host03'
CRS-2676: Start of 'ora.net1.network' on 'host03' succeeded
CRS-2672: Attempting to start 'ora.ons' on 'host03'
CRS-2677: Stop of 'ora.LISTENER_SCAN2.lsnr' on 'host01' succeeded
CRS-2673: Attempting to stop 'ora.scan2.vip' on 'host01'
CRS-2677: Stop of 'ora.scan2.vip' on 'host01' succeeded
CRS-2672: Attempting to start 'ora.scan2.vip' on 'host03'
a n u
Ahs 2015/01/22 11:40:22 CLSRSC-325: Configure Oracle Grid
Infrastructure for a Cluster ... succeeded
[root@host01 ~]#
ble
fe r a
ans
n - t r
a no
h
33. After configuration completes you will see the following message: a s ฺ
o m
“The installation of Oracle Grid Infrastructure for a Cluster u de
)was successful”
i
Click Close to close Oracle Universal Installer.ailฺ
c t G
n
@ gm tude
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
[grid@host01 ~]$
35. Now check the status of the cluster. Ensure that all the listed services are online on all the
cluster nodes.
[grid@host01 ~]$ crsctl check cluster -all
**************************************************************
host01:
CRS-4537: Cluster Ready Services is online
ble
CRS-4529: Cluster Synchronization Services is online
fe r a
ans
CRS-4533: Event Manager is online
n - t r
**************************************************************
o
host02:
s an
CRS-4537: Cluster Ready Services is online
) ha deฺ
CRS-4529: Cluster Synchronization Services is online
c o m ui
CRS-4533: Event Manager is online a il ent G
ฺ
gm tud
**************************************************************
@
b d i s S
host03:
i r h
k ab se t
CRS-4537: Cluster Ready Services is online
h
a t t o u
CRS-4529: Cluster Synchronization Services is online
i m
r ( ense
b
CRS-4533: Event Manager is online
n u l Ka lic
**************************************************************
hs a [grid@host01 ~]$
A
36. List the Clusterware resources. Ensure that all the Clusterware resources are running as
shown in the following output.
[grid@host01 ~]$ crsctl status resource -t
----------------------------------------------------------------
Name Target State Server State details
----------------------------------------------------------------
Local Resources
----------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE host01 STABLE
ONLINE ONLINE host02 STABLE
ONLINE ONLINE host03 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE host01 STABLE
a n u 192.168.2.1
Ahs ora.cvu
01,STABLE
ora.scan3.vip
1 ONLINE ONLINE host03 STABLE
----------------------------------------------------------------
[grid@host01 ~]$
37. Stop and disable the ora.cvu resource using SRVCTL to conserve disk space.
[grid@host01 ~]$ srvctl stop cvu
ble
fe r a
[grid@host01 ~]$ srvctl disable cvu
ans
n - t r
[grid@host01 ~]$
a no
h a s ฺ
38. Next, you will create another ASM disk group to host the)Fast Recovery
o m u i de Area (FRA). Start
the ASM Configuration Assistant (asmca).
a ilฺc ent G
[grid@host01 ~]$ asmca
@ gm tud
b d i s S
39. After the ASM Configurationb i r t h
h k a Assistant
s e appears, click Create.
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
l
41. After
u Ktheadisk group
lic creation process completes you will see a dialog window indicating that
santhe disk group has been created. Click OK to proceed.
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺcConfiguration
43. Click Yes to confirm that you want to quit the ASM
n t G Assistant.
@ gm tude
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
u l Ka lic
anClose all terminal windows opened for these practices.
s44.
Ah
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 2: RAC
Lesson
Databases o m ) i de &
Overview
u
a ilฺc ent G
Architecture
@ gm tud
b d Chapter
i s S 2
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 3:
Lesson
Installingo m )
and u i de
Configuring
a
Oracleilฺc RAC
n t G
@ gm tude
b d Chapter
i s S 3
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice you will install Oracle Database 12c.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. Establish an ssh connection to host01 using the –X option as the oracle user.
[vncuser@classsroom_pc ~]$ ssh -X oracle@host01
oracle@host01's password:
[oracle@host01 ~]$
h a s ฺ
Checking monitor: must be configured to display at least 256 colors.
) de
Actual 16777216 Passed
o m u i
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-
05-22_03-35-08PM. Please wait ...
a ilฺc ent G
@ gm tud
3. On the Confirm Security Updates b d deselect
screen, i s S “I wish to receive security updates” and
i r h
twill not configure security updates.
h k ab thatsyou
click Next. Click Yes to confirm
e
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
i r
b screen,
5. On the Grid Installation Options h
tclick Next to accept the default selection (Oracle
h k adatabase s e
Real Application Clusters
a t t o u installation).
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
7. Enter the password for the oracle
b duser inithe
s SOS Password field and click Test to confirm
b i r
that SSH connectivity is configured for t
theh cluster. Your laboratory environment is
k a e
preconfigured with thehrequired SSH
this. Click OK tom a t
continue. t o us connectivity so you will next see a dialog confirming
b i r ( ense
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
i r h
t click Next to accept the default selection
ab sscreen,
9. On the Select Product Languages
h k e
(English). a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
11. On the Specify Installation Locationb S Next to accept the default installation
dscreen,isclick
location. The Oracle base a i r t h
b bee/u01/app/oracle
should and the Software location should
t h k u s
be /u01/app/oracle/product/12.1.0/dbhome_1.
m a t o
b i r ( ense
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
i r h
t a series of prerequisite checks is performed.
13. On the System Prerequisite
h k abCheckssepage,
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
b i r t h
aa
15. The installer will display k dialog boxs e
for executing the fixup scripts. Follow the instructions
and execute them on a h
thost01, o u and host03 as the root user as shown below.
m t host02,
b i r ( ense
u l Ka lic
san
Ah
[root@host01 ~]#
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
16. When the scripts have been executed on all the three nodes, click the OK button.
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
17. On the Perform Prerequisite Checks page,
@ gmclick Ignore
t ud All and then click Next to continue.
d S
b i r some ofththeisprerequisites and continue the installation.
Click Yes when asked to ignore b
t h ka use
( m a to
e
a bir icens
u l K l
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b
19. Oracle Database release 12.1 software S on the cluster. The Install Product
d nowisinstalls
screen follows the course a ofb
i r t h
the installation.
h k u s e
a t t o
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
t r a ns
From your root terminal session on host01, execute the root scripts ono n -
host01,
host02, and host03. Press the Enter key when you are prompted
s afornthe local bin
directory location as shown below.
) ha deฺ
o m ui
[root@host01 ~]# /u01/app/oracle/product/12.1.0/dbhome_1/root.sh
c
Performing root user operation foraiOracle l ฺ n t
12c G
@ gm tude
b dvariables
i s Sare set as:
The following environment
i r h
k
ORACLE_OWNER= oracle
h ab se t
ORACLE_HOME= a t o u
t /u01/app/oracle/product/12.1.0/dbhome_1
i m
r ( ense
b
l
Enter
u Kathe full lic pathname of the local bin directory:
san
[/usr/local/bin]:
[/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.
a t t o u
i r m
( nse of the local bin directory:
Enter the full pathname
l ab ce
[/usr/local/bin]:
contentsli of "dbhome" have not changed. No need to overwrite.
K
a n u contents of "oraenv" have not changed. No need to overwrite.
The
s The
Ah The contents of "coraenv" have not changed. No need to overwrite.
[root@host01 ~]#
ble
fe r a
ans
n - t r
a no
h a s ฺ
m
22. After configuration completes you will see the Finish screen. e to close Oracle
) ClickidClose
o u
Universal Installer.
a ilฺc ent G
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
Overview
In this practice you will create an Oracle RAC database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. Using the same oracle terminal session from the previous practice, change directory to
/u01/app/oracle/product/12.1.0/dbhome_1/bin/ and execute dbca.
[oracle@host01 database]$ cd
/u01/app/oracle/product/12.1.0/dbhome_1/bin
[oracle@host01 bin]$ ./dbca
2. On the Database Operation screen, click Next to accept the default (Create Database).
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
4. an
On the Database Template screen, click Next to accept the default settings for a Policy-
s
Managed RAC Database using the General Purpose template).
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b S for the Server pool Name and set its
d specifyisorcldb
6. On the Database Placement screen,
cardinality to 3. Click Nexta
i r
tobproceed. t h
h k u s e
a t t o
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
i r h
t Use the Same Administrative Passwords for All
8. On the Database Credentials
h k abscreen,s e select
Accounts and enterathet password
t o ufor the SYS, SYSTEM, and DBSNMP accounts. Then
m
r ( ense
click Next to continue.
i
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
d database
A dialog box regarding policy-managed
b i s S instance placement on the local node
i r t h
h k ab sis edisplayed.
and sample schema configuration Click Yes to continue.
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
b d i s S
i r h
t Parameters screen, select Use Unicode
(AL32UTF8) and clickth k btheuInitialization
12. On the Character Sets tab,ain
Next. se
( m a to
e
a bir icens
u l K l
san
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
t are performed.
h k ab checks
14. Wait while a series of prerequisite
s e
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
t the Progress Page.
k abprocess
16. Follow the database creation
h s eon
a t t o u
i m
r ( ense
b
u l Ka lic
san
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r t h
k ab Configuration
18. Click Close to quit the Database
h s e Assistant.
a t to u
( m e
a bir icens
u l K l
san
Ah
[oracle@host01 bin]$
20. Use the srvctl command to check which cluster nodes the database instances are
running.
[oracle@host01 bin]$ srvctl status database -db orcl
Instance orcl_1 is running on node host03
Instance orcl_2 is running on node host01
ble
Instance orcl_3 is running on node host02
fe r a
[oracle@host01 bin]$
ans
n - t r
o
an
21. Close all terminal windows opened for these practices.
s
ha deฺ
)
m ui
c o
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 4:
Lesson
Oracle o m
RAC
) i de
Administration
u
a ilฺc ent G
@ gm t 4d
Chapteru
d S
b i rb this
t h ka use
( m a to
e
a bir icens
n u lK l
hs a
A
Practices Overview
In these practices, you will contrast operating systems, password file authenticated connections,
and Oracle database authenticated connections. You will also learn to stop a complete
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice, you adjust initialization parameters in the SPFILE, and stop and start the ASM
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. Connect to your first node as the oracle user and set up your environment variables by
using the oraenv script.
[vncuser@classroom_pc ~]$ ssh oracle@host01
Password:
[oracle@host01 ~]$ . oraenv
ble
ORACLE_SID = [oracle] ? orcl
fe r a
The Oracle base has been set to /u01/app/oracle
ans
[oracle@host01 ~]$$
n - t r
a no
a s onฺ your machine by
2. Identify all the database instance names that are currently executing
h
using the Linux ps command.
o m )
u i de
a ฺc nt G
Note: All database instances have a mandatoryilbackground process named pmon, and the
instance name will be part of the completem de
g processtuname.
[oracle@host01 ~]$ psbd @ s S -i pmon
i r h
t ?i
-ef | grep
3529 ab 1 0 e
grid
t h k u s 06:45 00:00:16 asm_pmon_+ASM1
grid
m a
15479
t o
1 0 Nov20 ? 00:12:12 mdb_pmon_-MGMTDB
oracle
b i r ( 15813
e n se 1 0 08:02 ? 00:00:18 ora_pmon_orcl_3
u l Ka
oracle c 16483 0 15:24 pts/1 00:00:00 grep -i pmon
li19607
san
Ah 3. Attempt to make a local connection to the orcl_n instance by using SQL*Plus with the
sysdba privilege. This is known as operating system authentication because a password is
not needed. What happens when you are trying to connect to the instance?
[oracle@host01 ~]$ sqlplus / as sysdba
SQL> exit
Disconnected
[oracle@host01 ~]$
Connected to:
ble
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
fe r a
64bit Production
ans
With the Partitioning, Real Application Clusters, Automatic
n - t r
Storage Management, OLAP,
a no
Advanced Analytics and Real Application Testing options
h a s ฺ
o m )
u i de
SQL> exit
a ilฺc12cenEnterprise
tG
Disconnected from Oracle Database
g m tud Edition Release
12.1.0.2.0 - 64bit Production
b d @ Application
s S
With the Partitioning,
b i r Real
t h i Clusters, Automatic
a e
thk toandusReal Application Testing options
Storage Management, OLAP,
a
Advanced Analytics
(m ns~]$
i r
[oracle@host01 e
b e
n l Ka lic
u the values of the environment variables (ORACLE_BASE, ORACLE_HOME,
hs a
5. Display
A ORACLE_SID, and so on) that were defined with the oraenv script in step 1.
[oracle@host01 ~]$ env | grep ORA
ORACLE_SID=orcl
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
[oracle@host01 ~]$
6. Modify the ORACE_SID environment variable to match the actual database instance name
for the orcl database.
[oracle@host01 ~]$ export ORACLE_SID=orcl_3
[oracle@host01 ~]$
2014
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
ble
With the Partitioning, Real Application Clusters, Automatic
fe r a
Storage Management, OLAP,
ans
Advanced Analytics and Real Application Testing options
n - t r
a no
SQL>
h a s ฺ
o m )
u i de
a ilฺc entdynamic
8. Query the instance_name column of the v$instance
G performance view to
m ExittuSQL*Plus
validate the instance that you connectedgwith. d when finished.
d @ S
SQL> select instance_name
b i rb tfrom
h is v$instance;
t h ka use
m
INSTANCE_NAME
( a to
e
bir icens
----------------
a
u l K
orcl_3 l
san
Ah SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
[oracle@host01 ~]$
Overview
In this practice, you will make multiple Oracle database authenticated connections to a
database instance and notice the effects of load-balanced connections.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. From your first node, connected as the oracle user, validate the instance names on each
host.
[oracle@host01 ~]$ srvctl status database -d orcl
Instance orcl_1 is running on node host02
Instance orcl_2 is running on node host03
Instance orcl_3 is running on node host01
ble
[oracle@host01 ~]$
fe r a
t r a ns
2. Connect to a database instance by using SQL*Plus with the system account. o n - This is known
as Oracle database authentication. After it is connected, query the a n
instance_name
column from the v$instance dynamic performance view. a s
m ) h below:
i d eฺ
Note: Your instance names may vary from the oneso
l ฺ c displayed
G u
i t
[oracle@host01 ~]$ sqlplus system@orcl
g ma tuden
b d @ sS
a b i r
SQL*Plus: Release 12.1.0.2.0
e thi Production on Wed Sep 11 16:02:01
thk to us
2014
a
(m(c)ns1982,
i r e 2014, Oracle. All rights reserved.
b
Copyright
e
u l Ka lic
san Enter password: ***** << Password is not displayed
Ah Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
INSTANCE_NAME
----------------
orcl_2
SQL>
SQL> !
[oracle@host01 ~]$ sqlplus system@orcl
ble
Enter password: ***** << Password is not displayed
fe r a
Last Successful login time: Wed Sep 11 2014 16:02:32 +00:00
ans
n - t r
o
Connected to:
s an
64bit Production ) ha deฺ
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
c o m ui
il ent G
ฺ
With the Partitioning, Real Application Clusters, Automatic
a
gm tud
Storage Management, OLAP,
b d @ s S
Advanced Analytics and Real Application Testing options
i r h i
h k ab se tfrom v$instance;
SQL> select instance_name
a t t o u
i m
r ( ense
b
INSTANCE_NAME
u Ka lic
l ----------------
a n
hs
orcl_1
A
SQL>
4. Use the SQL*Plus host command to temporarily exit SQL*Plus and return to the operating
system prompt. Note: SQL*Plus is still running when this is performed. Validate that you are
still on your first node. Repeat the previous step from the operating system prompt to
establish a third SQL*Plus session and database instance connection. What instance name
did you connect to?
SQL> !
[oracle@host01 ~]$ sqlplus system@orcl
SQL*Plus: Release 12.1.0.2.0 Production on Wed Sep 11 16:07:15
2014
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
INSTANCE_NAME
----------------
orcl_3
ble
fe r a
SQL>
ans
n - t r
5. no
Exit the three SQL*Plus sessions that are currently executing on the first node.
a
h a s ฺ
) de Edition Release
SQL> exit
o m u i
12.1.0.2.0 - 64bit Production ilฺc
Disconnected from Oracle Database 12c Enterprise
a n t G
With the Partitioning, Real gm t u
Applicationde Clusters, Automatic
Storage Management, OLAP,
b d @ s S
i
Advanced Analyticsb and Realr h i
t Application Testing options
h k a s e
a t t o u
i m
r ( ense
[oracle@host01 ~]$ exit
b
l Ka lic
exit
a n u
hs
SQL> exit
A Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
[oracle@host01 ~]$ exit
exit
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
[oracle@host01 ~]$
Overview
In this practice, you will use the srvctl utility to stop all resource components executing from a
single Oracle home location.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. Validate that the instances are running on each node of the cluster using the ps command.
[oracle@host01 ~]$ ps -ef|grep -i pmon
grid 3529 1 0 06:45 ? 00:00:18 asm_pmon_+ASM1
oracle 15813 1 0 08:02 ? 00:00:20 ora_pmon_orcl_3
grid 23591 1 0 06:45 ? 00:00:06 mdb_smon_-MGMTDB
oracle 24700 16483 0 16:25 pts/1 00:00:00 grep -i pmon
ble
fe r a
ans
[oracle@host01 ~]$ ssh host02 ps -ef|grep -i pmon
n - t r
no
grid 5973 1 0 07:45 ? 00:00:21 asm_pmon_+ASM2
oracle 7114 1 0 08:01 ? a
00:00:24 ora_pmon_orcl_1
s ฺ
h a
[oracle@host01 ~]$ ssh host03 ps -ef|grep o m u de
) -i ipmon
1 0 13:49 a ? ilฺ
c 00:00:07
t G
oracle 3034
m e n ora_pmon_orcl_2
grid 3682 1 0 13:51
@ g ? tud 00:00:06 asm_pmon_+ASM3
[oracle@host01 ~]$ rb d i s S
i
ab se t h
h k
t helptoforuthe srvctl status home command.
2. Display the syntaxm a
usage
b i r ( ens~]$ e
l K a l ic
[oracle@host01 srvctl status home -help
a n u
s
Ah Displays the current state of of all resources for the Oracle
home.
/u01/app/oracle/product/12.1.0/dbhome_1 -statefile
/tmp/host01_dbhome_state1.dmp -node host01
Database orcl is running on node host01
[oracle@host01 ~]$
4. Display the syntax usage help for the srvctl stop home command.
[oracle@host01 ~]$ srvctl stop home -help
bl e
fe r a
Stops all Oracle clusterware resources that run from the Oracle
n s
home.
n - tra
a no-statefile
Usage: srvctl stop home -oraclehome <oracle_home>
<state_file> -node <node_name> [-stopoption h a s<stop_options>]
ฺ [-
force] )
m uid e
c o
-oraclehome <path>
a il ent Ghome path
ฺ Oracle
-statefile <state_file>
@ gm t u dSpecify a file path for the
srvctl stop home command
b d to
i s S
store the state of the resources
-node <node_name> r
bi e th Node name
k a
-stopoption
a
database.mExamples t o us
th <stop_options> Stop options for the
r ( ensIMMEDIATE,
e of shutdown options are NORMAL,
b i
TRANSACTIONAL,
a or ABORT.
li c
nul K -force Force stop
[oracle@host01 ~]$
[oracle@host01 ~]$
i r (m nse
l K ab lice
a n u
s
Ah
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices )for s ฺ 5:
haLesson
m i e
dPatching
Upgrading o u
and
a ilฺc RAC
n t G
@ gm tude
Oracle
b d Chapter
i s S 5
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
1. Establish an ssh connection using the –X option as the oracle user. Use oraenv to set
the Oracle environment.
[vncuser@classsroom_pc ~]$ ssh -X oracle@host01
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
oracle@host01's password:
ble
2. The patch you will install is 20108098. It is located in /stage/patch/20108098. It fixes
fe r a
an issue with the GV$_SEQUENCES view. Navigate to the directory and take a few moments
ans
to view the README file, particularly Section I (Prerequisites) and Section II (Installation).
n - t r
[oracle@host01 ~]$ cd /stage/patch/20108098
a no
h a s ฺ
[oracle@host01 20108098]$ ls -al
o m )
u i de
total 24
a ilฺc20e20:05
n t G.
drwxrwxr-x 4 root root
@ gm tu22
4096 Jan
d 18:31 ..
drwxr-xr-x 3 oracle oinstall
d S
4096 Jan
is Jan 20 20:05 etc
drwxr-xr-x 3 root b i
root rb 4096
t h
drwxr-xr-x 3 roott h karootuse 4096 Jan 20 20:05 files
-rw-rw-r-- (1m
a
root erootto 5855 Jan 20 20:05 README.txt
i r n s
l K ab lice20108098]$ cat README.txt
a n u
[oracle@host01
s
Ah Oracle Database 12c Release 12.1.0.2.0
ORACLE DATABASE Patch for Bug# 20108098 for Linux-x86-64 Platforms
This document describes how you can install the ORACLE DATABASE
interim patch for bug# 20108098 on your Oracle Database 12c
Release 12.1.0.2.0
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
(I) Prerequisites
--------------------
Before you install or deinstall the patch, ensure that you meet the
following requirements:
gm tud
12.1.0.2.0,then download it from patch#
release.
b d @ s S
i r h i
t OPatch documentation, including any
k
For information
h ab abouts e
known issues, a see o u Support Document 293369.1 OPatch
t My tOracle
documentation
i m
r ( ense
list:
b
u l Ka lic
https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=22
san4346.1
Ah
3. Ensure that you set (as the home user) the ORACLE_HOME
environment variable to the Oracle home.
ble
fe r a
7. (Only for Installation) Determine whether any currently
ans
installed interim patches conflict with this patch 20108098 as
n - t r
no
shown below:
$ cd <PATCH_TOP_DIR>/20108098
s ฺa
h a
) de
$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./
o m u i
The report will indicate the a ilฺcpatches
n t Gthat conflict with
this patch and the patches forgm which u
t decurrent 20108098 is a
the
superset.
b d @ s S
i r h i
Note: thk
ab se t
a t o u
i r
When m
( nse
OPatch starts, it validates the patch and ensures that
a
there areb iceno conflicts with the software already installed in the
u l K
ORACLE_HOME. l OPatch categorizes conflicts into the following types:
san - Conflicts with a patch already applied to the
Ah ORACLE_HOME that is a subset of the patch you are trying to apply
- In this case, continue with the patch installation because the
new patch contains all the fixes from the existing patch in the
ORACLE_HOME. The subset patch will automatically be rolled back
prior to the installation of the new patch.
- Conflicts with a patch already applied to the
ORACLE_HOME - In this case, stop the patch installation and contact
Oracle Support Services.
8. Ensure that you shut down all the services running from the
Oracle home.
Note:
- For a Non-RAC environment, shut down all
the services running from the Oracle home.
- For a RAC environment, shut down all the
services (database, ASM, listeners, nodeapps, and CRS daemons)
running from the Oracle home of the node you want to patch. After
(II) Installation
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
-----------------
To install the patch, follow these steps:
$ cd <PATCH_TOP_DIR>/20108098
ble
fe r a
ans
$ opatch apply
n - t r
2. a no
Verify whether the patch has been successfully installed by
running the following command: h a s ฺ
o m )
u i de
$ opatch lsinventory
a ilฺc ent G
@ gm tud
3. Start the services
i r b d from istheSOracle home.
a b e th
k
th to us
a
(m nse
i r
(III) Deinstallation
K ab lice
----------------------
l
a n u
Ensure to follow the Prerequsites (Section I). To deinstall the
s patch, follow these steps:
Ah
1. Deinstall the patch by running the following command:
3. Ensure that you verify the Oracle Inventory and compare the
output with the one run before the patch installation and re-apply
any patches that were rolled back as part of this patch apply. To
verify the inventory, run the following command:
$ opatch lsinventory
-------------------------------------------------------------------
Copyright 2015, Oracle and/or its affiliates. All rights reserved.
-------------------------------------------------------------------
[oracle@host01 20108098]$
3. Make sure that your PATH definition points to the make, ar, ld and nm executables. In our
practice environment, they are located in /usr/bin.
[oracle@host01 ~]$ which make ar ld nm ble
fe r a
/usr/bin/make
ans
/usr/bin/ar
n - t r
/usr/bin/ld
a no
/usr/bin/nm
h a s ฺ
[oracle@host01 ~]$ echo $PATH
o m )
u i de
ilฺc ent G
/usr/lib64/qt-
a
3.3/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin:/u01/app/orac
le/product/12.1.0/dbhome_1/bin
@ gm tud
[oracle@host01 ~]$ b d i s S
i r h
h k ab se t
a t in your
4. Put the OPatch directory t o upath and verify that OPatch has access to the Oracle
i m
( opatch
r the
inventory with se lsinventory command.
b e n
Ka
[oracle@host01
u l lic ~]$ export
san
PATH=$PATH:/u01/app/oracle/product/12.1.0/dbhome_1/OPatch
-------------------------------------------------------------------
Installed Top-level Products (1):
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
n u
running as shown below.
sa [oracle@host01 20108098]$ opatch prereq
Ah CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.1.0.1.3
Copyright (c) 2015, Oracle Corporation. All rights reserved.
PREREQ session
OPatch succeeded.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
[oracle@host01 20108098]$
6. Open a second ssh connection as the oracle user. Set the environment and use the
SRVCTL command to determine which instances are running on the three nodes. Shut
down the instance running on the local node, host01.
[vncuser@classsroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
[oracle@host01 ~]$
ble
fe r a
ans
[oracle@host01 ~]$ . oraenv
n - t r
ORACLE_SID = [oracle] ? orcl
The Oracle base has been set to /u01/app/oracle a no
h a s ฺ
) de
[oracle@host01 ~]$
o m u i
[oracle@host01 ~]$ srvctl status database a ilฺc en-dt Gorcl
Instance orcl_1 is running on g
m tud
b @ node host02
d on nodes Shost03
Instance orcl_2 is running
i r h i
ab seont node host01
Instance orcl_3 iskrunning
h
a t t o u
i m
r ( e~]$ sesrvctl stop instance -d orcl -i orcl_3
b
[oracle@host01 n
l Ka
[oracle@host01
u lic ~]$
san
Ah 7. Return to the first terminal and start the patch installation by executing opatch apply.
When OPatch asks “Is the local system ready for patching?”, answer yes by typing Y and
pressing Enter.
[oracle@host01 20108098]$ opatch apply
Oracle Interim Patch Installer version 12.1.0.1.3
Copyright (c) 2015, Oracle Corporation. All rights reserved.
h k ab se t
Verifying the a
t t o u
i m update...
r ( ense
b
a system
The
u l Klocal lic has been patched. You can restart Oracle
san
instances on it.
Ah
Patching in rolling mode.
When patching is finished on host01, the OPatch dialog will inform you that the instance
can be restarted on host01 and will prompt you for the name of the next node to patch,
host02. Before continuing, go to the next step.
[oracle@host01 ~]$
ble
fe r a
9. From the second terminal window, stop the instance on host02.
ans
... Output from step 6 ****
n - t r
[oracle@host01 ~]$ srvctl status database -d orcl
a no
Instance orcl_1 is running on node host02
h a s ฺ
Instance orcl_2 is running on node host03
o m )
u i de
ilฺc ent G
Instance orcl_3 is running on node host01
a
@ gm tud -d orcl -i orcl_3
d
[oracle@host01 ~]$ srvctl stop S
instance
b i rb this
ka 8 u****
... Output from hstep
t se
( m a~]$ srvctl
to start instance -d orcl -i orcl_3
[oracle@host01
e
a bir icens
u l K l ~]$ srvctl stop instance -d orcl -i orcl_1
[oracle@host01
san
Ah [oracle@host01 ~]$
10. Return to the first terminal window, type host02 and press Enter. When asked “Is the
node ready for patching? [y|n]”, answer Y and press Enter.
What is the next node to be patched?
host02
You have selected 'host02' from 'host02' 'host03'
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
n_20_2015_12_04_56/rac/copy_files.txt"
DP =
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
n_20_2015_12_04_56/rac/copy_dirs.txt"
MP =
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
n_20_2015_12_04_56/rac/make_cmds.txt"
RC =
ble
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
fe r a
n_20_2015_12_04_56/rac/remote_cmds.txt"
ans
n - t r
o
an
Instantiating the file
s
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
ha deฺ
)
n_20_2015_12_04_56/rac/copy_files.txt.instantiated" by replacing
m ui
$ORACLE_HOME in
c o
il ent G
ฺ
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
a
gm tud
n_20_2015_12_04_56/rac/copy_files.txt" with actual path.
@
Propagating files to remote nodes...
b d i s S
i r h
Instantiating the file
h k ab se t
a t t o u
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
i m
n_20_2015_12_04_56/rac/copy_dirs.txt.instantiated" by replacing
r ( ense
$ORACLE_HOME in
b
l Ka lic
"/u01/app/oracle/product/12.1.0/dbhome_1/.patch_storage/20108098_Ja
The node 'host02' has been patched. You can restart Oracle
instances on it.
11. Go to the second terminal window and restart the instance on host02.
... Output from step 6 ****
[oracle@host01 ~]$ srvctl status database -d orcl
Instance orcl_1 is running on node host02
Instance orcl_2 is running on node host03
Instance orcl_3 is running on node host01 ble
fe r a
ans
[oracle@host01 ~]$ srvctl stop instance -d orcl -i orcl_3
n - t r
a no
... Output from step 8 ****
h a s ฺ
) de
[oracle@host01 ~]$ srvctl start instance -d orcl -i orcl_3
o m u i
... Output from step 9 **** a ilฺc ent G
[oracle@host01 ~]$ srvctl stopginstance
m tud -d orcl -i orcl_1
b d @ s S
i r h i
t instance -d orcl -i orcl_1
ab sstart
[oracle@host01 ~]$ksrvctl
h e
a t t o u
i m
r ( e~]$ se
b
[oracle@host01 n
u l Ka lic
s12.anFrom the second terminal window stop the instance on host03.
Ah ... Output from step 6 ****
[oracle@host01 ~]$ srvctl status database -d orcl
Instance orcl_1 is running on node host02
Instance orcl_2 is running on node host03
Instance orcl_3 is running on node host01
[oracle@host01 ~]$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
13. Return to the first terminal window and indicate host03 is ready for patching by typing Y
and pressing Enter.
Is the node ready for patching? [y|n]
y
The node 'host03' has been patched. You can restart Oracle
instances on it.
OPatch succeeded.
[oracle@host01 ~]$
-------------------------------------------------------------------
16. When finished, close all terminal windows opened for practice.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 6:
Lesson
Managing o m ) i
Backup
u de and
a ilฺc enfor
Recovery t G RAC
@ gm tud
b d Chapter
i s S 6
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Practices Overview
In this practice, you will configure ARCHIVELOG mode for your RAC database, configure
instance-specific connect strings for RMAN, and configure persistent RMAN settings.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice, you adjust initialization parameters in the SPFILE, and stop and start the ASM
instances on local and remote nodes.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. Open a terminal session to host01 as the oracle user and set up the environment
variables using the oraenv script for the database instance. Determine the instance
running on host01 (the local machine). Change the value of the ORACLE_SID variable to
allow local system authenticated connections.
[vncuser@classroom_pc ~] ssh oracle@host01
Password:
[oracle@host01 ~]$ . oraenv
ble
ORACLE_SID = [oracle] ? orcl
fe r a
The Oracle base has been set to /u01/app/oracle
ans
n - t r
[oracle@host01 ~]$ no
srvctl status database -db orcl
a
Instance orcl_1 is a
running on node host02
h s ฺ
Instance orcl_2 is
m )
running on node host03
o u i de
Instance orcl_3 is
ilฺc ent G
running on node host01
a
@ gm tud
[oracle@host01 ~]$ export
[oracle@host01 ~]$bir
bd this S
ORACLE_SID=orcl_3
t h ka use
( m a using tooperating system authentication to the database instance,
2. Make a localrconnection e
ns log list SQL command to determine whether the database
and thena busei theicarchive
e
l
isuin K
ARCHIVELOG l mode. Exit SQL*Plus when done.
san [oracle@host01 ~]$ sqlplus / as sysdba
Ah
SQL*Plus: Release 12.1.0.2.0 Production on Mon Jan 13 17:24:39
2014
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
3. Stop the orcl database on each node of the cluster by using the srvctl stop
ble
database command.
fe r a
[oracle@host01 ~]$ srvctl stop database -d orcl
ans
[oracle@host01 ~]$ n - t r
a no
4. Verify that the orcl database is not running on any node ofhthea sclusterฺ by using the
srvctl status database command.
o m )
u i de
c
ilฺdatabase
t G-d orcl
[oracle@host01 ~]$ srvctl status a n
de host02
Instance orcl_1 is not running
@ gm ontunode
b drunningi s S
Instance orcl_2 is not
b i r t h on node host03
Instance orcl_3ka e
t h u s
is not running on node host01
[oracle@host01
( m a ~]$to
b i r ense
l
5. Make
u Kaalocal connection
lic using operating system authentication to the local database
saninstance, and then start up the database on only the first node with the mount option.
Ah [oracle@host01 ~]$ sqlplus / as sysdba
6. Issue the alter database archivelog SQL command to change the archive mode of
the database, and then verify the results by using the archive log list SQL command.
SQL> alter database archivelog;
Database altered.
l K ab lice
a n u
s Database dismounted.
Ah ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
8. Verify that the orcl database is running on all the three nodes of your cluster by using the
srvctl status database command.
[oracle@host01 ~]$ srvctl status database -d orcl
Instance orcl_1 is running on node host03
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice, you will designate all three instances (orcl_1, orcl_2 and orcl_3) of your
policy-managed database responsible for performing parallel backups of the database. The
database will be backed up to the +FRA ASM disk group by default.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. Using the recovery manager utility (RMAN), connect to the orcl database as the target
database.
[oracle@host01 ~]$ rman target /
n-
rights reserved.
a no
connected to target database: ORCL (DBID=1352492209)
h a s ฺ
o m )
u i de
RMAN>
a ilฺc ent G
@ gm tud
b d
2. Display all of the current RMAN settings.
i s S
RMAN> show all; b i r t h
h k a s e
a t t o u
r m
( nse
using target
i database control file instead of recovery catalog
l K abconfiguration
RMAN
l ice parameters for database with db_unique_name
a n u ORCL are:
s
Ah
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT'
OPTIMIZE FOR LOAD TRUE ; # default
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
RMAN>
3. Configure RMAN to automatically back up the control file and server parameter file each
time any backup operation is performed.
RMAN> configure controlfile autobackup on;
a n u
s
Ah
RMAN> configure channel device type disk connect =
'sys/sys_password@orcl';
RMAN>
5. Open a second terminal session as the oracle user and set up the environment variables
for the orcl database. Invoke SQL*plus as the system user, and run the
/stage/RAC/labs/less_06/monitor_rman.sql script. Do not exit the first session
with the RMAN prompt or this second session with the SQL prompt.
[oracle@host01 ~]$ . oraenv
ORACLE_SID = [oracle] ? orcl
The Oracle base has been set to /u01/app/oracle
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
ble
Storage Management, OLAP,
fe r a
Advanced Analytics and Real Application Testing options
ans
n - t r
SQL> @/stage/RAC/labs/less_06/monitor_rman.sql
a no
h a s ฺ
no rows selected
o m )
u i de
a ilฺc ent G
SQL>
@ gm tud
b d i s S
6. In the first session with the RMANi r h
b onlyeont the designated
prompt, perform a full database backup with archive
logs. The backup should h k a
happen s nodes (your first and second
a t o u
nodes) as the backup nodes.t Do not wait for this step to finish before proceeding to
i
the next step.r (m nse
l K ab backup
RMAN> l ice database plus archivelog;
a n u
s
Ah Starting backup at 09-DEC-14
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=237 instance=orcl_1 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=38 instance=orcl_2 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=95 instance=orcl_3 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=3 sequence=62 RECID=2 STAMP=865871218
input archived log thread=1 sequence=79 RECID=5 STAMP=865877087
channel ORA_DISK_1: starting piece 1 at 09-DEC-14
channel ORA_DISK_2: starting archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
handle=+FRA/ORCL/BACKUPSET/2014_12_09/annnf0_tag20141209t173104_
0.278.865877465 tag=TAG20141209T173104 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_3: finished piece 1 at 09-DEC-14
piece
handle=+FRA/ORCL/BACKUPSET/2014_12_09/annnf0_tag20141209t173104_
0.279.865877465 tag=TAG20141209T173104 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:01
ble
Finished backup at 09-DEC-14
fe r a
t r a ns
Starting Control File and SPFILE Autobackup at 09-DEC-14
o n -
piece
s an
comment=NONE ) ha deฺ
handle=+FRA/ORCL/AUTOBACKUP/2014_12_09/s_865877467.280.865877471
c o m uati 09-DEC-14
Finished Control File and SPFILE ฺAutobackup
a il ent G
@ gm tud
RMAN>
b d i s S
i r t h
h k ab rerun s e
7. While the backup is in
a t progress
progress,
t o u the query in the second terminal window to monitor
the RMAN backup
i r ( m se
session within the cluster. The backup should be done in
abthework
parallel, with n
distributed to all three nodes of the cluster. Enter the slash (/) symbol
K
andl press l icekey to rerun the query. It may be necessary to do this multiple times
Enter
a n u the output appears. When the backup finishes, exit SQL*Plus.
until
s
Ah SQL> /
no rows selected
SQL> /
SQL> /
SQL> /
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
SQL> exit
ble
[oracle@host01 ~]$
fe r a
t r a ns
8. Shut down the database using srvctl so ARCHIVELOG mode can be disabled o n - for your
RAC database.
s an
[oracle@host01 ~]$ srvctl stop database -d
) haorcl d e ฺ
[oracle@host01 ~]$ m
co t Gu i
i l
a denฺ
g m u
system tauthentication
d @
9. Make a local connection using operating
s S to the local database
b thoni only the first node with the mount option.
instance, and then start up theirdatabase
Disable ARCHIVELOG mode a bwith thee
k the archive noarchivelog statement.
t h u s alterlogdatabase
m a
Confirm this operation with
t o list statement. Shut down the database
b i r ( when
and exit SQL*Plus
e n e
sfinished.
u l Ka lic ~]$ sqlplus / as sysdba
[oracle@host01
san
Ah SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 12 12:30:00
2014
Database altered.
a t
[oracle@host01 ~]$
t o u
i m
r ( ense
b
u l Kawindows.
10. Use srvctl
terminal
lic your database. Ensure that all instances are up, and then exit all
to restart
san
Ah [oracle@host01 ~]$ srvctl start database -d orcl
ble
fe r a
ans
n - t r
a no
Practices )for s ฺ 7:
haLesson
Global o m u i
Resource de
a ilฺc ent G Concepts
Management
@ gm tud
b d Chapter
i s S 7
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
[oracle@host01 less_07]$
Connected to:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Ah SYS@orcl_3 SQL>
5. Find the block ID and file number for the block containing the record for employee number
7521 from the SCOTT.EMP table.
SYS@orcl_3 SQL> select empno, ename,
dbms_rowid.rowid_relative_fno(rowid) fileno,
dbms_rowid.rowid_block_number(rowid) block_no
from scott.emp where empno = 7521;
SYS@orcl_3 SQL>
6. Using the file and block number identified, check the status of the block in GV$BH as shown
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
below.
SYS@orcl_3 SQL> select inst_id,file#,block#,status,dirty from
gv$bh where file#=6 and block# = 197 and status !='free'
order by 1,2,3;
no rows selected
SYS@orcl_3 SQL>
ble
fe r a
ans
7. Read the record for WARD from the SCOTT.EMP table and recheck the block status in
n - t r
no
GV$BH. What do you see?
s ฺa
SYS@orcl_3 SQL> select * from scott.emp where ename = 'WARD';
h a
) de
Hit Any Key to Continue
o m u i
EMPNO ENAME JOB a ilฺc enMGR
t GHIREDATE
DEPTNO gm
SAL COMM
---------- ----------bd
tud
@ s S----------
i r ---------
t h i --------------------
---------- ----------
h k ab SALESMAN
----------
s e
a t
7521 WARD
t o u 7698 22-feb-1981 00:00:00
1250
i r (m nse
500 30
ab selected.
l 1Krow lice
a n u
Ahs SYS@orcl_3 SQL> select inst_id,file#,block#,status,dirty from
gv$bh where file#=6 and block# = 197 and status !='free'
order by 1,2,3;
Hit Any Key to Continue
1 row selected.
SYS@orcl_3 SQL>
GV$BH shows that the local instance (orcl_3) has cached the block image in SCUR
(shared current) mode.
ble
[oracle@host02 less_07]$ . oraenv
fe r a
ORACLE_SID = [oracle] ? orcl
ans
The Oracle base has been set to /u01/app/oracle n - t r
a no
[oracle@host02 less_07]$ export ORACLE_SID=orcl_1 h a s ฺ
[oracle@host02 less_07]$
o m )
u i de
a ilฺc ent G
gmfor WARD
9. On host02, start SQL*Plus, read the record
@ tud from the SCOTT.EMP table and
d S
b i rb Whatthdoisyou see?
recheck the block status in GV$BH.
a
[oracle@host02 kless_07]$
h sesqlplus / as sysdba
a t to u
( m e
SQL*Plus:
a e ns 12.1.0.2.0 Production on Mon Jan 5 14:01:26
bir icRelease
u l K
2015 l
san
Ah Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
30
ble
INST_ID FILE# BLOCK# STATUS D
fe r a
---------- ---------- ---------- ---------- -
ans
1 6 197 scur N
n - t r
3 6 197 scur
a no N
h a s ฺ
SYS@orcl_1 SQL>
o m )
u i de
You should see that both instance 1 (orcl_1) and
a ilฺcinstance
n t G3 (orcl_3) have cached the
block image in SCUR (shared current) mode.
@ gm tude
S
d toishost03
10. Open a terminal session on b i
yourrbdesktop
t h as the oracle user. Change the
h k a s e
a t o u
directory to /stage/RAC/labs/less_07, check which instance is running on host03,
i r ( m se t
and set the environment.
a b icen
[vncuser@classsroom_pc ~]$ ssh oracle@host03
u K l
l oracle@host03's password:
n
sa Last login: Wed Dec 10 17:57:14 2014 from 192.0.2.1
Ah
[oracle@host03 ~]$ cd /stage/RAC/labs/less_07
2015
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
ble
With the Partitioning, Real Application Clusters, Automatic
fe r a
Storage Management, OLAP,
ans
Advanced Analytics and Real Application Testing options
n - t r
n o
SYS@orcl_2 SQL> select * from scott.emp where a
s ename = 'WARD';
h a ฺ
Hit Any Key to Continue
o m )
u i de
a ilฺc enMGR
t GHIREDATE
EMPNO ENAME JOB
DEPTNO g
m tud
SAL COMM
b @
d--------- s S---------- --------------------
---------- ---------- i r t h i
k ab ----------
---------- ----------
h s e
7521 a t
WARD
t o uSALESMAN 7698 22-feb-1981 00:00:00
1250 r ( m 500se
bi icen
30
lK a l
a n u 1 row selected.
Ahs
SYS@orcl_2 SQL> select inst_id,file#,block#,status,dirty from
gv$bh where file#=6 and block# = 197 and status !='free'
order by 1,2,3;
Hit Any Key to Continue
2 6 197 scur N
3 6 197 scur N
3 rows selected.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
12. Next, let’s engineer a read/write for the block from the instance on host01. Use the
cf_upward.sql script to do this. Recheck the block status in GV$BH. What do you see?
SYS@orcl_3 SQL> !cat cf_upward.sql
update scott.emp set sal = sal + 0 where ename = 'WARD';
1 row updated.
ble
fe r a
ans
SYS@orcl_3 SQL> commit;
n - t r
Commit complete. a no
h a s ฺ
o m )
u i de
SYS@orcl_3 SQL> select inst_id,file#,block#,status,dirty from
gv$bh where file#=6 and block# =ilฺ197 c andt status
G
m a e n !='free'
order by 1,2,3;
d @ g
S tud
Hit Any Key to Continue
b i rb this
ka use BLOCK# STATUS
INST_ID ath FILE#
m t o D
i r ( e----------
----------
b n se ---------- ---------- -
n u l Ka li1c 6 197 cr N
hs a
A 2 6 197 cr N
3 6 197 xcur Y
6 197 cr N
4 rows selected.
SYS@orcl_3 SQL>
The updating instance now holds an XCUR (exclusive current) image for the block and all
SCURs have been downgraded to CR. Note that the XCUR shows dirty. When you have a
read/write condition, existing SCURs are downgraded to CR while the updating instance will
indicate an XCUR. No other instance can have either a shared or exclusive image of the
same block.
1 row updated.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Commit complete.
@ gm tud
2 6 d
b i s S cr
197 N
i r h
h k ab se t
3 t 6u
m a t o 197 pi Y
b i r ( ense 6 197 cr N
n u l Ka lic
hs a 6 rows selected.
A
SYS@orcl_1 SQL>
The updating instance (orcl_1) now holds an XCUR (exclusive current) image for the
block. The old XCUR held by instance 3 has been downgraded to a PI (past image). Note
that the XCUR and PI both show as dirty. The past image is nothing more than a copy of a
dirty block that is used by the Global Cache Service. Past images of blocks are maintained
by GCS until writes covering those versions are recorded. Past images are used in failure
recovery. Once a later image is written from any instance, the PI image is converted to CR.
14. From host01 (instance 3) issue a checkpoint. Recheck the block status in GV$BH. What do
you see?
SYS@orcl_3 SQL> alter system checkpoint;
System altered.
2 6 197 cr N
ble
3 6 197 cr N
fe r a
6 197 cr N
ans
n - t r
a no
6 rows selected.
h a s ฺ
o m )
u i de
SYS@orcl_3 SQL>
a ilฺc ent G
The PI image has been converted to a CR
@ gm t Nodimages are dirty after the
image. u
d S
checkpoint.
b i rb this
a e
15. Close all terminals a thk fortothisuspractice.
opened
i r (m nse
l K ab lice
a n u
s
Ah
1. Establish an ssh connection option as the oracle user. Use oraenv to set the Oracle
environment. Change the directory to /stage/RAC/labs/less_07. Connect to instance
1 (orcl_1).
[vncuser@classsroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
a ilฺc ent G
gm tud on Tue Jan 27 07:16:33 2015
SQL*Plus: Release 12.1.0.2.0 Production
@
b d i s S
i r t h
h k ab sOracle.
Copyright (c) 1982, 2014,
e All rights reserved.
a t t o u
Connected to:m
ir ( en12c seEnterprise Edition Release 12.1.0.2.0 - 64bit
Oracleab
u l K
Production lic
Database
2 rows selected.
SYS@orcl_1 SQL>
SQ lock is used both in RAC and single instance to single thread cache replenishment for a
specific sequence. The SV lock is used to coordinate number ordering when using RAC
ble
and the ORDERED option for a sequence.
fe r a
t r a ns
n - no cache
3. Next we will create five sequences. First, create a sequence with no order and
o
an
called rac_nocache_noorder.
SYS@orcl_1 SQL> create sequence rac_nocache_noorder s
ha deฺ
2 start with 1 increment by 1 )
m ui
c o
3 nocache noorder;
a il ent G
ฺ
@ gm tud
Sequence created.
b d i s S
i r h
SYS@orcl_1 SQL>
h k ab se t
a t t o u
i m
ra (sequence e order but no cache called rac_nocache_order.
susing
b e n
Ka SQL>
4. Next, create
u l
SYS@orcl_1 lic create sequence rac_nocache_order
san 2 start with 1 increment by 1
Ah 3 nocache order;
Sequence created.
SYS@orcl_1 SQL>
Sequence created.
SYS@orcl_1 SQL>
Sequence created.
SYS@orcl_1 SQL>
a b icen
CACHE_SIZE, LAST_NUMBER from dba_sequences where sequence_name like
l K
'%RAC_%ORDER';
u l
san
Ah SYS@orcl_1 SQL> @seq_dd.sql
Hit Any Key to Continue
5 rows selected.
from gv$_sequences
where sequence_name like '%RAC%'
order by inst_id,sequence_name;
o m )
u i de
ilฺc ent G
5 rows selected.
a
SYS@orcl_1 SQL>
@ gm tud
b d in the i s S
i
Only Instance 1 currently has metadatar h row cache, since the sequences were
tinstance.
created there and not used
h k ainbany other
s e
a t t o u
i r
10. Let’s take a lookm
( nse
at the SV resources currently owned by LCK0 using the sv_res.sql
script. ab
l K l i ce
a n u
SYS@orcl_1 SQL> !cat sv_res.sql
s select l.inst_id,l.pid,p.program,l.resource_name2,
Ah l.owner_node,l.state,l.blocked,l.blocker
from gv$ges_enqueue l, gv$process p
where resource_name2 like '%SV%'
and p.spid = l.pid
order by 1;
2 rows selected.
OBJECT_NAME OBJECT_TYPE
-------------------- -----------------------
RAC_GAP_ORDER SEQUENCE
1 row selected.
ble
SYS@orcl_1 SQL> select object_name, object_type from dba_objects
fe r a
where object_id = 93294;
ans
Hit Any Key to Continue
n - t r
a no
OBJECT_NAME OBJECT_TYPE
h a s ฺ
-------------------- -----------------------
o m )
u i de
RAC_CACHE_ORDER SEQUENCE
a ilฺc ent G
@ gm tud
1 row selected.
b d i s S
i r h
SYS@orcl_1 SQL> thk
ab se t
a t o u
i m
( with ncache
rrequesting
Only sequences e and order get SV instance locks which are required to pass
sinstances.
b e
Ka
NEXTVAL
u l
to
lic
san
Ah 12. Now, let’s attempt to show gaps occurring in the RAC_GAP_ORDER sequence.
SYS@orcl_1 SQL> select rac_gap_order.nextval from dual;
Hit Any Key to Continue
NEXTVAL
----------
1
1 row selected.
1 row selected.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
SYS@orcl_1 SQL>
13. Force a loss of the cached sequence numbers by flushing the shared pool.
SYS@orcl_1 SQL> alter system flush shared_pool;
System altered.
SYS@orcl_1 SQL>
ble
fe r a
14. Increment the RAC_GAP_ORDER sequence with cache and order again.
ans
SYS@orcl_1 SQL> select rac_gap_order.nextval from dual;
n - t r
Hit Any Key to Continue
a no
NEXTVAL
h a s ฺ
----------
o m )
u i de
50001
a ilฺc ent G
1 row selected.
@ gm tud
b d i s S
i r h
SYS@orcl_1 SQL>
h k ab se t
Note that NEXTVALaist now 50001.
t o uThis gap would occur in both single instance and RAC
databases. (m
b i r ense
u l Ka lic
sandbms_shared_pool.keep procedure. Keep the RAC_GAP_ORDER sequence to prevent
15. You must manually keep the sequence to prevent ageouts. This is done using the
Ah this condition.
SYS@orcl_1 SQL> exec dbms_shared_pool.keep('RAC_GAP_ORDER','Q');
PL/SQL procedure successfully completed.
SYS@orcl_1 SQL>
16. Increment the RAC_GAP_ORDER sequence and then flush the shared pool again. Increment
the sequence again. What do you observe?
SYS@orcl_1 SQL> select rac_gap_order.nextval from dual;
Hit Any Key to Continue
NEXTVAL
----------
50002
System altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
NEXTVAL
----------
50003
ble
1 row selected.
fe r a
ans
n - t r
no
SYS@orcl_1 SQL>
s ฺa
Because the sequence has been kept (for this instance), the cached values are not lost. If
h a
you are using cached sequences, you will need to initiate a keep for them when instances
o m ) i de
are restarted. In a RAC environment, the keep must be performed on all instances.
u
a ilฺc ent G
17. You can query gv$db_object_cache g tom d status of the RAC_GAP_ORDER
d @ S tuwhen
view the keep
sequence. Drop the RAC_GAP_ORDER
i r b t h i s
sequence finished. Note that it shows as kept
only in one instance. b
kaname e
SYS@orcl_1 SQL> tcol h u s
SYS@orcl_1 (SQL>
a
m col t o format a20
1 row selected.
SYS@orcl_1 SQL>
SYS@orcl_1 SQL>
19. Check the keep status of the sequences using the view_obj_cache.sql script .
SYS@orcl_1 SQL> !cat view_obj_cache.sql
select inst_id, name, type, kept from gv$db_object_cache where name ble
like '%RAC_CACHE%' fe r a
ans
and type = 'SEQUENCE'
n - t r
order by 1,2; o
s an
SYS@orcl_1 SQL> @view_obj_cache
) ha deฺ
Hit Any Key to Continue
c o m ui
a il ent G
ฺ
INST_ID NAME
@ gmTYPEtud KEP
d S
i
---------- --------------------
b rb this---------------- ---
t h ka use SEQUENCE
1 RAC_CACHE_NOORDER YES
( m a to
1 RAC_CACHE_ORDER SEQUENCE YES
ir ens e
a b
l
2 rows
u lic
K selected.
san
Ah 20. Now get the first value from the RAC_NOCACHE_NOORDER sequence in the first instance.
Check SQ enqueues on the first instance using the sq_enq.sql script.
SYS@orcl_1 SQL> select rac_nocache_noorder.nextval from dual;
Hit Any Key to Continue
NEXTVAL
----------
1
1 row selected.
3 SQ 20 0 20 0 0 0
3 rows selected.
SYS@orcl_1 SQL>
21. Get the first value from the RAC_NOCACHE_ORDER sequence in the first instance. Check
ble
SQ enqueues on the first instance using the sq_enq.sql script.
fe r a
SYS@orcl_1 SQL> select rac_nocache_order.nextval from dual;
an s
Hit Any Key to Continue
n - t r
a no
NEXTVAL
h a s ฺ
----------
o m )
u i de
1
a ilฺc ent G
1 row selected.
@ gm tud
b d i s S
i r h
SYS@orcl_1 SQL> @sq_enq.sql
h k ab se t
a t
Hit Any Key to Continue
t o u
i m
( nse
rTOTAL_REQ#
INST_ID b
EQ
ice -----------
a-- ---------- TOTAL_WAIT# SUCC_REQ# FAILED_REQ# CUM_WAIT_TIME CON_ID
u l K
------- l ---------- ----------- ------------- ------
sa n 1 SQ 19 0 19 0 0 0
Ah 2 SQ 15 0 15 0 0 0
3 SQ 20 0 20 0 0 0
3 rows selected.
SYS@orcl_1 SQL>
22. Get the first value from the RAC_CACHE_NOORDER sequence in the first instance. Check
SQ enqueues on the first instance using the sq_enq.sql script.
SYS@orcl_1 SQL> select rac_cache_noorder.nextval from dual;
Hit Any Key to Continue
NEXTVAL
----------
1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
3 rows selected.
ble
SYS@orcl_1 SQL>
fe r a
ans
23. Get the first value from the RAC_CACHE_ORDER sequence in the first instance. Check SQ
n - t r
enqueues on the first instance using the sq_enq.sql script.
a no
SYS@orcl_1 SQL> select rac_cache_order.nextval
h a sfrom ฺdual;
Hit Any Key to Continue
o m )
u i de
a ilฺc ent G
NEXTVAL
@ gm tud
----------
b d i s S
i r h
1
1 row selected. thk
ab se t
a t o u
i m
r (SQL>en@sq_enq.sql
se
a b
SYS@orcl_1
u l KAny lic
san
Hit Key to Continue
3 rows selected.
SYS@orcl_1 SQL>
24. View the sequence data contained in the data dictionary using the seq_dd.sql script.
Compare that with the sequence metadata displayed in GV$_SEQUENCES using the
seq_meta_val.sql script.
SYS@orcl_1 SQL> @seq_dd
4 rows selected.
i r ( m se t
1 RAC_NOCACHE_NOORDER N 0
K a l i c en
b 1 RAC_NOCACHE_ORDER Y 0
n u l
sa 4 rows selected.
Ah
SYS@orcl_1 SQL>
In the data dictionary, the two non-cached sequences show a zero cache size as expected,
and the LAST_NUMBER column contains 2 for both of them. This represents the number
written to the data dictionary the last time it was updated for those sequences. For non-
cached sequences, each time a NEXTVAL is requested, the dictionary will be updated so
the LAST_NUMBER column shows the next value that will be allocated. In the row cache
metadata the NEXTVALUE column contains nulls for the non-cached sequences, because
no values are cached. For the cached sequences, the cache size is 50000. In the data
dictionary, the LAST_NUMBER column shows 50001 as that number is the value written to
the data dictionary for these two sequences when caching the first 50000 numbers for each
sequence in the row cache of instance 1. Notice that the NEXTVALUE column contains 2 in
the row cache metadata, as that represents the next cached number that will be allocated
for each of the cached sequences. The data dictionary will only need to be updated for
either of these sequences when cache replenishment occurs, either due to ageouts, or due
to exhausting the cached range of numbers.
SYS@orcl_2 SQL>
ble
fe r a
ans
26. Use the view_obj_cache.sql script to view the cached sequences in the second
n - t r
instance. o
SYS@orcl_2 SQL> @view_obj_cache.sql
s an
) ha deฺ
Hit Any Key to Continue
c o m ui
INST_ID NAME a il ent G KEP
TYPE
ฺ
---------- --------------------
@ gm----------------
tud ---
d s S
a b irb thiSEQUENCE
1 RAC_CACHE_NOORDER YES
e
thk to us
RAC_CACHE_ORDER SEQUENCE YES
m sea
(RAC_CACHE_NOORDER
i r
2
e n
b RAC_CACHE_ORDER SEQUENCE YES
l K a li c SEQUENCE YES
u
san
Ah
4 rows selected.
SYS@orcl_2 SQL>
1 row selected.
SYS@orcl_2 SQL> select rac_nocache_order.nextval from dual;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
1 row selected.
ble
1 row selected.
fe r a
t r a ns
SYS@orcl_2 SQL> select rac_cache_order.nextval from dual;
o n -
Hit Any Key to Continue
s an
NEXTVAL
) ha deฺ
----------
c o m ui
2 a il ent G
ฺ
@ gm tud
b d i s S
1 row selected.
i r h
h k ab se t
SYS@orcl_2 SQL> a t t o u
i m
r ( ense
b
l
28. From
u Kthea secondlicinstance, view the sequence data contained in the data dictionary using
santhe seq_dd.sql script. Compare that with the sequence metadata displayed in
Ah GV$_SEQUENCES using the seq_meta_val.sql script.
SYS@orcl_2 SQL> @seq_dd
Hit Any Key to Continue
4 rows selected.
8 rows selected.
ble
SYS@orcl_2 SQL>
fe r a
ans
By now you should have noticed that the non-cached sequences hit the data dictionary for
n - t r
each NEXTVAL requested while the cached sequences are not incremented in the data
o
dictionary because NEXTVAL is supplied from memory.
s an
ha deฺ
Note too that the sequence that is not ordered causes another range of 50000 numbers to
)
c o m ui
be cached in the second row cache. This is why the LAST_NUMBER column in the data
il ent G
ฺ
dictionary contains 100001 for RAC_CACHE_NOORDER. The value for RAC_CACHE_ORDER
a
gm tud
remains at 50001 since all instances are in effect caching the same range of numbers. This
@
b i s S
can also be seen in the row cache metadata. RAC_CACHE_NOORDER has a NEXTVALUE of
d
i r h
2 in one instance but a NEXTVALUE of 50002 in another and no coordination is done to
k ab se t
allocate the numbers in order. RAC_CACHE_ORDER also has two different values for
h
a t t o u
NEXTVALUE having a 2 in one instance and a 3 in the other but the instance with the
i m
r ( ense
highest value in the row cache NEXTVALUE column owns the “true” next value and if
b
l Ka lic
another instance increments that sequence, the “true” next value will be passed by
Ahs
29. Connect back to the first instance and get the next value for the RAC_NOCACHE_NOORDER,
RAC_NOCACHE_ORDER, .RAC_CACHE_NOORDER, and RAC_CACHE_ORDER sequences.
SYS@orcl_2 SQL> connect sys/sys_password@orcl_1 as sysdba
Connected.
1 row selected.
SYS@orcl_1 SQL> select rac_nocache_order.nextval from dual;
Hit Any Key to Continue
NEXTVAL
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
1 row selected.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1 row selected.
ble
SYS@orcl_1 SQL> select rac_cache_order.nextval from dual;
fe r a
ans
Hit Any Key to Continue
n - t r
no
NEXTVAL
----------
s ฺa
3 h a
o m )
u i de
1 row selected. a ilฺc ent G
@ gm tud
b d i s S
SYS@orcl_1 SQL>
i r h
h k ab se t
t
30. View the sequenceadata contained
t o u in the data dictionary using the seq_dd.sql script.
i
Compare that
m
( thensequence
r with se metadata displayed in GV$_SEQUENCES using the
b e
Ka
seq_meta_val.sql
u l lic script. What are your observations?
sanSYS@orcl_1 SQL> @seq_dd.sql
Ah Hit Any Key to Continue
4 rows selected.
RAC_CACHE_ORDER Y 3 50000
RAC_NOCACHE_NOORDER N 0
RAC_NOCACHE_ORDER Y 0
8 rows selected.
SYS@orcl_1 SQL>
The non-cached sequences update the data dictionary with each NEXTVAL, potentially ble
causing performance degradation. The best performance is usually obtained using cached fe r a
and ordered sequences.
ans
The RAC_CACHE_ORDER sequence got the correct value of 3, due to the resource n - t r
o
an
coordination provided by the SV lock. The RAC_CACHE_NOORDER sequence got the
s
ha deฺ
number 2. So the order of allocation for RAC_CACHE_ORDER was 1, 2, 3 as required. The
)
c o m ui
order of allocation for RAC_CACHE_NOORDER was 1, 50001, 2.
a il ent G
ฺ
31. Drop all sequences created in this practice.
@ gm tud
SYS@orcl_1 SQL> drop sequence
b i S
d rac_nocache_noorder;
s
b i r t h
h k a s e
Sequence dropped.
a t t o u
i m
r (SQL>endrop
se sequence rac_nocache_order;
b
Ka
SYS@orcl_1
u l lic
sanSequence dropped.
Ah
SYS@orcl_1 SQL> drop sequence rac_cache_noorder;
Sequence dropped.
Sequence dropped.
SYS@orcl_1 SQL>
1. Establish an ssh connection as the oracle user. Use oraenv to set the Oracle
environment.
[vncuser@classsroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
thk to uexport
[oracle@host01aless_07]$
s
( m e
ORACLE_SID=orcl_3
[oracle@host01
a ns
bir iceless_07]$
u l K l
s3.anStart SQL*Plus and verify the SID using the show_my_sid.sql script.
Ah [oracle@host01 less_07]$ sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit
Production
With the Partitioning, Real Application Clusters, Automatic Storage
Management, OLAP,
Advanced Analytics and Real Application Testing options
1 row selected.
SYS@orcl_3 SQL>
4. Next, create a stored procedure using the lc_demo.sql script. Take a moment and look
at the script to see what it does.
SYS@orcl_3 SQL> !cat lc_demo.sql
create or replace procedure lcdemo is ble
begin fe r a
ans
for i in 1 ..100000 loop
n - t r
dbms_lock.sleep (1);
a no
end loop;
h a s ฺ
) de
end;
o m u i
ilฺc ent G
/
SYS@orcl_3 SQL> a
@ gmcalledtulcdemo.
d
The script creates a long running procedure
d S
b i rb this
h a to compile
kscript se the lcdemo procedure, and then execute it.
5. Run the lc_demo.sql
t
a @lc_demo.sql
to u
SYS@orcl_3 (SQL> m e
a bir icens
u l K
Procedure
l
created.
san
Ah SYS@orcl_3 SQL> exec lcdemo
█
The session essentially hangs while it runs the lcdemo procedure.
6. Open another terminal window to host01, set the environment, change the directory to
/stage/RAC/labs/less_07 and connect to the same instance. Use the
show_my_sid.sql script to display the SID.
[vncuser@classsroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit
Production
With the Partitioning, Real Application Clusters, Automatic Storage
ble
Management, OLAP,
fe r a
Advanced Analytics and Real Application Testing options
ans
n - t r
o
SYS@orcl_3 SQL> @show_my_sid
s an
Hit Any Key to Continue
) ha deฺ
c o m ui
SID
a i l ฺ n t G
----------
@ gm tude
47
b d i s S
i r h
1 row selected. thk
ab se t
a t o u
i m
r (SQL>ense
b
Ka
SYS@orcl_3
u l lic
san
Ah 7. From the second terminal session, query V$SESSION and see what is held by the first SID.
SYS@orcl_3 SQL> select sid, event from v$session where sid = 73;
Hit Any Key to Continue
SID EVENT
---------- --------------------------------------------------------
73 PL/SQL lock timer
1 row selected.
SYS@orcl_3 SQL>
9. Now, open a third terminal window to host01. Set the environment, change the directory to
/stage/RAC/labs/less_07 and connect to the same instance. Query V$SESSION to
see what the session attempting to drop the lcdemo preocedure is waiting on.
[vncuser@classsroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
h k ab se t
Copyright (c) a t 2014,
t o u Oracle. All rights reserved.
i m 1982,
r ( ense
b
u l Ka lic
sanConnected to:
Ah Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit
Production
With the Partitioning, Real Application Clusters, Automatic Storage
Management, OLAP,
Advanced Analytics and Real Application Testing options
SID EVENT
-------- ---------------------------
47 library cache pin
1 row selected.
SYS@orcl_3 SQL>
10. Return to the second terminal session. Cancel the drop procedure lcdemo statement
by typing <Control-c>. Connect to a different instance. In this example, we will connect
to orcl_1. Use the show_my_sid.sql script to determine the session identifier.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
12. Go to the third terminal session and connect to orcl_1. Query V$SESSION to check what
the session attempting to drop the lcdemo preocedure is waiting on.
SYS@orcl_3 SQL> connect sys/sys_password@orcl_1 as sysdba
Connected.
SYS@orcl_1 SQL> select sid, event from v$session where sid = 18;
Hit Any Key to Continue
SID EVENT
---------- ---------------------------
18 library cache pin
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
h san
A 3. Start SQL*Plus and determine the SID. Run the query shown below against GV$LOCK to
show lock specifics. The query will only return rows when TYPE is TM (DML enqueue). The
query should return no rows at this stage.
[oracle@host01 less_07]$ sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SID
----------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
61
1 row selected.
no rows selected
ble
fe r a
SYS@orcl_3 SQL>
ans
n - t r
4. a no
Lock the HR.EMPLOYEES table in exclusive mode. Rerun the GV$LOCK query. The instance
h a s ฺ
ID (INST_ID) should be 3, and lock mode (LMODE) should be 6 (EXCLUSIVE). BLOCK
o m ) i de
should be 2, meaning that instances on other nodes are blocked from acquiring a lock on
u
ilฺc ent G
the object. Query DBA_OBJECTS by using the value of ID1 to verify that the results pertain
a
to the HR.EMPLOYEES table. m tud
ghr.employees
SYS@orcl_3 SQL> lock table
b d @ s S in exclusive mode;
r
bi e th i
k a
th to us
Table(s) Locked.
a
i r (m nse
b e select
Ka fromlicgv$lock
SYS@orcl_3 SQL> inst_id, sid, type, id1, id2, lmode, request,
1 row selected.
OWNER OBJECT_NAME
---------- ---------------
HR EMPLOYEES
SYS@orcl_3 SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
5. From your desktop open a second terminal to host01 as the oracle user. Change the
directory to /stage/RAC/labs/less_07 and set the environment.
[vncuser@classsroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
Last login: Wed Dec 10 17:47:27 2014 from 192.0.2.1
ble
[oracle@host01 less_07]$ . oraenv
fe r a
ORACLE_SID = [oracle] ? orcl
ans
n - t r
no
The Oracle base has been set to /u01/app/oracle
s ฺa
[oracle@host01 less_07]$ export ORACLE_SID=orcl_3h a
o m )
u i de
[oracle@host01 less_07]$ sqlplusilฺ/c as sysdbat G
a n
@ gm tude
b i s S on Thu Dec 11 11:20:49
d Production
SQL*Plus:Release 12.1.0.2
i r h 2014
h k ab se t
Copyright (c) a u Oracle. All rights reserved.
t 1982,to 2014,
i m
r ( ense
b
u Ka
l Connected licto:
a n Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
Ahs 64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SID
----------
67
1 row selected.
SYS@orcl_3 SQL>
7. Return to the first terminal window and rerun the query from step 5. What do you observe?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
SID
----------
75
ble
fe r a
1 row selected.
ans
n - t r
SYS@orcl_1 SQL>
a no
h a s ฺ
9. From the third terminal window (host02) attempt to lock
o m u i de
)the HR.EMPLOYEES table in
exclusive mode. What do you observe? il ฺ c t G
ma tuden in exclusive mode;
SYS@orcl_1 SQL> lock table ghr.employees
b d @ sS
10. Return to the first terminala b r
e thi the query from step 7 by entering / and
i and rerun
hkyou observe?
session
pressing Enter. What a tdo t o us
i r
SYS@orcl_3 (m SQL>n se/
b e
u l Ka Any Key
Hit lic to Continue
san
Ah INST_ID SID TY ID1 ID2 LMODE REQUEST BLOCK
------- ----- -- ----- ----- ------ ------- -------
1 75 TM 92593 0 0 6 0
3 61 TM 92593 0 6 0 1
67 TM 92593 0 0 6 0
3 rows selected.
SYS@orcl_3 SQL>
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SID
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
1 row selected.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
SYS@orcl_2 SQL>
12. From the new terminal, attempt to lock the HR.EMPLOYERES table in exclusive mode.
SYS@orcl_2 SQL> lock table hr.employees in exclusive mode;
13. Return to the first terminal window and rerun the query to view the lock status. What do you
observe?
ble
SYS@orcl_3 SQL> /
fe r a
Hit Any Key to Continue
ans
n - t r
INST_ID SID TY ID1 ID2 LMODE REQUEST BLOCK
a no
------- ----- -- ----- ----- ------ ------- -------
h a s ฺ
1 75 TM 92593 0 0 6
o m ) 0
u i de
ilฺc
0ma 0 en 6
tG
2 38 TM 92593
g t u d 0
b d @ sS
3 b i
61 TM 92593
a
r
e th0i 6 0 1
t k
67hTM 92593 us 0 0 6 0
a
(m nse t o
i r
b ice
l Ka
4 rows selected.
u l
a n
Ahs SYS@orcl_3 SQL>
Instance 3, SID 61 is holding the lock in exclusive mode (LMODE 6), blocking SID 67
(inst 3), 38 (inst 2), and SID 75 (inst 1) all requesting the lock in exclusive mode
(REQUEST 6).
14. Go to the first terminal session, (INST_ID 3, SID 61 in this example) and issue a rollback.
Query GV$LOCK when finished. What do you observe?
SYS@orcl_3 SQL> rollback;
Rollback complete.
2 38 TM 92593 0 0 6 0
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
3 67 TM 92593 0 0 6 0
3 rows selected.
SYS@orcl_3 SQL>
SID 75 (inst 1) holds the lock, the BLOCK value is 2, meaning the lock is not blocking
any blocked processes on the local node, but it may or may not be blocking processes
ble
on remote nodes. SID 38 (inst 2) and SID 67 (inst 3) are waiting for the lock in
fe r a
exclusive mode (LMODE 6).
ans
n - t r
o
an
15. Go to the terminal window for instance 1 (host02 in this example). Issue a rollback. When
s
ha deฺ
complete, go back to the first terminal window (host01) and query GV$LOCK again. What
)
do you see now?
c o m ui
a il ent G
ฺ
SYS@orcl_1 SQL> rollback;
@ gm tud
Rollback complete.bir
bd this S
t h ka use
( m aSQL> to
b i r ense
SYS@orcl_1
u Ka
l SYS@orcl_3lic SQL> /
a n
Ahs Hit Any Key to Continue
3 67 TM 92593 0 0 6 0
2 rows selected.
SYS@orcl_3 SQL>
SID 38 (inst 1) holds the lock, the BLOCK value is 2, meaning the lock is not blocking
any blocked processes on the local node, but it may or may not be blocking processes
on remote nodes. SID 67 (inst 3) is waiting for the lock in exclusive mode (LMODE 6).
Rollback complete.
SYS@orcl_2 SQL>
SYS@orcl_3 SQL> /
Hit Any Key to Continue
ble
INST_ID SID TY ID1 ID2 LMODE REQUEST BLOCK
fe r a
------- ------ -- ------ ------- ----- -------
an
------s
3 67 TM 92593 0 6 n
0 - t r 2
a no
h a s ฺ
1 row selected.
o m )
u i de
a ilฺc ent G
SYS@orcl_3 SQL>
@ gm tud
SID 67 (inst 3) now holds theb d the BLOCK
i s S value is mode 2.
i r lock,
h
h k ab se t
a
17. Go to the terminal window u 3, (host01 and SID 67 in this example). Issue a
t fortoinstance
i
rollback. When
m
r (complete,
sego back to the first terminal window (host01) and query GV$LOCK
b e n
Ka do lyou
again. What
u l ic see now?
san
SYS@orcl_3 SQL> rollback;
Ah Rollback complete.
SYS@orcl_3 SQL>
SYS@orcl_3 SQL> /
no rows selected
SYS@orcl_3 SQL>
h san
A 3. Start SQL*Plus and determine the SID. Issue the SQL statement below to force result
cache creation for the HR.EMPLOYEES table. Find the object ID for the table by querying
DBA_OBJECTS.
[oracle@host01 less_07]$ sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
OBJECT_ID
----------
92593
1 row selected.
ble
SYS@orcl_3 SQL>
fe r a
t r a ns
o n
4. Query DBA_TABLES to confirm that a result cache has been enabled for the-EMPLOYEES
table.
s an
SYS@orcl_3 SQL> col owner format a10
) ha deฺ
SYS@orcl_3 SQL> col table_name formatma15
c o u i
ฺ
SYS@orcl_3 SQL> col result_cacheil format ta15 G
a den result_cache from
SYS@orcl_3 SQL> select owner, g mtable_name,
tu
d @ s S
irb thi
dba_tables where table_name = 'EMPLOYEES';
a b
se
Hit Any Key to Continue
t h k u
a
OWNER (m TABLE_NAME
to
i r n s e RESULT_CACHE
l K ab lice--------------- ---------------
----------
a n u HR EMPLOYEES FORCE
Ahs
1 row selected.
SYS@orcl_3 SQL>
5. Let’s flush the results cache for all the three instances. Start with the instance running on
host01, then open terminal windows to host02 and host03, open a SQL*Plus
connection to the local instance, and flush the results cache for them also.
SYS@orcl_3 SQL> exec dbms_result_cache.flush;
SYS@orcl_3 SQL>
@ gm tud
b d i s S
i r
PL/SQL procedure successfully
h completed.
h k ab se t
SYS@orcl_1 a t
SQL>
t o u
i m
r ( ense
b
n u l Ka lic
hs a [vncuser@classsroom_pc ~]$ ssh oracle@host03
A oracle@host03's password:
Last login: Wed Dec 10 17:47:14 2014 from 192.0.2.1
SYS@orcl_2 SQL>
h k s e
u Failure
1024
a t
Create
t o
Count 0
i m
r ( eCreatese Count Success
b n 0
Execution Plan
----------------------------------------------------------
1 - column-count=11; dependencies=(HR.EMPLOYEES);
name="select * from hr.employees"
Statistics
----------------------------------------------------------
75 recursive calls
ble
0 db block gets
fe r a
189 consistent gets
ans
19 physical reads
n - t r
0 redo size
a no
10121 bytes sent via SQL*Net to client
h a s ฺ
628 bytes received via SQL*Net from client
o m )
u i de
ilฺc ent G
9 SQL*Net roundtrips to/from client
a
gm tud
5 sorts (memory)
0 sorts (disk)
b d @ s S
i r h i
ab se t
107 rows processed
h k u
t set tautotrace
SYS@orcl_3 m a
( SQL>nse
SQL> o off
i r
l K ab icphysical
SYS@orcl_3
the value lfor
e
n u
Note reads and the step for the result cache in the explain plan.
sa
Ah 8. Again, query GV$_RESULT_CACHE_STATISTICS and re-check results cache statistics for
all the three instances.
SYS@orcl_3 SQL> select inst_id, name, value from
gv$result_cache_statistics order by 1,2;
Hit Any Key to Continue
Invalidation Count 0
Latch (Share) 0
Result Size Maximum (Blocks) 193
SYS@orcl_3 SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 1445457117
ble
fe r a
----------------------------------------------------------------------------------------
ans
|Id | Operation | Name |Rows |Bytes|Cost (%CPU)| Time |
n - t r
no
----------------------------------------------------------------------------------------
a
| 0 | SELECT STATEMENT
| 1 | RESULT CACHE
|
| afz18h8m8pm02td181yj8 |
h | s ฺ
| 107 | 7383|
a |
3 (0)| 00:00:01 |
| |
| 2 | TABLE ACCESS FULL| EMPLOYEES
o m u i de 3 (0)| 00:00:01 |
| ) 107| 7383|
ilฺc ent G
----------------------------------------------------------------------------------------
a
Result Cache Information@ gm tud by operation id):
b d i s S
(identified
i r t h
ab sedependencies=(HR.EMPLOYEES);
------------------------------------------------------
h k u
t * fromto hr.employees"
1 - column-count=11;
name="select
m a
b i r ( ense
u Ka
l Statistics lic
a n
hs
----------------------------------------------------------
A 0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
10121 bytes sent via SQL*Net to client
628 bytes received via SQL*Net from client
9 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
107 rows processed
gm tud
Find Count 0
Global Hit Count
b d @ s S 0
i r h i
ab se t
Global Miss Count 0
t h k
Hash Chain Length
u 0
m a t o
r ( ense
Invalidation Count 0
b i
l Ka
Latch (Share) 0
u lic
Result Size Maximum (Blocks) 193
a n
Ahs 2 Block Count Current 0
Block Count Maximum 3872
Block Size (Bytes) 1024
Create Count Failure 0
Create Count Success 0
Delete Count Invalid 0
Delete Count Valid 0
Find Copy Count 0
Find Count 0
Global Hit Count 0
Global Miss Count 0
Hash Chain Length 0
Invalidation Count 0
Latch (Share) 0
Result Size Maximum (Blocks) 193
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
@ gm tud
b d by updating
11. Next, let’s invalidate the resultsrcache i s S the EMPLOYEES table.
i t
b hr.employeesh
SYS@orcl_3 SQL>ka update s e set salary = salary + 0;
a t h u
( m e to
107 b
a ir updated.
rows
c e ns
u l K li
san SYS@orcl_3 SQL> commit;
Ah
Commit complete.
SYS@orcl_3 SQL>
12. Set autotrace as shown below and repeat the EMPLOYEES query. What do you observe?
SYS@orcl_3 SQL> set autotrace traceonly
Execution Plan
----------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
----------------------------------------------------------------------------------------
|Id | Operation | Name | Rows | Bytes| Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 107 | 7383 | 3 (0 | 00:00:01 |
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1 - column-count=11; dependencies=(HR.EMPLOYEES);
name="select * from hr.employees"
ble
Statistics fe r a
ans
----------------------------------------------------------
n - t r
0 recursive calls o
0 db block gets
s an
15 consistent gets
) ha deฺ
0 physical reads
c o m ui
0 redo size a il ent G
ฺ
gm tud
10121 bytes sent via SQL*Net to client
@
b d i s S
i r
628 bytes received via SQL*Net from client
h
k ab se t
9 SQL*Net roundtrips to/from client
h
a t t o
0 sorts (memory) u
i m
r ( ense
b 0 sorts (disk)
n u l Ka lic
107 rows processed
hs a
A SYS@orcl_3 SQL>
The result cache entry for this statement has been repopulated. This is apparent from the
execution plan as consistent gets has been incremented and is now 15.
Find Count 0
Global Hit Count 0
Global Miss Count 0
Hash Chain Length 0
Invalidation Count 0
Latch (Share) 0
Result Size Maximum (Blocks) 193
ble
2 Block Count Current 0
fe r a
Block Count Maximum 3872
ans
Block Size (Bytes) 1024
n - t r
o
Create Count Failure
s an 0
Create Count Success
) ha deฺ 0
Delete Count Invalid
c o m ui 0
Delete Count Valid
a il ent G
ฺ 0
Find Copy Count
@ gm tud 0
Find Count
b d i s S 0
i r h
ab se t
Global Hit Count 0
t h k
Global Miss Count
u 0
m a t o
Hash Chain Length 0
b i r ( ense
Invalidation Count 0
14. Rerun the EMPLOYEES query and see if the newly cached results will be used.
SYS@orcl_3 SQL> set autotrace traceonly
ka use
EMPLOYEES | 107 | 7383 | 3 (0)| 00:00:01 |
t h
----------------------------------------------------------------------------------------
a
( m e to
bir Cache e s
nInformation
K a
Result
l i c (identified by operation id):
l ------------------------------------------------------
a n u
Ahs 1 - column-count=11; dependencies=(HR.EMPLOYEES);
name="select * from hr.employees"
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
10121 bytes sent via SQL*Net to client
628 bytes received via SQL*Net from client
9 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
SYS@orcl_3 SQL>
From the statistics, we can see that no reads or block gets are performed. Looking at the
explain plan shows us that the newly cached results were used instead.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
i m
r ( ense
Find Count 0
b
l Ka lic
Global Hit Count 0
Execution Plan
----------------------------------------------------------
Plan hash value: 1445457117
----------------------------------------------------------------------------------------
|Id| Operation | Name |Rows |Bytes|Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
|0| SELECT STATEMENT | | 107 |7383 | 3 (0)| 00:00:01 |
|1| RESULT CACHE | afz18h8bm8pm02td181yj8udn4 | | | | |
|2| TABLE ACCESS FULL| EMPLOYEES | 107 |7383 | 3 (0)| 00:00:01 |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
1 - column-count=11; dependencies=(HR.EMPLOYEES);
name="select * from hr.employees"
Statistics
----------------------------------------------------------
189 recursive calls
0 db block gets
ble
290 consistent gets
fe r a
12 physical reads
ans
0 redo size
n - t r
10121 bytes sent via SQL*Net to client
a no
628 bytes received via SQL*Net from client
h a s ฺ
9 SQL*Net roundtrips to/from client
o m )
u i de
9 sorts (memory)
a ilฺc ent G
0 sorts (disk)
@ gm tud
107 rows processed
b d i s S
i r h
h k ab se t
SYS@orcl_1 SQL>
a t t o u
m
ir ( we
From the statistics sesee that I/O is being performed and the local result cache entry
can
is built. ab e n
u l K lic
s17.anAgain, query GV$_RESULT_CACHE_STATISTICS from the host01 (instance 3) terminal
Ah session and re-check results cache statistics for all three instances. You can do this by
entering “/” and then pressing Enter. What do you see?
SYS@orcl_3 SQL> /
Hit Any Key to Continue
Latch (Share) 0
Result Size Maximum (Blocks) 193
SYS@orcl_3 SQL>
18. Now, update the EMPLOYEES table on instance 1 and commit. When the commit is
complete, rerun the EMPLOYEES query. What do you see?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
Commit complete.
fe r a
ans
SYS@orcl_1 SQL> set autotrace traceonly n - t r
a no
SYS@orcl_1 SQL> select * from hr.employees;
h a s ฺ
o m )
u i de
107 rows selected.
a ilฺc ent G
@ gm tud
Execution Plan b d i s S
i r h
h k ab se t
----------------------------------------------------------
a
Plan hash value: t 1445457117
t o u
i m
r ( ense
b
u KaOperation lic
----------------------------------------------------------------------------------------
l |Id|
a n | Name |Rows|Bytes |Cost (%CPU)| Time |
hs
----------------------------------------------------------------------------------------
A |0 | SELECT STATEMENT |
|1 | RESULT CACHE
|107 |7383 |
| afz18h8bm8pm02td181yj8udn4 | | |
3 (0)| 00:00:01 |
| |
|2 | TABLE ACCESS FULL| EMPLOYEES |107 |7383 | 3 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
1 - column-count=11; dependencies=(HR.EMPLOYEES);
name="select * from hr.employees"
Statistics
----------------------------------------------------------
4 recursive calls
0 db block gets
a n u Find Count 0
20. Go to the third instance (orcl_2 in this example) and query the EMPLOYEES table.
SYS@orcl_2 SQL> set autotrace traceonly
SYS@orcl_2 SQL> select * from hr.employees;
Execution Plan
----------------------------------------------------------
Plan hash value: 1445457117
----------------------------------------------------------------------------------------
|Id |Operation | Name |Rows |Bytes |Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
------------------------------------------------------
1 - column-count=11; dependencies=(HR.EMPLOYEES);
name="select * from hr.employees"
Statistics
----------------------------------------------------------
ble
212 recursive calls
fe r a
0 db block gets
ans
n - t r
315 consistent gets
o
17 physical reads
s an
0 redo size
) ha deฺ
10121 bytes sent via SQL*Net to client
c o m ui
a il ent G
ฺ
629 bytes received via SQL*Net from client
gm tud
9 SQL*Net roundtrips to/from client
@
b d i s S
9 sorts (memory)
i r h
k ab se t
0 sorts (disk)
h
a t t o
107 rows processed u
i m
r ( ense
b
Ka
l SYS@orcl_2 lic SQL>
u the explain plan we can see that the results cache entry has been created for
a nFrom
Ahs instance 2.
21. Query GV$_RESULT_CACHE_STATISTICS from the host01 (instance 3) terminal session
and re-check results cache statistics. What do you see?
SYS@orcl_3 SQL> /
Hit Any Key to Continue
i m
r ( enseResult Size Maximum (Blocks) 193
b
n u l Ka li3c Block Count Current 32
hs a Block Count Maximum 3872
A Block Size (Bytes) 1024
Create Count Failure 0
Create Count Success 2
Delete Count Invalid 0
Delete Count Valid 0
Find Copy Count 0
Find Count 2
Global Hit Count 0
Global Miss Count 0
Hash Chain Length 1
Invalidation Count 2
Latch (Share) 0
Result Size Maximum (Blocks) 193
SYS@orcl_3 SQL>
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Execution Plan
----------------------------------------------------------
Plan hash value: 1445457117
----------------------------------------------------------------------------------------
ble
| Id | Operation
Time |
| Name | Rows | Bytes | Cost (%CPU)|
fe r a
----------------------------------------------------------------------------------------
ans
|0 |SELECT STATEMENT | | 107 | 7383 | 3
n - t r
(0)| 00:00:01 |
|1 | RESULT CACHE | afz18h8bm8pm02td181yj8udn4 |
|2 | TABLE ACCESS FULL| EMPLOYEES a
|
no
| 107 | 7383 |
|
3 (0)| 00:00:01 |
| |
h a s ฺ
----------------------------------------------------------------------------------------
o m )
u i de
Result Cache Information (identified
a ilฺc ebyntoperation
G id):
gm tud
------------------------------------------------------
@
b i s S
d dependencies=(HR.EMPLOYEES);
i r t h
name="select * kfrom
h ab hr.employees"
1 - column-count=11;
s e
a t t o u
i m
r ( ense
b
Statistics
u Ka lic
l ----------------------------------------------------------
a n
hs
0 recursive calls
A 0 db block gets
0 consistent gets
0 physical reads
0 redo size
10121 bytes sent via SQL*Net to client
629 bytes received via SQL*Net from client
9 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
107 rows processed
SYS@orcl_2 SQL>
The explain plan shows that the instance 2 local result cache entry was used. The statistics
section confirms this.
h k ab se t
2a t Count
Block
t o u Current 32
i m
r ( eBlockse Count Maximum 3872
b n
n u l Ka lic Block Size (Bytes) 1024
Find Count 2
Global Hit Count 0
Global Miss Count 0
Hash Chain Length 1
Invalidation Count 2
Latch (Share) 0
Result Size Maximum (Blocks) 193
45 rows selected.
ble
fe r a
SYS@orcl_3 SQL>
t r a ns
o
Looking at the instance 2 statistics, you can see that the Find Count is nown -
1. Now, all three
instances have results cached for the same table.
s an
) ha deฺ
24. Next, update the EMPLOYEES table from instance 2 and
c o mcommit.ui
SYS@orcl_2 SQL> update hr.employees a ฺ t G = salary + 0;
il setensalary
@ gm tud
107 rows updated. irbd i s S
ab se t h
h k
t commit; u
SYS@orcl_2 a t o
i m SQL>
r ( ense
b
u l Ka complete.
Commit lic
san
Ah SYS@orcl_2 SQL>
25. Next, query the result cache stats again. What do you observe?
SYS@orcl_3 SQL> /
Hit Any Key to Continue
Invalidation Count 2
Latch (Share) 0
Result Size Maximum (Blocks) 193
SYS@orcl_3 SQL>
26. To finish, return the EMPLOYEES table result_cache mode back to DEFAULT.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
SYS@orcl_3 SQL>
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 8: RAC
Lesson
Database o m ) i de and
Monitoring
u
a
Tuningilฺc ent G
@ gm tud
b d Chapter
i s S 8
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Practices Overview
This practice is designed to show you how to discover performance problems in your RAC
environment. In this practice, you identify performance issues by using EM Express, and fix
issues in three different steps. At each step, you will generate the same workload to make sure
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
The goal of this practice is to show you how to manually discover performance issues by using
the EM Express performance pages as well as ADDM. This first part generates a workload that
uses a bad RAC application design.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Note that all the necessary scripts for this practice are located in the
/stage/RAC/labs/less_08 directory.
1. Connect to your first node as the oracle user. Be sure to use the –X option. Set up your
environment variables by using the oraenv script. Determine that the Oracle instance is
running on host01. You will need this information throughout these practices.
[vncuser@classroom_pc ~]$ ssh -X oracle@host01
ble
oracle@host01's password:
fe r a
[oracle@host01 ~]$ . oraenv
ans
ORACLE_SID = [oracle] ? orcl
n - t r
The Oracle base has been set to /u01/app/oracle
a no
[oracle@host01 ~]$ ps -ef|grep ora_smon) h
as eฺ
c o u id grep ora_smon
m 00:00:00
oracle 18660 3459 0 17:25 pts/3 ฺ t G
a? il den00:01:06
oracle 31630 1 0 Jan13
g m t u
ora_smon_orcl_3
[oracle@host01 ~]$
b d @ sS
a b i r
e thi
t
2. Execute the setupseq1.sh
a hk oscript usfrom the/stage/RAC/labs/less_08 directory to set
(m nse
up the necessary t
configuration for this practice.
i r
l K ab lice ~]$ cd /stage/RAC/labs/less_08
[oracle@host01
a n u
s
Ah
[oracle@host01 less_08]$ ./setupseq1.sh
Tablespace created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
User created.
Grant succeeded.
drop sequence s
ble
*
fe r a
ans
ERROR at line 1:
n - t r
ORA-02289: sequence does not exist
o
s an
) ha deฺ
drop table s purge
c o m ui
* a il ent G
ฺ
ERROR at line 1:
@ gm tud
b S exist
d doesisnot
ORA-00942: table or view
i r h
h k ab se t
a t t o u
m
( tnspurge
drop irtable e
b e
n u l Ka lic *
hs a ERROR at line 1:
A ORA-00942: table or view does not exist
Table created.
Table created.
Index created.
1 row created.
[oracle@host01 less_08]$
3. From the Oracle window, start a browser and enter the following address:
https://host01:5500/em
Add a security exception, if prompted, and log in to EM Express as sys/sys_password.
Make sure the connection is as SYSDBA.
[oracle@host01 less_08]$ firefox&
ble
[1] 32419
fe r a
[oracle@host01 less_08]$
ans
n - t r
4. Use PL/SQL to create a new AWR snapshot. a no
h a s ฺ
) de
[oracle@host01 less_08]$ ./create_snapshot.sh
o m u i
PL/SQL procedure successfully a ilฺc ent G
completed.
@ gm tud
b d i s S
[oracle@host01 less_08]$
i r h
h k ab se t
5. Open a second m a t to host01
terminal t o u as the oracle user. Change the directory to
b i r ( ense Execute the lockinfo.sh script. This script allows you to
/stage/RAC/labs/less_08.
view K
l a locklicontention
global c issues. Your output should show no transactions for JMW.
u
san [vncuser@classroom_pc ~]$ ssh oracle@host01
Ah oracle@host01's password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
sa nu
Ah
INSTANCE_NAME
----------------
orcl_3
INSTANCE_NAME
----------------
orcl_2
[oracle@host01 less_08]$
PL/SQL procedure successfully completed.
[oracle@host01 less_08]$
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
ble
With the Partitioning, Real Application Clusters, Automatic
fe r a
Storage Management, OLAP,
ans
Advanced Analytics and Real Application Testing options n - t r
a no
SQL>
OBJ NAME or ) h
as eฺ
Sess Op Sys
c o m TY Lock
u id Mode Req Mode
ID USERNAME User ID TERMINAL TRANS_ID
ฺ G
ail dent-- ----------- -----------
m
---- -------- ------- -------- ------------
g ORA$BASE
tu
37 SYS oracle
oracle b d @ s S AE Share
37 SYS
b i r t h iTrans-1 PS Share
37 SYS
t h ka use Trans-3
oracle PS Share
37 SYS
m a t
oracle o Trans-2 PS Share
i
59 JMW
b r ( enoracle se ORA$BASE AE Share
l K a
59 JMW
l i c oracle S TM --Waiting-- Exclusive
14 rows selected.
3) Click the Workload tab. In the Workload Profile graph, place the cursor over the
Transactions line at the current time on the timeline. Transactions should be around
120-140 per second.
4) Click the RAC tab and scroll down to the Instances summary.
5) Looking at the Active Sessions column, you should see that the number of active
sessions on host01 and host02 are similar. Click the instance running on host01
(orcl_3 in this example). This takes you to the Performance Hub for the orcl_3 page.
6) Click the Activity tab, look under the SQL ID column, and then click the SQL identifier
ble
that uses most of the resources. This takes you to the SQL Details page for the
fe r a
corresponding statement. The SQL text should be LOCK TABLE S IN EXCLUSIVE
ans
MODE, and the user should be JMW. Click the Back button to return to the
Performance Hub for the orcl_3 page. n - t r
a no
Under the User Session column, click the User Session ID with the highest activity. The
h a s ฺ
User Name should be JMW. Beneath the Monitored SQL section, drill down on the
o m ) i de
SQL ID under the ID column. You will see that the script running on the first instance is
u
ilฺc ent G
executing a SELECT/UPDATE statement on table S that causes most of the Cluster
a
gm tud
waits. (Place the cursor over the SQL Text to see the entire SQL statement.)
@
b i s S
By using EM Express, you can quickly identify the top waiting SQL statements and the top
d
i r h
waiting sessions on both instances. Here it appears that a SELECT or UPDATE statement on
k ab se t
table S is causing most of the waits for the Cluster wait class.
h
a t t o u
i m
r ( eClick sePerformance, then Performance Hub, and then click the RAC tab.
9. Using EMbExpress,
ata
n
LookK
u l licCache Blocks Received graph. What are your conclusions?
the Global
san1) The Global Cache Blocks Received graph clearly shows that there are a lot of blocks
Ah transferred per second on the system. You should see cumulative transfer rates (both
CR and current blocks) in excess of 500 blocks per second.
10. After the workload finishes, use PL/SQL to create a new AWR snapshot.
[oracle@host01 less_08]$ ./create_snapshot.sh
[oracle@host01 less_08]$
11. Using EM Express, review the latest ADDM run. What are your conclusions?
1) Click Performance, then Performance Hub, and then click the ADDM tab.
2) Find the link for the latest ADDM task under ADDM Tasks and click it. This takes you to
the Automatic Database Diagnostic Monitor (ADDM) page.
Overview
The goal of this practice is to show you how to manually discover performance issues by using
the EM Express performance pages as well as ADDM. In this second part of the practice, you
are going to correct the previously found issue by creating a sequence number instead of by
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
using a table.
Note that all the necessary scripts for this practice are located in the
/stage/RAC/labs/less_08 directory.
1. Execute the setupseq2.sh script to create the necessary objects used for the rest of this
practice.
[oracle@host01 less_08]$ ./setupseq2.sh
ble
fe r a
PL/SQL procedure successfully completed.
ans
n - t r
o
PL/SQL procedure successfully completed. s an
) ha deฺ
c o m ui
a il ent G
ฺ
gm tud
User dropped.
b d @ s S
i r h i
h k ab se t
Tablespace dropped.
a t t o u
i m
r ( ense
b
Ka
ul Tablespace lic created.
sa n
Ah
User created.
Grant succeeded.
drop sequence s
*
ERROR at line 1:
ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
ble
Index created.
fe r a
ans
n - t r
Sequence created. a no
h a s ฺ
o m )
u i de
PL/SQL procedure successfully a ilฺc ent G
completed.
@ gm tud
b d i s S
[oracle@host01 less_08]$
i r h
h k ab se t
2. Using EM Express,aand t connected
t o u as the SYS user, navigate to the Performance page of
m
( nse
your ClusterirDatabase.
b ice and then Performance Hub. Make sure 15 Seconds Refresh is
a Performance,
K
1) Click
l l
u selected from the Auto Refresh drop-down list.
s a n
Ah 3. Use PL/SQL to create a new AWR snapshot.
[oracle@host01 less_08]$ ./create_snapshot.sh
[oracle@host01 less_08]$
5. While the scripts are still executing, look at the Active Sessions graphic. View the workload.
What are your conclusions?
ble
1) Click Performance, and then Performance Hub.
fe r a
2) From there you can now see the Average Active Sessions graph. Make sure 15 ans
Seconds Refresh is selected from the Auto Refresh drop-down list. After a few n - t r
o
waits. s an
seconds, the graphic will clearly show that the Cluster wait classes are causing most
n u l Ka lic
T that causes most of the Cluster waits.
hs a 6) Click Performance, then Performance Hub, and then the Workload tab. Make sure 15
A Seconds Refresh is selected from the Auto Refresh drop-down list. In the Workload
Profile graph, place the cursor over the Transactions line at the current time on the
timeline. Transactions should be in excess of 175 per second.
7) Click Performance, and then Performance Hub. After a while you can see that all
transactions are executed by looking at the Active Sessions graph again. Check the
Oracle terminal window where the workload was started. You should see two “PL/SQL
procedure successfully completed.” messages, indicating the workload has finished.
6. After the workload finishes, use PL/SQL to create a new AWR snapshot.
[oracle@host01 less_08]$ ./create_snapshot.sh
[oracle@host01 less_08]$
cluster. This is your first entry point before drilling down to specific instances. From
there, investigate the Top SQL Statements, Sequence Usage, and Unusual
“Concurrency” Wait Event findings.
4) The Top SQL Statements should reveal an INSERT INTO T command using
sequence S as a possible problem to investigate. Click the Back button to return to the
ADDM report.
5) Click Sequence Usage. The Sequence Usage finding reveals that you should use a
larger cache size for your hot sequences. Click the Back button to return to the ADDM
ble
report.
fe r a
6) Click Unusual “Concurrency” Wait Event. The Unusual “Concurrency” Wait Event
ans
finding asks you to investigate the cause for high “row cache lock” waits. Refer to the
n - t r
Oracle Database Reference for the description of this wait event. Click the Back button.
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
The goal of this practice is to show you how to manually discover performance issues by using
the EM Express performance pages as well as ADDM. This last part generates the same
workload as in the previous practice, but uses more cache entries for sequence number S.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Note that all the necessary scripts for this practice are located in the
/stage/RAC/labs/less_08 directory.
1. Execute the setupseq3.sh script to create the necessary objects used for the rest of this
practice.
[oracle@host01 less_08]$ ./setupseq3.sh
ble
PL/SQL procedure successfully completed.
fe r a
ans
n - t r
o
an
PL/SQL procedure successfully completed.
s
ha deฺ
)
m ui
c o
User dropped.
a il ent G
ฺ
@ gm tud
b d i s S
i r h
Tablespace dropped.
h k ab se t
a t t o u
i m
r ( ecreated.
se
b n
l Ka
Tablespace
u lic
a n
Ahs User created.
Grant succeeded.
drop sequence s
*
ERROR at line 1:
ORA-02289: sequence does not exist
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Table created.
Index created.
ble
fe r a
ans
n - t r
Sequence created.
o
s an
) ha deฺ
PL/SQL procedure successfully completed.
c o m ui
a il ent G
ฺ
[oracle@host01 less_08]$ gm
d @ S tud
b i rb this
2. Use PL/SQL to create ak
h a AWRssnapshot.
new e
t
a less_08]$
to u
i r ( m
[oracle@host01
s e ./create_snapshot.sh
a b icen
u l K
PL/SQL l
procedure successfully completed.
san
Ah [oracle@host01 less_08]$
[oracle@host01 less_08]$
4. Until the scripts are executed, look at the Active Sessions graphic. What are your
ble
conclusions?
fe r a
1) Click Performance, and then Performance Hub. Make sure 15 Seconds Refresh is
ans
selected from the Auto Refresh drop-down list. After all the scripts have finished their
n - t r
no
execution, the Active Sessions graph will clearly show that there are no significant
a
waits on your cluster.
h a s ฺ
o m )
u de
2) Next, click the Workload tab. In the Workload Profile graph, place the cursor over the
i
Transactions line at the current time on the timeline. After a few moments, transactions
a ilฺc ent G
should be in excess of 1000 per second.
@ gm tud
5. After the workload finishes, userb
PL/SQL s S a new AWR snapshot.
d toicreate
i t h
ab se./create_snapshot.sh
[oracle@host01 kless_08]$
a t h o u
m t
( nse successfully completed.
b
PL/SQLi r procedure
l K a l ice
a n u [oracle@host01 less_08]$
s
Ah
6. Using EM Express, review the latest ADDM run. What are your conclusions?
1) Click Performance, then Performance Hub, and then the ADDM tab.
2) Find the link for the latest ADDM task under ADDM Tasks and click it. This takes you to
the Automatic Database Diagnostic Monitor (ADDM) page.
3) On the Automatic Database Diagnostic Monitor (ADDM) page, the Findings section
shows you the consolidation of ADDM reports from all instances running in your
cluster. In the DB Time Breakdown By Instance section, drill down on the task link for
orcl_3. From there, investigate the Buffer Busy findings. You should no longer see the
Sequence Usage, nor specific instances impacted.
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 9:
Lesson
m ) i e
dAvailability
Managing c o High
G u of
i l
a den ฺ t
Services
m
@ g tu9
d s S
a b irb thi Chapter
t h k u se
( m a to
e
a bir icens
n u lK l
hs a
A
Practices Overview
In these practices, you will create, manage, and monitor services.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice, you will create a service called prod1. You then observe what happens to your
service when you terminate the instances on which it is running.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Ahs
[oracle@host01 less_09]$
4) Add the following entry for the PROD1 service in the tnsnames.ora on all three
hosts.
prod1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =
cluster01-scan.cluster01.example.com)(PORT =
1521))(LOAD_BALANCE = YES)(CONNECT_DATA = (SERVER =
DEDICATED)(SERVICE_NAME = prod1)))
l K ab tnsnames.ora
PROD1
l ice entry completed for HOST03
nu
sa
Ah [oracle@host01 less_09]$
2. Use the srvctl command to check the status of the new service. On which host is your
service running? (It may be different from the example below)
[oracle@host01 less_09]$ srvctl status service -db ORCL -s prod1
Service prod1 is running on nodes: host02
[oracle@host01 ~]$
3. Change the user to grid, set the environment, and check the status of the PROD1 service
using CRSCTL.
[oracle@host01 less_09]$ su - grid
Password:
----------------------------------------------------------------
Local Resources
----------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE host01 STABLE
ONLINE ONLINE host02 STABLE
ONLINE ONLINE host03 STABLE
ora.FRA.dg
ble
ONLINE ONLINE host01 STABLE
fe r a
ans
ONLINE ONLINE host02 STABLE
n - t r
ONLINE ONLINE host03 STABLE
o
ora.LISTENER.lsnr
s an
ONLINE ONLINE host01
) ha deฺ
STABLE
ONLINE ONLINE host02
c o m ui
STABLE
ONLINE ONLINE a il ent G
host03 ฺ STABLE
ora.net1.network
@ gm tud
b d i s S
i r
ONLINE ONLINE
h host01 STABLE
h k ab se t
ONLINE ONLINE host02 STABLE
a t t o
ONLINE ONLINEu host03 STABLE
i
ora.ons
m
r ( ense
b
n u l Ka lic ONLINE ONLINE host01 STABLE
Started,STABLE
ora.cvu
1 OFFLINE OFFLINE STABLE
ora.gns
1 ONLINE ONLINE host01 STABLE
ora.gns.vip
1 ONLINE ONLINE host01 STABLE
ble
ora.host01.vip
fe r a
1 ONLINE ONLINE host01 STABLE
ans
ora.host02.vip
n - t r
o STABLE
an
1 ONLINE ONLINE host02
ora.host03.vip s
ha deฺ
1 ONLINE ONLINE )
host03
m ui STABLE
ฺ c o G
ora.mgmtdb
a il host01n t
1 ONLINE ONLINE
@ gm tude Open,STABLE
ora.oc4j
i r b dONLINEis S host01
1
b
ONLINE
a e th STABLE
ora.orcl.db k
th ONLINE usONLINE
a
(m nsONLINEt o
i
1
r e host02 Open,STABLE
a b ice
2 ONLINE host03 Open,STABLE
u l K 3 l ONLINE ONLINE host01 Open,STABLE
a n
Ahs ora.orcl.prod1.svc
1 ONLINE ONLINE host02 STABLE
ora.scan1.vip
1 ONLINE ONLINE host02 STABLE
ora.scan2.vip
1 ONLINE ONLINE host03 STABLE
ora.scan3.vip
1 ONLINE ONLINE host01 STABLE
----------------------------------------------------------------
Connected to:
ble
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production fe r a
ans
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP, n - t r
Advanced Analytics and Real Application Testing options a no
h a s ฺ
SQL> select instance_name from v$instance;
o m )
u i de
a ilฺc ent G
INSTANCE_NAME
@ gm tud
b d i s S
----------------
i r h
orcl_1
h k ab se t
a t t o u
i
SQL> exit m
r ( ense
b
Ka lic from Oracle Database 12c Enterprise Edition
l Disconnected Release
anu
12.1.0.2.0 - 64bit Production
s
Ah With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
5. From a terminal session on the node hosting the PROD1 service, as the oracle user,
crash the instance on that node. In this example, the service is running on host02. Use
ssh to log in to the host, find the database pmon process and kill the ora_pmon_orcl_n
process. Use the pkill -9 –f ora_pmon_orcl_n command to crash the database
instance. The orcl_1 instance will crash and the Clusterware services will restart it very
quickly. Exit back to host01.
bl e
e
6. Use SRVCTL to check the status of the PROD1 service. Where is the service runningfnow?r a
n s
running on the system hosting the service? n - tra
In the example below, the service has been failed over to host03. What instance is
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
INSTANCE_NAME
----------------
orcl_2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
ble
[oracle@host01 less_09]$ srvctl status database -db orcl
fe r a
Instance orcl_1 is running on node host02
ans
Instance orcl_2 is running on node host03
n - t r
Instance orcl_3 is running on node host01
a no
h a s ฺ
[oracle@host01 less_09]$
o m )
u i de
a ilฺc ent G
8. Use SRVCTL to relocate the PROD1 service
@ gm backtutodthe original host.
[oracle@host01 less_09]$ b d srvctl
i s Srelocate service -db orcl -
i r h
service PROD1 -c host03
h k ab se t -n host02
a t t o u
m
r ( ense
[oracle@host01
i less_09]$
b
u l Ka lic
san
9. Verify that the PROD1 service has been relocated to the host specified in the previous step.
Ah
[oracle@host01 less_09]$ srvctl status service -db orcl
Service PROD1 is running on nodes: host02
[oracle@host01 less_09]$
Overview
In this practice, you will use EM Express to determine the amount of resources used by
sessions executing under a particular service.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. Connect to your first node as the oracle user. Set up your environment variables using
the oraenv script. Change directory to /stage/RAC/labs/less_09. Execute the
createuser.sh script. This script creates a new user called jmw identified by the
password jmw. The default tablespace of this user is USERS, and its temporary tablespace
is TEMP. This new user has the CONNECT, RESOURCE, and DBA roles.
[vncuser@classroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
ble
fe r a
[oracle@host01 ~]$ . oraenv
ans
ORACLE_SID = [oracle] ? orcl
n - t r
The Oracle base has been set to /u01/app/oracle
a no
h a s ฺ
[oracle@host01 ~]cd /stage/RAC/labs/less_09
o m )
u i de
c
[oracle@host01 less_09]$ catm ailฺ dent G
createuser.sh
@ g tu
export HOST=`hostname -s`
d s S
b irb thi
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
a
t h k u se
export ORACLE_SID=`$ORACLE_HOME/bin/srvctl status database -db
a
orcl|grepm$HOST|cut
( nse t o -f2 -d" "`
b i r PATH=$PATH:$ORACLE_HOME/bin
lice
export
n u l Ka
hs a
A /u01/app/oracle/product/12.1.0/dbhome_1/bin/sqlplus -s /NOLOG
<<EOF
connect / as sysdba
drop user jmw cascade;
create user jmw identified by jmw default tablespace users
temporary tablespace temp;
grant connect, resource, dba to jmw;
EOF
User dropped.
Grant succeeded.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
[oracle@host01 less_09]$
2. Open a second terminal to your first node as the oracle user. Be sure to use the –X
option. Set up your environment variables using the oraenv script. Next, start Firefox and
enter the following address: https://host01:5500/em
Log in to EM Express as sys/sys_password as SYSDBA.
[vncuser@classroom_pc ~]$ ssh -X oracle@host01
ble
oracle@host01's password:
fe r a
ans
[oracle@host01 ~]$ . oraenv n - t r
ORACLE_SID = [oracle] ? orcl a no
The Oracle base has been set to /u01/app/oracle h a s ฺ
o m )
u i de
[oracle@host01 ~]$ firefox&
a ilฺc ent G
@ gm tud
[oracle@host01 ~]$ bd i s S
i r h
h k ab se t
a t session,
3. From the first terminal t o u
connect to prod1 as jmw using SQL*Plus. When
m
r ( enthe
connected, idetermine seinstance on which your session is currently running.
ThenK
b
a thelicfollowing query:
execute
u l
san
select count(*) from dba_objects,dba_objects,dba_objects
Ah Do not wait; instead, proceed with the next step.
[oracle@host01 less_09]$ sqlplus jmw/jmw_password@PROD1
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl_1
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
h k
gc cr blocks receivedab se t 2
a t t o u
i m
gc cr block receive time
r ( ense
0
b
gc current blocks received 0
n u l Ka lic
opened cursors cumulative 242
logons cumulative 1
sql execute elapsed time 884654643
user commits 0
28 rows selected.
SQL> exit
ble
[oracle@host01 ~]$
fe r a
t r a ns
5. You can also use EM Express to view service activity. Click Performance, o n -
then
Performance Hub, and then the Activity tab. On the activity timelineagraph, n select Session
Identifiers > Service from the pull-down list. s
a eฺ
hIdentifiers
On the bottom-left summary graphic, again choose Session m ) i d > Service from the
o u
pull-down list.
On the bottom-right summary graphic, chooseaSession ilฺc eIdentifiers
n t G > User ID from the pull-
down list. Spend a few moments and monitor
@ gm thetservice ud activity for the PROD1 service.
d S
isissteadily
You should see the PROD1 service
b
Go to the first terminal window. i rIfbtheactivity
t
queryh
increase.
still running, stop it by pressing Ctrl + C.
Returning to EM Express,t h kayou should
u sesee the service activity for PROD1 steadily decrease
until it disappears
( m a the monitored
from to list due to inactivity.
i r s e
a b icen
l
6. Stop
u Kthe PROD1l service and remove it.
san [oracle@host01 ~]$ srvctl stop service -d orcl -s PROD1
Ah
[oracle@host01 ~]$ srvctl remove service -d orcl -s PROD1
[oracle@host01 ~]$
7. Dismiss Firefox and EM Express and close all terminal windows opened for this practice.
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 10: High
Lesson
Availability
o m )
for
u i de
Connections
c G
ilฺApplications
t
and a n
@ gm tude
b d Chapter
i s S 10
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 1
Practices for Lesson 10: Overview
Practices Overview
In this practice, you will explore Application Continuity.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 2
Practice 10-1: Using Application Continuity
Overview
In this practice, you will use Application Continuity in a RAC environment to demonstrate how
Application Continuity helps an application to seamlessly recover after the failure of a RAC
instance.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. From your desktop, open a terminal and become the root user and shut down host03.
[vncuser@classroom_pc ~]$ su -
Password:
[root@classroom_pc ~]# xm shutdown host03
[root@classroom_pc ~]#
ble
fe r a
ans
2. Establish a terminal session connected to host01 using the oracle OS user.
n - t r
o
[vncuser@classroom_pc ~]$ ssh oracle@host01
s an
ha deฺ
oracle@host01's password:
[oracle@host01 ~]$ )
m ui
c o
a il ent G
ฺ
3. Configure the environment by using the g m tscript.
oraenv
ud
d @ S
[oracle@host01 ~]$ . b
b i r ? orcl
oraenv
t h is
a
useset to /u01/app/oracle
ORACLE_SID = [oracle]
The Oracle a thk hasto been
base
i r (m ns~]$
[oracle@host01 e
b e
u l Ka lic
s4.anConfirm that two instances of the RAC database are up and running.
Ah [oracle@host01 ~]$ srvctl status database -db orcl
Instance orcl_1 is running on node host02
Instance orcl_3 is running on node host01
[oracle@host01 ~]$
5. Navigate to the directory that contains the files for this practice.
[oracle@host01 ~]$ cd /stage/RAC/labs/less_10
[oracle@ host01 less_10]$
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 3
6. Create a database service on the orcl database. Configure the service for use in
conjunction with Application Continuity.
[oracle@host01 less_10]$ srvctl add service -db orcl -service
actest -serverpool ora.orcldb -cardinality singleton -
failovertype TRANSACTION -commit_outcome TRUE -failoverretry 50
-failoverdelay 5 -retention 86400 -replay_init_time 1800 -
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
notification TRUE
[oracle@host01 less_10]$
a thk to u~]$
[vncuser@classroom_pc
s ssh oracle@host02
i r (m nsepassword:
ab lice
oracle@host02's
l K
u [oracle@host02 ~]$ cd /stage/RAC/labs/less_10
s a n
Ah [oracle@host02 less_10]$
10. Configure the prompt in your ADMIN session as shown below. This will help you to
differentiate between your terminal sessions as you progress through this practice.
[oracle@host02 less_10]$ export PS1='[HOST02 ADMIN] $ '
HOST02 ADMIN $
11. Configure the environment in your ADMIN session by using the oraenv script. Enter orcl
when you are prompted for an ORACLE_SID value.
[HOST02 ADMIN] $ . oraenv
ORACLE_SID = [oracle] ? orcl
The Oracle base has been set to /u01/app/oracle
[HOST02 ADMIN] $
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 4
12. Back in your first session, examine the scripts that you will soon use to execute the practice
application. Notice that both scripts execute the same application code (in actest.jar).
The only difference is that each script references a different properties file.
[oracle@host01 less_10]$ cat runnoreplay
java -classpath
./actest.jar:$ORACLE_HOME/ucp/lib/ucp.jar:$ORACLE_HOME/jdbc/lib/
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
b d @ s Sno replay
i r h i
ab se t
# Use standard 12.1 datasource
h k u
datasource=oracle.jdbc.pool.OracleDataSource
t
m a t o
b i r ( ense
url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=
a lic
ul K
cluster01-
n
hsa
scan.cluster01.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NA
ME=actest)))
A
# UCP setting:
ucp_pool_size=2
ucp_validate_connection_on_borrow=true
ucp_connection_wait_timeout=60
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 5
verbose=true
[oracle@host01 less_10]$
username=scott
password=tiger
autoCommit=false
url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=
ble
cluster01-
fe r a
scan.cluster01.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NA
ans
ME=actest)))
n - t r
a no
# UCP setting:
h a s ฺ
) de
ucp_pool_size=2
o m u i
ilฺc ent G
ucp_validate_connection_on_borrow=true
ucp_connection_wait_timeout=60 a
@ gm tud
b S results from the database.
dprocessisthe
# Think Time taken ito r h
k
Time in milliseconds.
h ab se t
# -1 means a t sleep.
no
t o u
i m
r ( ense
thread_think_time=20
a b
ul K lic
n
hsa
# Number of concurrent threads running in the application
A # UCP is tuned to have MAX and MIN limit set to this
number_of_threads=6
verbose=true
[oracle@host01 less_10]$
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 6
Next, you will execute the practice Java application twice. Once without the benefit of
Application Continuity, and once with Application Continuity enabled. Notice that you will
execute the same application and the only difference is the JDBC data source that is used
on each occasion. The source files containing the application code are contained in the src
directory. Feel free to examine the application code if you like.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
14. Execute the practice application without the benefit of Application Continuity. Notice that
while the application runs, a periodic status message is displayed.
[oracle@host01 less_10]$ ./runnoreplay
######################################################
Connecting to
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=clus
ter01-
scan.cluster01.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NA
ble
ME=actest)))
fe r a
# of Threads : 6
ans
UCP pool size : 2
n - t r
Thread think time : 20 ms
a no
######################################################
h a s ฺ
o m )
u i de38 ms
2 active connections, avg response
a ilฺc time
time
n t G
from db
2 active connections, avg response
g m tude from db 23 ms
b d @ sS
a b
15. While the application continues r
e thiin the primary window, return to your ADMIN
i to execute
h
session and remind yourself
t k about u swhich node is running the actest service. Then, abort
m on
the database instancea
(Ensure o
thet host running the actest service (host02 in the example
i
shown below). r s e
n you abort the instance on the node running the service and not
that
a bdatabase c e
u l K
the other li node.
16. Return to your primary window and you should see a series of errors caused by aborting
the database instance. This is typical of applications that do not use Application Continuity.
Press Ctrl + C to abort the application.
...
at
oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.borrowConnection
(OracleJDBCConnectionPool.java:1441)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 7
at
oracle.ucp.jdbc.oracle.OracleConnectionConnectionPool.borrowConn
ection(OracleConnectionConnectionPool.java:81)
at
oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceI
mpl.java:1027)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
... 4 more
.Exception occurred while getting connection:
oracle.ucp.UniversalConnectionPoolException: Cannot get
Connection from Datasource: java.sql.SQLRecoverableException:
Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service
requested in connect descriptor
.
ble
0 active connections, avg response time from db 150418377 ms
fe r a
^C
ans
[oracle@host01 less_10]$
n - t r
a no
17. Confirm both RAC database instances are up and running again.
h a s ฺ
[oracle@host01 less_10]$ srvctl status
o m )database
u i de-d orcl
Instance orcl_1 is running on node
a ilฺc host02
e n t G
Instance orcl_3 is running gon mnodetudhost01
b d @ s S
i r h i
h k ab se t
[oracle@host01 less_10]$
at t o u
18. Reexamine the(m e
status of the service. You should observe that the service is
i r
ba differentn s actest
runningaon
l K
service l ice when
was migrated
node compared to what you observed earlier. This is because the
you aborted the database instance earlier in the practice.
n u
sa [oracle@host01 less_10]$ srvctl status service -d orcl -s actest
Ah Service actest is running on nodes: host01
[oracle@host01 less_10]$
19. Execute the practice application with Application Continuity enabled. You should see the
same period status messages as before while the application is running.
[oracle@host01 less_10]$ ./runreplay
######################################################
Connecting to
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=clus
ter01-
scan.cluster01.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NA
ME=actest)))
# of Threads : 6
UCP pool size : 2
Thread think time : 20 ms
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 8
######################################################
20. While the application continues to execute in the primary window, return to your ADMIN
session and remind yourself about which node is now running the actest service. Then,
abort the database instance running the actest service (which is now host01 in the
example shown below). Ensure that you abort the instance on the node running the service
and not the other database node.
[HOST02 ADMIN] $ srvctl status service -d orcl -s actest
Service actest is running on nodes: host01
ble
fe r a
[HOST02 ADMIN] $ srvctl status database -d orcl
ans
Instance orcl_1 is running on node host02
n - t r
Instance orcl_3 is running on node host01
a no
[HOST02 ADMIN] $ ssh host01 pkill -9 -f pmon_orcl_3 h a s ฺ
[HOST02 ADMIN] $ o m )
u i de
a ilฺc ent G
21. Return to your primary window and you g
m tuthat
should see d the application continued in spite of
d @ S
b i b should
the aborted database instance.rYou
t h isseewhen
a pause and then a brief spike in the
h k a
response time, which coincides with
s the
e time the database instance was aborted.
a t
Now you have seen how
t o u
Application Continuity masks the effect of database instance loss
i r (m nse
in a RAC database environment. Press Ctrl + C to abort the application.
l ab liconnections,
2 active
K c e avg response time from db 44 ms
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 9
22. Confirm that both instances are running and the service migrated to the other node as
expected.
[oracle@host01 less_10]$ srvctl status database -d orcl
Instance orcl_1 is running on node host02
Instance orcl_3 is running on node host01
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
[oracle@host01 less_10]$
Practices for Lesson 10: High Availability for Connections and Applications
Chapter 10 - Page 10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 11:
Lesson
Oracle o m )
RAC One
u i deNode
a ilฺc ent G
@ gm
Chapter 11d
tu
d s S
a b irb thi
t h k u se
( m a to
e
a bir icens
n u lK l
hs a
A
Practices Overview
In these practices, you will create a RAC One Node Database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice, you will create a RAC One Node database. You will perform an online database
relocation. Finally, you will convert the RAC One Database to an Oracle RAC database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
1. From a terminal session on your classroom PC, execute ssh oracle@host01 to open a
terminal session on host01 as the oracle user. Set the environment and check the status
of the database.
[vncuser@classroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
san
Instance orcl_3 is running on node host01
[oracle@host01 ~]$
[oracle@host01 ~]$
[oracle@host01 ~]$
6. Use the srvctl utility to check the status of the orcl database.
[oracle@host01 ~]$ srvctl status database -db orcl
Instance orcl_3 is running on node host01
Online relocation: INACTIVE
[oracle@host01 ~]$
relocate database
-timeout <timeout> Online relocation timeout in
minutes
-abort Abort failed online
relocation
-revert Remove target node of failed
online relocation request from the candidate server list of
administrator-managed RAC One Node database
ble
-stopoption <stop_option> Override default shutdown
fe r a
option for running instance (only NORMAL allowed)
ans
-verbose Verbose output
n - t r
-help Print usage
a no
[oracle@host01 ~]$
h a s ฺ
o m )
u i de Use srvctl to
8. In this example, the orcl_3 instance was running
a ilฺc toehost02.
perform an online database relocation from host01
initially
n tG
on host01.
[oracle@host01 ~]$
9. Open another terminal window as oracle, set the environment and issue the srvctl
status database -db orcl command several times to monitor the migration process
until the relocation command finishes in the first terminal.
[vncuser@classroom_pc ~]$ ssh oracle@host01
oracle@host01's password:
[oracle@host01]$
12. Execute the srvctl status service command to view the services configuration.
Note that the serv1 service is running on all nodes. Stop the service and remove it.
[oracle@host01 ~]$ srvctl status service -d orcl
Service serv1 is running on nodes: host01,host02
13. Execute the srvctl config database command to view the database configuration.
[oracle@host01 ~]$ srvctl config database -d orcl
Database unique name: orcl
Database name: orcl
Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/ORCL/PARAMETERFILE/spfile.279.868817789
ble
Password file: +DATA/ORCL/PASSWORD/pwdorcl.276.868816925
fe r a
Domain:
ans
Start options: open
n - t r
o
an
Stop options: immediate
Database role: PRIMARY s
ha deฺ
Management policy: AUTOMATIC )
m ui
c o
Server pools: orcldb
a il ent G
ฺ
gm tud
Disk Groups: DATA,FRA
Mount point paths:
b d @ s S
i r h i
ab se t
Services:
Type: RAC
t h k u
m a t o
r ( ense
Start concurrency:
b i
Stop concurrency:
n u l Ka lic
OSDBA group: dba
[oracle@host01 ~]$
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 12:
Lesson
Multitenant o m ) i de
Architecture
u and
i l ฺ c t G
m a Environment
RAC d e n
@ g tu
d s S
b i rb thi Chapter 12
t h ka use
( m a to
e
a bir icens
n u lK l
hs a
A
Overview
In this practice, you will create a new CDB named cdb1 including one PDB named pdb1. The
CDB is hosted in an existing server pool.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Then you will create another PDB named pdb2 and manage the services to affinitize the PDB
services to instances.
At the end of the practice, you drop the pdb2 PDB.
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice, you will create a new CDB named cdb1 with DBCA.
Pre CDB Creation Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
As root, start host03. Then, remove the existing RAC database. From your classroom
PC desktop, execute ssh –X oracle@host01 to open a terminal session on host01 as
the oracle user. Then navigate to
/u01/app/oracle/product/12.1.0/dbhome_1/bin and execute DBCA.
[vncuser@classroom_pc ~]$ su –
Password:
ble
[root@classroom_pc ~]# xm create host03
fe r a
Using config file "/etc/xen/host03".
ans
Started domain host03 (id=108)
n - t r
a no
*** Wait a few moments for host03 to boot completely
h a s ฺ ****
o m )
u i de
ilฺc ent G
[root@classroom_pc ~]# ssh -X oracle@host01
a
gm tud
oracle@host01's password:
b d @ s S
[oraclec@host01 ~]#ircd
h i
k ab se t
/u01/app/oracle/product/12.1.0/dbhome_1/bin
h
a t t o u
i m
r ( ensbin]$
[oracle@host01 e ./dbca
a b
ul K lic
sa n Step Screen/Page Description Choices or Values
Ah a. Database Operation Select Delete Database. Click Next.
b. Delete Database Select orcl and click Next.
c. Management Options Click Next.
d. Summary Click Finish.
e. Database Configuration You are informed that the instances and
Assistant dialog box datafiles will be deleted. Click Yes to proceed.
f. Database Configuration You are informed that database deletion is
Assistant dialog box complete. Click OK.
g. Progress Page Click Close.
Tasks
1. Start DBCA and perform the following steps.
[oracle@host01 bin]$ ./dbca
d @ s S
a b irb thi Select “General Purpose or Transaction
e
thk to us
Processing.”
Confirm password:
database_administrative_password
Click Next.
h. Step 8: Storage Locations Confirm Storage type is “Automatic Storage
Management (ASM).”
Confirm “Use Common Location for All
Database Files.” in +DATA diskgroup.
ble
Deselect “Specify Fast Recovery Area”.
fe r a
Click Next.
ans
i. Step 9: Database Options Click Next. n - t r
j. Step 10: Initialization a no
Set “Memory Size (SGA and PGA)” to 840 MB.
Parameters h a s ฺ
m )
Select “Use Automatic
i e Management”
Memory
d
o u
a ilฺc“Character
Select
n t GSets.”
de Unicode (AL32UTF8).”
gmSelecttu“Use
b d @ s S Next.
i r h i Click
t Select “Create Database.”
k. k ab Option
Step 11: Creation
h s e
a t t o u
i r m
( nse Click Next.
l. b Step 12:
u l Ka Checkslice Pre Requisite Click Next.
a n
Ahs m. Step 13: Summary Click Finish.
n. Step 14: Progress Page On the Database Configuration Assistant page
(for password management), click Exit.
Click Close.
ble
fe r a
ans
n - t r
a no
h a s ฺ
o m )
u i de
a ilฺc ent G
@ gm tud
2. Explore the CDB instances hosteddon the nodes
b i s Sof the server pool. You will also see that
b
the pdb1 PDB can be accessedi r on anyt h
instance of the CDB just like a non-CDB can be
k a e
th intaoRAC
accessed on any instance
a usenvironment.
i r m seserver pool and its cardinality.
a. Check the(cdb1pool
a b icen bin]$ su - grid
u l K l
[oracle@host01
[oracle@host01 ~]$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
b. Use SRVCTL to know on which nodes the instances of the CDB are running, as you
traditionally do for any non-CDB.
[oracle@host01 ~]$ export
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
[oracle@host01 ~]$ cd $ORACLE_HOME/bin
9841 ora_gcr0_cdb1_3
9843 ora_lck0_cdb1_3
9857 ora_rsmn_cdb1_3
9906 ora_tmon_cdb1_3
9908 ora_tt00_cdb1_3
9960 ora_smco_cdb1_3
9962 ora_w000_cdb1_3
9968 ora_gtx0_cdb1_3
ble
9970 ora_rcbg_cdb1_3
fe r a
ans
9972 ora_ppa7_cdb1_3
n - t r
9987 ora_aqpc_cdb1_3
o
9989 ora_qm02_cdb1_3
s an
9991 ora_q001_cdb1_3
) ha deฺ
9993 ora_q002_cdb1_3
c o m ui
9995 ora_qm05_cdb1_3 a il ent G
ฺ
10013 ora_p000_cdb1_3
@ gm tud
b d i s S
10015 ora_p001_cdb1_3
i r h
k
10017 ora_p002_cdb1_3
h ab se t
a t
10019 ora_p003_cdb1_3
t o u
i m
r ( ense
10319 ora_cjq0_cdb1_3
b
n u l Ka lic
11166 ora_w001_cdb1_3
hs a 11995 ora_w002_cdb1_3
A 13641 ora_p004_cdb1_3
13643 ora_p005_cdb1_3
[oracle@host01 bin]$
c. Use LSNRCTL to list the CDB instances on two nodes of the server pool.
1) Check the services on the first node.
[oracle@host01 bin]$ ./lsnrctl status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.245)(PORT=1521
)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.102)(PORT=1521
)))
Services Summary...
Service "+ASM" has 1 instance(s). ble
fe r a
Instance "+ASM3", status READY, has 1 handler(s) for this
ans
service...
n - t r
Service "cdb1" has 1 instance(s).
o
an
Instance "cdb1_2", status READY, has 1 handler(s) for this
s
service...
) ha deฺ
Service "cdb1XDB" has 1 instance(s).
c o m ui
a il ent G
ฺ
Instance "cdb1_2", status READY, has 1 handler(s) for this
service...
@ gm tud
b d
Service "pdb1" has 1 instance(s).
i s S
i r h
h k ab se t
Instance "cdb1_2", status READY, has 1 handler(s) for this
service...
a t t o u
m
r ( ense
The command completed successfully
i
b
u Ka lic ~]$ exit
l [oracle@host02
a n
Ahs logout
Connection to host02 closed.
[oracle@host01 bin]$
d. Use SRVCTL to stop and restart the CDB as you traditionally would do for any non-
CDB.
[oracle@host01 bin]$ . oraenv
ORACLE_SID = [oracle] ? cdb1_3
ORACLE_HOME = [/home/oracle] ?
/u01/app/oracle/product/12.1.0/dbhome_1
The Oracle base has been set to /u01/app/oracle
[oracle@host01 bin]$ cd
[oracle@host01 ~]$
ble
fe r a
e. Use SQL*Plus to connect to the instances of the cdb1 CDB, check the UNDO
ans
tablespaces and the groups of redo log files, and verify the existence of the pdb1 PDB.
n - t r
1) Check the UNDO tablespaces created in the CDB.
a no
[oracle@host01 ~]$ sqlplus / as sysdba
h a s ฺ
o m )
u i de
Connected to:
a ilฺc ent G
Oracle Database 12c Enterprise
@ gm Editiont u d Release 12.1.0.2.0 -
64bit Production
b d i s S
i r
b OLAP, t h
k a
With the Partitioning, Real
e Application Clusters, Automatic
ApplicationaTesting
us
th to options
Storage Management, Advanced Analytics and Real
i r (m nse
b ice
u Ka SELECT
l SQL> l name, cdb, con_id FROM v$database;
a n
Ahs NAME CDB CON_ID
--------- --- ----------
CDB1 YES 0
INSTANCE_NAME CON_ID
---------------- ----------
cdb1_3 0
CON_NAME
------------------------------
CDB$ROOT
TABLESPACE_NAME CON_ID
------------------------------ ----------
UNDOTBS1 1
UNDOTBS2 1
UNDOTBS3 1
SQL>
ble
2) Check the groups of redo log files created for the three CDB instances. fe r a
ans
SQL> SELECT group#, con_id FROM v$logfile;
n - t r
o
s an
GROUP# CON_ID
) ha deฺ
---------- ----------
c o m ui
2 0
a il ent G
ฺ
1 0
g m tud
5 0 d
b @ s S
i r h i
6
3 thk
ab 0 se t
0
a t o u
i m
r ( ense
4 0
a b
u l 6Krows lic
a n selected.
Ahs SQL>
3) Check the PDB created in the CDB and its open mode. If the PDB is not
opened, open it.
SQL> COL pdb_name format a10
SQL> SELECT pdb_id, pdb_name, guid, status FROM cdb_pdbs;
Session altered.
CON_NAME
------------------------------
ble
PDB1
fe r a
ans
SQL> CONNECT / AS SYSDBA
n - t r
Connected.
a no
h a s ฺ
SQL> SELECT name FROM cdb_services;
o m )
u i de
a ilฺc ent G
gm tud
NAME
b d @ s S
---------------------------------------------------------------
i r h i
ab se t
SYS$BACKGROUND
SYS$USERS
t h k u
cdb1XDB ma t o
cdb1bir
( nse
u l Ka lice
a n
hs
SQL> ALTER PLUGGABLE DATABASE pdb1 OPEN;
A
Pluggable database altered.
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
SQL>
SYS$BACKGROUND
SYS$USERS
SQL> EXIT
f. Switch to the second node to verify the open mode of the PDB in the second instance
of the CDB.
ble
[oracle@host01 ~]$ ssh host02
fe r a
[oracle@host02 ~]$ . oraenv
ans
ORACLE_SID = [oracle] ? cdb1_2
n - t r
ORACLE_HOME = [/home/oracle] ?
a no
/u01/app/oracle/product/12.1.0/dbhome_1
h a s ฺ
The Oracle base has been set to /u01/app/oracle
o m )
u i de
a lฺc nt G
isysdba
gm tude
[oracle@host02 ~]$ sqlplus / as
b d @ s S
Connected to:
b i r h i
t Edition Release 12.1.0.2.0 -
Oracle Databaseka s e
a t h o u
12c Enterprise
64bit Production
m t
b i
With ther ( Partitioning,
e n se Real Application Clusters, Automatic
K a
Storage
l Application c
li Testing optionsAdvanced Analytics and Real
Management, OLAP,
a n u
Ahs
SQL> SELECT name, cdb, con_id FROM v$database;
INSTANCE_NAME CON_ID
---------------- ----------
cdb1_2 0
CON_NAME
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
Session altered.
ble
fe r a
SQL> SELECT name FROM v$services; ans
n - t r
o
NAME
s an
ha deฺ
---------------------------------------------------------------
)
pdb1
c o m ui
a il ent G
ฺ
SQL> exit
@ gm tud
b d i s S
[oracle@host02 ~]$ exit
i r h
logout
h k ab se t
Connection a t host02
to
t o uclosed.
i m
r ( ens~]$
[oracle@host01 e
b
n u l Ka lic
hs a g. Verify that the pdb1 service is accessible from instance cdb1_3 on the first node but
A also from the cdb1_2 instance on the second node and from the cdb1_1 instance on
the third node. First restart the listener.
[oracle@host01 ~]$ su - grid
Password:
Last login: Mon Sep 2 05:16:31 2014 from host01.example.com
[grid@host01 ~]$ . oraenv
ORACLE_SID = [grid] ? +ASM1
The Oracle base has been set to /u01/app/grid
INSTANCE_NAME CON_ID
ble
---------------- ----------
fe r a
ans
cdb1_3 0
n - t r
SQL> show con_name a no
h a s ฺ
CON_NAME o m )
u i de
------------------------------ailฺ
c t G
n
PDB1
@ gm tude
b d i s S
i r h
k ab se t
SQL> CONNECT system@"host02:1521/pdb1"
h
a
Enter password: t t o u
i m
r ( ense
b
ERROR:
u Ka lic
l ORA-01033:ORACLE initialization or shutdown in progress
a n Process ID: 0
Ahs Session ID: 0 Serial Number: 0
Notice that the connection does not complete because pdb1 was opened for instance
cdb1_3 on host01 only. Remember that the clause INSTANCES was not used in the
ALTER PLUGGABLE DATABASE OPEN statement in task 2.e.3).
SQL> CONNECT / AS SYSDBA
Connected.
SQL> ALTER PLUGGABLE DATABASE pdb1 OPEN INSTANCES=('cdb1_2');
INSTANCE_NAME CON_ID
---------------- ----------
cdb1_2 0
CON_NAME
------------------------------
ble
PDB1
fe r a
ans
n - t r
no
SQL> CONNECT system@"host03:1521/pdb1"
Enter password:
s ฺa
ERROR: h a
o m )
u i de
ORA-01033:ORACLE initialization or shutdown in progress
Process ID: 0 a ilฺc ent G
Session ID: 0 Serial Number: 0
@ gm tud
b d i s S
Warning: You areano
i r
b longer h
t connected to ORACLE.
h k u s e
a t t o
i
SQL> EXIT
m
r ( ense
b
Ka
Thel connection
u
ic not complete on host03 because pdb1 was opened for instance
ldoes
sancdb1_3 on host01 and cdb1_2 on host02 only.
Ah
Overview
In this practice, you will clone the pdb1 PDB into a new PDB named pdb2 in the cdb1 CDB.
This operation requires to close and open PDBs on multiple instances of the CDB.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Tasks
1. Connect to the root of the multitenant container database cdb1 on any of the three
instances.
[oracle@host01 ~]$ . oraenv
ORACLE_SID = [cdb1] ? cdb1_3
ORACLE_HOME = [/home/oracle] ?
/u01/app/oracle/product/12.1.0/dbhome_1
ble
The Oracle base has been set to /u01/app/oracle
fe r a
ans
[oracle@host01 ~]$ sqlplus / as sysdba
n - t r
Connected to: a no
h a s ฺ
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
o m )
u i de
a ilฺc ent G
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
@ gm tud
b d i s S
i r h
SQL>
h k ab se t
a t t o u
m
r ( enFiles
2. Use OracleiManaged se to locate the data files of the new pdb2.
b
u l Ka SHOWlicPARAMETER db_create_file_dest
SQL>
san NAME TYPE VALUE
Ah ------------------------------------ ----------- --------------
db_create_file_dest string +DATA
SQL>
NAME OPEN_MODE
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
SQL>
b. Now, open both PDBs in READ WRITE mode on all the CDB instances.
SQL> ALTER PLUGGABLE DATABASE pdb1 CLOSE IMMEDIATE
INSTANCES=ALL;
Session altered.
NAME
---------------------------------------------------------------
pdb2
c. Use LSNRCTL to verify that the new pdb2 service associated to the new PDB in the
CDB instance is automatically started after the PDB is opened. Because the PDB is
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
opened in all the CDB instances, the pdb2 PDB service is started in all the CDB
instances.
[oracle@host01 ~]$ lsnrctl status
hs a (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
A (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.101)(PORT=1521
)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.239)(PORT=1521
)))
Services Summary...
[oracle@host01 ~]$
4. Use the net service name to connect to pdb2 as the system user on any of the three
ble
instances of the CDB.
fe r a
[oracle@host01 ~]$ sqlplus /nolog
ans
SQL> CONNECT system@"host01:1521/pdb2" n - t r
o
Enter password:
s an
Connected.
) ha deฺ
c o m ui
SQL> show con_name a il ent G
ฺ
CON_NAME
@ gm tud
b d i s S
i r
------------------------------
h
PDB2
h k ab se t
a t t o u
i m
r ( ensystem@"host02:1521/pdb2"
SQL> CONNECT se
b
u Ka password:
l Enter lic
a n Connected.
Ahs
SQL> CONNECT system@"host03:1521/pdb2"
Enter password:
Connected.
SQL> EXIT
Overview
In this practice, you will “affinitize” connections to a PDB to one or particular CDB instances.
Because server pools determine which services run together or separately, you can configure
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Tasks
1. Create a dynamic PDB service, mypdb1serv, for the pdb1 PDB in the CDB which will
“affinitize” connections to pdb1 to all the CDB instances.
a. Check the configuration of the server pools.
ble
[oracle@host01 ~]$ srvctl status srvpool
fe r a
Server pool name: Free
ans
Active servers count: 0
n - t r
Server pool name: Generic
a no
Active servers count: 0
h a s ฺ
Server pool name: cdb1pool
o m )
u i de
Active servers count: 3
a ilฺc ent G
[oracle@host01 ~]$
@ gm tud
[oracle@host01 ~]$bisrvctl h is S srvpool -serverpool
rbd tconfig cdb1pool
t
Server pool name:h ka cdb1pool
u se
( m a0, Min:to 0, Max: 3
Importance:
b i r hub e n se
Ka
Category:
u l Candidate licserver names:
a n
Ahs [oracle@host01 ~]$
b. Check the services. You notice that the default services created at PDB creation are
not managed by the clusterware.
[oracle@host01 ~]$ srvctl status service -db cdb1
[oracle@host01 ~]$
[oracle@host01 ~]$ srvctl config service -db cdb1
[oracle@host01 ~]$
c. Create a dynamic PDB service for the pdb1 PDB in the CDB which will “affinitize”
connections to pdb1 to all the CDB instances uniformly.
1) Create the service from the connection on the first node of the server pool.
[oracle@host01 ~]$ srvctl add service -db cdb1 -pdb pdb1 -
service mypdb1serv -policy automatic -serverpool cdb1pool -
cardinality uniform
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Cardinality: UNIFORM
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Global: false
Commit Outcome: false
ble
Failover type:
fe r a
ans
Failover method:
n - t r
TAF failover retries:
o
TAF failover delay:
s an
Connection Load Balancing Goal: LONG
) ha deฺ
Runtime Load Balancing Goal: NONE
c o m ui
TAF policy specification: NONE a il ent G
ฺ
Edition:
@ gm tud
b d i s S
i r
Pluggable database name: pdb1
h
k
Maximum lag time: ANY
h ab se t
a t t
SQL Translation Profile:o u
i m
r ( ense
Retention: 86400 seconds
b
n u l Ka lic
Replay Initiation Time: 300 seconds
2) Check that the PDB service is also created on the two other nodes of the server
pool.
[oracle@host01 ~]$ ssh host02
[oracle@host02 ~]$
[oracle@host02 ~]$ . oraenv
ORACLE_SID = [oracle] ? cdb1_2
ORACLE_HOME = [/home/oracle] ?
/u01/app/oracle/product/12.1.0/dbhome_1
The Oracle base has been set to /u01/app/oracle
You can reiterate the same verification on the third node of the server pool.
[oracle@host01 ~]$ ssh host03
[oracle@host03 ~]$ . oraenv
ORACLE_SID = [oracle] ? cdb1_1
ORACLE_HOME = [/home/oracle] ?
/u01/app/oracle/product/12.1.0/dbhome_1
The Oracle base has been set to /u01/app/oracle
[oracle@host01 ~]$
d. Close the PDB. You will verify that restarting the CDB automatically starts the dynamic
PDB service and opens the associated PDB.
[oracle@host01 ~]$ sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Real Application Clusters, Automatic
Storage Management, OLAP, Advanced Analytics and Real
Application Testing options
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB2 READ WRITE
ble
SQL> EXIT
fe r a
ans
n - t r
e. Stop and restart the CDB.
a no
[oracle@host01 ~]$ srvctl stop database -d cdb1
h a s ฺ
[oracle@host01 ~]$
o m )
u i de -eval
[oracle@host01 ~]$ srvctl start database c
ilฺnodes t G
-db cdb1
a n
Database cdb1 will be started
Service mypdb1serv will @
gm tudonenodes host03,host02,host01
on host03,host02,host01
d be started
s S
[oracle@host01 ~]$ irb t h i
h k ab srvctl
s e
[oracle@host01
a t ~]$
o u start database -db cdb1
i r (m nse t
a b ice ~]$ srvctl status database -db cdb1
[oracle@host01
K
ul Instance l cdb1_1 is running on node host03
sa n Instance cdb1_2 is running on node host02
Ah Instance cdb1_3 is running on node host01
[oracle@host01 ~]$
f. Verify that the new dynamic PDB service is started and the PDB opened automatically.
It may take a few moments for the service to be started on all hosts. (If you do not wish
to wait, use SRVCTL to start the service: srvctl start service -d cdb1 -
service mypdb1serv).
[oracle@host01 ~]$ srvctl status service -db cdb1
Service mypdb1serv is running on nodes: host03,host02,host01.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB2 MOUNTED
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
ble
------------------------
fe r a
Alias LISTENER
ans
Version TNSLSNR for Linux: Version 12.1.0.2.0
n - t r
o
an
- Production
Start Date 16-JUL-2014 05:39:02 s
ha deฺ
Uptime )
1 days 0 hr. 28 min. 37 sec
m ui
c o
Trace Level off
a il ent G
ฺ
Security
gm tud
ON: Local OS Authentication
@
SNMP OFF
b d i s S
i r h
ab se t
Listener Parameter File
h k
/u01/app/12.1.0/grid/network/admin/listener.ora
t u
m a
Listener Log File t o
i r ( ense
/u01/app/grid/diag/tnslsnr/host01/listener/alert/log.xml
b
n u l Ka lic
Listening Endpoints Summary...
hs a (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
A (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.101)(PORT=1521
)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.239)(PORT=1521
)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 2 handler(s) for this
service...
Service "cdb1" has 1 instance(s).
Instance "cdb1_3", status READY, has 1 handler(s) for this
service...
Service "cdb1XDB" has 1 instance(s).
Instance "cdb1_3", status READY, has 1 handler(s) for this
service...
Service "mypdb1serv" has 1 instance(s).
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
h. Use the service to connect to the PDB on any of the CDB instances.
[oracle@host01 ~]$ sqlplus /nolog
ble
fe r a
ans
SQL> CONNECT system@"host01/mypdb1serv"
n - t r
Enter password: o
Connected.
s an
) ha deฺ
SQL> SELECT name, open_mode FROM v$pdbs;
c o m ui
a il ent G
ฺ
NAME
@ gm OPEN_MODE
tud
d S
i rb this ----------
------------------------------
b
PDB1
t h ka use READ WRITE
( m a to
s e
ir ensystem@"host02/mypdb1serv"
a b
SQL> CONNECT
c
u l Enter li
K password:
a n Connected.
Ahs
SQL> SELECT name FROM v$services;
NAME
---------------------------------------------------------------
mypdb1serv
pdb1
NAME
SQL> EXIT
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
2. You can also “affinitize” connections to pdb2 to a single node by defining the
singpdb2serv service cardinality to SINGLETON.
a. Create and start the service for pdb2.
[oracle@host01 ~]$ srvctl add service -db cdb1 -pdb pdb2 -
service singpdb2serv -policy automatic -serverpool cdb1pool -
cardinality singleton
ble
[oracle@host01 ~]$ srvctl start service -d cdb1 -service
fe r a
singpdb2serv -eval
ans
Service singpdb2serv will be started on node host01
n - t r
a no
[oracle@host01 ~]$ srvctl start service -dacdb1
h s -service
singpdb2serv
m ) i d eฺ
i l ฺ co t Gu
[oracle@host01 ~]$ srvctl status m a serviced e n -d cdb1 -service
@ g tu
singpdb2serv
d s S
Service singpdb2serv
a b irbis running
t hi on nodes: host01
[oracle@host01 k~]$ e
a th to us
i r (m nse
ab that lyou
b. Check
l K i c ecan use the service to connect to pdb2 only on host01 and that the
a n u PDB is opened in the CDB instance on host01 only.
s
Ah [oracle@host01 ~]$ sqlplus /nolog
NAME OPEN_MODE
------------------------------ ----------
PDB2 READ WRITE
NAME
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
c. Check that you cannot use the service to connect to pdb2 on host02 nor host03
and that the PDB is closed in the CDB instances on host02 and host03.
SQL> CONNECT system@"host02/singpdb2serv"
Enter password:
ERROR:
ORA-12514: TNS:listener does not currently know of service
ble
requested in connect descriptor
fe r a
ans
Warning: You are no longer connected to ORACLE.
n - t r
a no
SQL> CONNECT system@"host03/singpdb2serv" s
Enter password: ) ha deฺ
c o m ui
ERROR: ฺ
ail currently
n t G
ORA-12514: TNS:listener doesm
g not
t u de know of service
requested in connect descriptor
b d @ sS
a b i r
e t hi
Warning: You are
a thk noto longer
us connected to ORACLE.
i r (m ensystem@"host02/cdb1"
SQL>bCONNECT se
u Ka password:
l Enter lic
a n
hs
Connected.
A
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB2 MOUNTED
SQL> EXIT
[oracle@host01 ~]$
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
Overview
In this practice, you will drop a PDB in the CDB and verify that the services and data files are
deleted.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
Tasks
1. To drop the pdb2, first stop and remove the service from the resources configuration.
[oracle@host01 ~]$ srvctl stop service -d cdb1 -service
singpdb2serv
NAME
---------------------------------------------------------------
mypdb1serv
pdb2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
7 rows selected.
11 rows selected.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ
SQL>
Note that all files related to pdb2 are removed. The UNDO datafile is associated with the
instance, and not with any PDB.
4. Verify that the services are deleted. Check in V$SERVICES view and with LSNRCTL.
ble
SQL> SELECT name FROM v$services;
fe r a
ans
NAME
n - t r
o
an
---------------------------------------------------------------
mypdb1serv s
ha deฺ
pdb1 )
m ui
c o
cdb1XDB
a il ent G
ฺ
cdb1
@ gm tud
SYS$BACKGROUND
b d i s S
i r h
ab se t
SYS$USERS
t h k u
m a t o
r ( ense
6 rows selected.
b i
u Ka EXITlic
l SQL>
a n
Ahs [oracle@host01 ~]$ lsnrctl status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0
- Production
Start Date 16-JUL-2014 05:39:02
Uptime 1 days 0 hr. 28 min. 37 sec
Trace Level off
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.101)(PORT=1521
)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.239)(PORT=1521
)))
ble
Services Summary...
fe r a
Service "+ASM" has 1 instance(s).
ans
Instance "+ASM1", status READY, has 2 handler(s) for this n - t r
o
service...
s an
Service "cdb1" has 1 instance(s).
) ha deฺ
c o m ui
Instance "cdb1_3", status READY, has 1 handler(s) for this
service...
a il ent G
ฺ
gm tud
Service "cdb1XDB" has 1 instance(s).
@
b d i s S
Instance "cdb1_3", status READY, has 1 handler(s) for this
i r h
ab se t
service...
h k
Service "mypdb1serv" has 1 instance(s).
t u
m a t o
Instance "cdb1_3", status READY, has 1 handler(s) for this
i r ( ense
service...
b
n u l Ka lic
Service "pdb1" has 1 instance(s).
ble
fe r a
ans
n - t r
a no
Practices for h a s ฺ 13:
Lesson
Quality o m
of
) i
Service
u de
a ilฺc ent G
Management
@ gm tud
b d Chapter
i s S 13
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A
ble
fe r a
ans
n - t r
o
s an
) ha deฺ
c o m ui
a il ent G
ฺ
@ gm tud
b d i s S
i r h
h k ab se t
a t t o u
i m
r ( ense
b
n u l Ka lic
hs a
A