Oracle RAC 11g Release 2 Client Connections

20
1/22/2012 1 2 Oracle RAC 11g Release 2 Client Connections Markus Michalewicz Senior Principal Product Manager Oracle RAC and RAC One Node

description

Oracle RAC and Client Connectivity

Transcript of Oracle RAC 11g Release 2 Client Connections

Page 1: Oracle RAC 11g Release 2 Client Connections

1/22/2012

1

1

2

Oracle RAC 11g Release 2 Client Connections Markus Michalewicz

Senior Principal Product Manager Oracle RAC and RAC One Node

Page 2: Oracle RAC 11g Release 2 Client Connections

1/22/2012

2

3

Agenda

• Introduction to Oracle RAC

• Connecting to Oracle RAC using SCAN

• Load balancing, TAF, FAN and Oracle RAC

• More Information and Q&A

4

What is Oracle RAC?

Clustered

Database Servers

Mirrored Disk

Subsystem

High Speed

Switch or

Interconnect

Hub or

Switch

Fabric

Network

Centralized

Management

Console

Drive and Exploit

Industry Advances

in Clustering

Clients

No Single

Point Of Failure

Interconnect

Storage Area Network

SCAN

Page 3: Oracle RAC 11g Release 2 Client Connections

1/22/2012

3

5

Oracle RAC Architecture

Node 1 Node ... Node n

Consolidated Pool of Storage with Automatic Storage Management (ASM)

Oracle Clusterware

Oracle ASM / ACFS

Oracle RAC

Clustered version of the Oracle Database

Based on a Shared Disk-Architecture

ONE database, SEVERAL instances

All nodes work concurrently

Revolutionary technique: “Cache Fusion“ = shared cache

6

Agenda

• Introduction to Oracle RAC

• Connecting to Oracle RAC using SCAN

• Load balancing, TAF, FAN and Oracle RAC

• More Information and Q&A

Page 4: Oracle RAC 11g Release 2 Client Connections

1/22/2012

4

7

Connecting to RAC: SCAN

• Used by clients to connect to any database in the cluster

• Removes the requirement to change the client connection if cluster changes

• Load balances across the instances providing a service

• Provides failover between “moved instances”

Clu

ste

rSC

AN

nam

e

Siebel

PSFT

Ora

cle

Gri

d In

frastr

uctu

re

RAC

One FR

EE

RAC

DB2

RAC

DB1

8

Why SCAN is Easier

PMRAC =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = node1)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = nodeN)(PORT = 1521))

(CONNECT_DATA =

… ))

PMRAC =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = clusterSCANname)(PORT = 1521))

(CONNECT_DATA =

… ))

• Without SCAN (pre-11g Rel. 2) TNSNAMES has 1 entry per node

• With every cluster change, all client TNSNAMES need to be changed

• With SCAN only 1 entry per cluster is used, regardless of the # of nodes:

Page 5: Oracle RAC 11g Release 2 Client Connections

1/22/2012

5

9

Connecting using SCAN

Application Server

Clients

SCAN

Listeners

Local

Listeners

Oracle RAC

Database

Cluster

10

Connecting using SCAN

Application Server

Clients

SCAN

Listeners

Oracle RAC

Database

Cluster Local

Listeners

Page 6: Oracle RAC 11g Release 2 Client Connections

1/22/2012

6

11

• Requires a DNS entry (or GNS) to be used for full functionality

• In DNS, SCAN is a single name defined to resolve to 3 IP-addresses:

• Each cluster will have 3 SCAN-Listeners,

combined with a SCAN-VIP defined as cluster resources

• The SCAN VIP/LISTENER combination will failover

to another node in the cluster, if the current node fails

Cluster Resources

--------------------------------------------

ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE node1

ora.LISTENER_SCAN2.lsnr 1 ONLINE ONLINE node2

ora.LISTENER_SCAN3.lsnr 1 ONLINE ONLINE node3

clusterSCANname.example.com

IN A 133.22.67.194

IN A 133.22.67.193

IN A 133.22.67.192

Network Configuration for SCAN

12

• Requires a DNS entry (or GNS) to be used for full functionality

• What if… the configuration needs to change?

• Change the DNS entry first – e.g.:

• Then issue: • srvctl modify scan -n NEWclusterSCANname.example.com

• Most changes to the SCAN configuration can be performed using 'srvctl modify scan‘ online, including:

• name changes (changes to the SCAN name)

• IP address changes (assuming that the new IP addresses are taken from the same subnet as the old ones).

• The SCAN listeners need to be restarted using 'srvctl stop / start scan' to reflect an IP address change

NEWclusterSCANname.example.com

IN A 133.22.67.184

IN A 133.22.67.183

SCAN re-configuration

Page 7: Oracle RAC 11g Release 2 Client Connections

1/22/2012

7

13

NAME TYPE VALUE

-------------------------- ----------- ------------------------------

local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD

DRESS=(PROTOCOL=TCP)(HOST=133.

22.67.111)(PORT=1521))))

remote_listener string sales1-scan.example.com:1521

• Load balancing using SCAN is still based on these parameters:

• local_listener

• remote_listener

• Using an Oracle Database 11g Release 2, the following configuration will be the default for a newly, DBCA-created DB:

• Note the notation of the remote_listener for SCAN

• More information: “Oracle Real Application Clusters 11g Release 2 Overview of SCAN” on http://www.oracle.com/goto/rac

SCAN and Load Balancing

14

Oracle client version Oracle DB version Comments

Oracle Database 11g Release 2

Oracle Database 11g Release 2

No change required

Oracle Database

11g Release 2

Pre-Oracle Database

11g Release 2

Add the SCAN VIPs as hosts to the REMOTE_LISTENER

parameter.

Pre-Oracle Database

11g Release 2

Oracle Database

11g Release 2

Change the client

TNSNAMES.ora to

include the SCAN VIPs

Pre-Oracle Database

11g Release 2

Pre-Oracle Database

11g Release 2

No change required, since

node VIPs can be used,

but use of SCAN is

recommended.

SCAN and “older Databases”

Page 8: Oracle RAC 11g Release 2 Client Connections

1/22/2012

8

15

Agenda

• Introduction to Oracle RAC

• Connecting to Oracle RAC using SCAN

• Load balancing, TAF, FAN and Oracle RAC

• More Information and Q&A

16

Direct or Indirect Connection

Production Email

BATCH

• Connect Time Load Balancing (CTLB)

• Connect Time Connection Failover (CTCF)

• Runtime Connection Load Balancing (RTLB)

• Runtime Connection Failover (RTCF)

Connection

Pool

SC

AN

Page 9: Oracle RAC 11g Release 2 Client Connections

1/22/2012

9

17

TNSNAMES.ora or JDBC(:THIN)

Production Email

BATCH

Connection

Pool M

yS

CA

N

PMRAC =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = MySCAN)(PORT = 1521))

(CONNECT_DATA =

… ))

jdbc:oracle:thin:@MySCAN:1521/Email

18

The Simple Failover Cases: CTCF

jdbc:oracle:thin:@MySCAN:1521/Email

• Connect Time Connection Failover

Production Email

BATCH

Connection

Pool

MyS

CA

N

PMRAC =

(DESCRIPTION =

(FAILOVER=ON)

(ADDRESS = (PROTOCOL = TCP)(HOST = MySCAN)(PORT = 1521))

(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Email)))

Page 10: Oracle RAC 11g Release 2 Client Connections

1/22/2012

10

19

CTCF – Further Optimization

PMRAC =

(DESCRIPTION =

(FAILOVER=ON)(CONNECT_TIMEOUT=10)(RETRY_COUNT=3)

(ADDRESS = (PROTOCOL = TCP)(HOST = MySCAN)(PORT = 1521))

(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Email)))

• Connect Time Connection Failover

Production Email

BATCH

Connection

Pool M

yS

CA

N

20

The Simple Failover Cases: RTCF

Production Email

BATCH

Connection

Pool

MyS

CA

N

• Connect Time Connection Failover

• Runtime Connection Failover

PMRAC =

(DESCRIPTION =

(FAILOVER=ON)

(ADDRESS = (PROTOCOL = TCP)(HOST = MySCAN)(PORT = 1521))

(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Email)

...))

Page 11: Oracle RAC 11g Release 2 Client Connections

1/22/2012

11

21

The Simple Failover Cases: RTCF

Production Email

BATCH

Connection

Pool M

yS

CA

N

• Connect Time Connection Failover

• Runtime Connection Failover

?

PMRAC =

(DESCRIPTION =

(FAILOVER=ON)

(ADDRESS = (PROTOCOL = TCP)(HOST = MySCAN)(PORT = 1521))

(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Email)

...))

22

What happens to the client?

Production Email

BATCH

Connection

Pool

MyS

CA

N

• Does the client get re-connected?

• YES, configurable

• Are transactions recovered?

• Write transactions: NO

• Pure ‘selects’: Maybe

• Using TAF only

empno name

7369 Smith

7499 Allen

7521 Ward

7566 Jones

7654 Martin

7698 Blake

?

Page 12: Oracle RAC 11g Release 2 Client Connections

1/22/2012

12

23

Two Ways To Protect the Client: TAF

1. Transparent Application Failover (TAF)

• Tries to make the client unaware of a failure

• Provides means of CTCF and RTCF

• Allows for pure ‘selects’ (reads) to continue

• Write transactions need to be re-issued

• The Application needs to be TAF aware

2. Fast Application Notification (FAN)

Production Email

BATCH

Connection

Pool M

yS

CA

N

empno name

7369 Smith

7499 Allen

7521 Ward

7566 Jones

7654 Martin

7698 Blake

24

Set up TAF Policies on the Server

• TAF policies can be set on the client:

• Or on the server using settings per service:

• This setting enables central TAF policy management per service.

PMRAC =

(DESCRIPTION =

(FAILOVER=ON)

(ADDRESS = (PROTOCOL = TCP)(HOST = MySCAN)(PORT = 1521))

(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Email)

(FAILOVER_MODE= (TYPE=select)(METHOD=basic))))

srvctl add service

-s Email -d ORCL

-e SELECT -m BASIC

-r ORCL1 -a ORCL2

-q TRUE

Page 13: Oracle RAC 11g Release 2 Client Connections

1/22/2012

13

25

Two Ways To Protect the Client: FAN

1. Transparent Application Failover (TAF)

2. Fast Application Notification (FAN)

• FAN wants to inform clients ASAP

• Expects clients to re-connect on failure (FCF)

• Sends messages about changes in the cluster

Production Email

BATCH

Connection

Pool M

yS

CA

N

26

The Benefits of a Connection Pool I

• If a connection pool is used

• The clients (users) get a physical connection to the connection pool

• The connection pool creates a physical connection to the database

• It is a direct client to the database

• Internally the pool maintains logical connections

Production Email

BATCH Connection Pool

MyS

CA

N

Page 14: Oracle RAC 11g Release 2 Client Connections

1/22/2012

14

27

The Benefits of a Connection Pool II

• The connection pool

• Invalidates connections to one instance

• Re-establishes new logical connections

• May create new physical connections

• Prevent new clients to be misrouted

• The application needs to handle the transaction failure that might have occurred.

Production Email

BATCH Connection Pool

MyS

CA

N

28

Production Email

BATCH

Connection

Pool

MyS

CA

N

The Load Balancing (LB) Cases

• Connect Time Load Balancing (CTLB)

• Runtime Connection Load Balancing (RTLB)

• On the Client Side

• On the Server Side

Page 15: Oracle RAC 11g Release 2 Client Connections

1/22/2012

15

29

Client Side Load Balancing

Production Email

BATCH

Connection

Pool M

yS

CA

N

• Connect Time Load Balancing (CTLB) – On the client side

• Runtime Connection Load Balancing (RTLB)

PMRAC =

(DESCRIPTION =

(FAILOVER=ON)(LOAD_BALANCE=ON)

(ADDRESS = (PROTOCOL = TCP)(HOST = MySCAN)(PORT = 1521))

(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Email)))

30

Server Side Load Balancing • Connect Time Load Balancing (CTLB) – On the server

• Runtime Connection Load Balancing (RTLB)

Production

Email

BATCH

Connection

Pool

MyS

CA

N

? • Traditionally, PMON dynamically registers the services to the specified listeners with:

• service names for each running instance of the database and instance names for the DB

• The listener is updated with the load information for every instance and node as follows:

• 1-Minute OS Node Load Average all 30 secs.

• Number of Connections to Each Instance

• Number of Connections to Each Dispatcher

Page 16: Oracle RAC 11g Release 2 Client Connections

1/22/2012

16

31

NAME TYPE VALUE

-------------------------- ----------- ------------------------------

local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD

DRESS=(PROTOCOL=TCP)(HOST=133.

22.67.111)(PORT=1521))))

remote_listener string sales1-scan.example.com:1521

• Load balancing using SCAN is still based on these parameters:

• local_listener

• remote_listener

• Using an Oracle Database 11g Release 2, the following configuration will be the default for a newly, DBCA-created DB:

• Note the notation of the remote_listener for SCAN

• More information: “Oracle Real Application Clusters 11g Release 2 Overview of SCAN” on http://www.oracle.com/goto/rac

SCAN and Load Balancing

32

FAN for the Load Balancing Cases

• Connect Time Load Balancing (CTLB)

• Connect Time Connection Failover (CTCF)

• Runtime Connection Load Balancing (RTLB)

• Runtime Connection Failover (RTCF)

RAC

Database

Instance1

Instance2

Instance3

I’m busy

I’m very busy

I’m idle

30% connections

10% connections

60% connections

Page 17: Oracle RAC 11g Release 2 Client Connections

1/22/2012

17

33

FAN based Load Balancing in General

• Connect Time Load Balancing (CTLB)

• Runtime Connection Load Balancing (RTLB)

• Also via AQ (Advanced Queuing) based notifications

• Background is always the Load Balancing Advisory RAC

Database

Instance1

Instance2

Instance3

I’m busy

I’m very busy

I’m idle

30% connections

10% connections

60% connections

MyS

CA

N

34

Use Services For FAN based LB • Connect Time Load Balancing (CTLB)

• Runtime Connection Load Balancing (RTLB)

• CTLB Goal

• SHORT - used for application connections that are short in duration.

• LONG - used for application connections that are connected for a long period; e.g. third party connection pools and SQL*Forms applications.

• RTLB Goal

• THROUGHPUT – Work requests are directed based on throughput.

• SERVICE_TIME – Work requests are directed based on response time.

• This example is most suitable for FAN integrated connection pools

srvctl add service

-s EmailLBA -d ORCL

-j SHORT // Connection Load Balancing Goal {LONG|SHORT}

-B SERVICE_TIME // Runtime Connection Load Balancing Goal

{SERVICE_TIME|THROUGHPUT|NONE}

-r ORCL1,ORCL2,ORCL3

Page 18: Oracle RAC 11g Release 2 Client Connections

1/22/2012

18

35

Use Services For FAN based LB • Connect Time Load Balancing (CTLB)

• Runtime Connection Load Balancing (RTLB)

• The Listener uses the Load Balancing Advisory for CTLB

• IF the service has CLB_GOAL=SHORT and RTLB-GOAL=SERVICE_TIME or THROUGHPUT

• IF CLB_GOAL=LONG then the listener will load balance based on number of sessions

• The RTLB-GOAL setting will not be used in this case.

srvctl add service

-s EmailLBA -d ORCL

-j SHORT // Connection Load Balancing Goal {LONG|SHORT}

-B SERVICE_TIME // Runtime Connection Load Balancing Goal

{SERVICE_TIME|THROUGHPUT|NONE}

-r ORCL1,ORCL2,ORCL3

-q TRUE // AQ HA Notifications {TRUE|FALSE}; for OCI / ODP.net

36

Use Services For FAN based LB • Connect Time Load Balancing (CTLB)

• Runtime Connection Load Balancing (RTLB)

srvctl add service

-s Email -d ORCL

-j LONG // Connection Load Balancing Goal {LONG|SHORT}

-B SERVICE_TIME // Runtime Connection Load Balancing Goal

{SERVICE_TIME|THROUGHPUT|NONE}

-r ORCL1,ORCL2,ORCL3

-q TRUE // AQ HA Notifications {TRUE|FALSE}; for OCI / ODP.net

Production

Email

BATCH

Connection

Pool

MyS

CA

N

?

200 100 160 !

Page 19: Oracle RAC 11g Release 2 Client Connections

1/22/2012

19

37

Agenda

• Introduction to Oracle RAC

• Connecting to Oracle RAC using SCAN

• Load balancing, TAF, FAN and Oracle RAC

• More Information and Q&A

38

• www.oracle.com/goto/rac

• Oracle Real Application Clusters 11g Release 2 Overview of SCAN - Aug 2010

• Automatic Workload Management with Oracle RAC 11g Release 2 - Jan 2010

• XA and Oracle controlled Distributed Transactions - Aug 2010

• www.oracle.com/goto/clusterware

• Oracle Clusterware 11g Release 2 Technical Overview

- Updated for Oracle Clusterware 11.2.0.2

• Oracle Documentation

• Oracle® Real Application Clusters Administration and Deployment Guide

11g Release 2 (11.2): 5 Introduction to Automatic Workload Management

More Information

Page 20: Oracle RAC 11g Release 2 Client Connections

1/22/2012

20

39

From the Documentation

40