2. Objectives
• After completing this lesson, you should be able to:
– Configure client-side connect-time load balancing
– Configure client-side connect-time failover
– Configure server-side connect-time load balancing
– Use the Load Balancing Advisory (LBA)
– Describe the benefits of Fast Application Notification
(FAN)
– Configure server-side callouts
– Configure the server- and client-side ONS
– Configure Transparent Application Failover (TAF)
3. Types of Workload Distribution
– Connection balancing is rendered possible by
configuring multiple listeners on multiple nodes:
• Client-side connect-time load balancing
• Client-side connect-time failover
• Server-side connect-time load balancing
– Run-time connection load balancing is rendered
possible by using connection pools:
• Work requests automatically balanced across the pool of
connections
• Native feature of the JDBC implicit connection cache and
ODP.NET connection pool
7. Fast Application Notification: Overview
Node1
CRS EMD
ONS
HA
Events
HA
Events
HA
Events
C app
ONS OCI
API
ONS
Java app
ONS Java
API
ONS
Java app
DB
Control
JDBC
AQ
Proxy
app
Callout
script
Callout
exec
C app
OCI API
.NET app
ODP.NET
HA
Events
8. Fast Application Notification: Benefits
– No need for connections to rely on connection
timeouts
– Used by Load Balancing Advisory to propagate load
information
– Designed for enterprise application and
management console integration
– Reliable distributed system that:
• Detects high-availability event occurrences in a timely
manner
• Pushes notification directly to your applications
– Tightly integrated with:
• Oracle JDBC applications using connection pools
• Enterprise Manager
• Data Guard Broker
9. FAN-Supported Event Types
Event type Description
SERVICE Primary application service
SRV_PRECONNECT Shadow application service event
(mid-tiers and TAF using primary and secondary
instances)
SERVICEMEMBER Application service on a specific instance
DATABASE Oracle database
INSTANCE Oracle instance
ASM Oracle ASM instance
NODE Oracle cluster node
SERVICE_METRICS Load Balancing Advisory
10. FAN Event Status
Event status Description
up Managed resource comes up.
down Managed resource goes down.
preconn_up Shadow application service comes up.
preconn_down Shadow application service goes down.
nodedown Managed node goes down.
not_restarting Managed resource cannot fail over to a remote
node.
restart_failed Managed resource fails to start locally after a
discrete number of retries.
Unknown Status is unrecognized.
11. FAN Event Reasons
Event Reason Description
user User-initiated commands, such as srvctl and sqlplus
failure Managed resource polling checks detecting a failure
dependency Dependency of another managed resource that triggered
a failure condition
unknown Unknown or internal application state when event is
triggered
autostart Initial cluster boot: Managed resource has profile attribute
AUTO_START=1, and was offline before the last Oracle
Clusterware shutdown.
Boot Initial cluster boot: Managed resource was running before
the last Oracle Clusterware shutdown.
12. FAN Event Format
<Event_Type>
VERSION=<n.n>
[service=<serviceName.dbDomainName>]
[database=<dbName>] [instance=<sid>]
[host=<hostname>]
status=<Event_Status>
reason=<Event_Reason>
[card=<n>]
timestamp=<eventDate> <eventTime>
SERVICE VERSION=1.0 service=ERP.oracle.com
database=RACDB status=up reason=user card=4
timestamp=16-Mar-2004 19:08:15
NODE VERSION=1.0 host=strac-1
status=nodedown timestamp=16-Mar-2004 17:35:53
13. Load Balancing Advisory: FAN Event
Parameter Description
Version Version of the event payload
Event type SERVICE_METRICS
Service Matches DBA_SERVICES
Database unique name Unique DB name supporting the service
Time stamp Date and time stamp (local time zone)
Instance Instance name supporting the service
Percent Percentage of work to send to this database and instance
Flag GOOD, VIOLATING, NO DATA, UNKNOWN
Repeated
14. Server-Side Callouts Implementation
– The callout directory:
• <CRS Home>/racg/usrco
• Can store more than one callout
• Grants execution on callout directory and callouts only to
the Oracle Clusterware user
– Callouts execution order is nondeterministic.
– Writing callouts involves:
1.Parsing callout arguments: The event payload
2.Filtering incoming FAN events
3.Executing event-handling programs
17. Configuring the Server-Side ONS
ONS
ONS
localport=6100
remoteport=6200
useocr=on
ons.config
ONS
ons.config
OCR
$ racgons add_config node1:6200 node2:6200
$ racgons add_config midtier1:6200
$ onsctl reconfig $ onsctl reconfig
Node1 Node2
Mid-tier1
1
2
1
3 3
18. Optionally Configure the Client-Side
ONS
localport=6100
remoteport=6200
nodes=node1:6200,node2:6200
ONS
ONS
ons.config
ONS
ons.config
$ onsctl start
Node1 Node2
Mid-tier1
ons.config
1
2
OCR
19. JDBC Fast Connection Failover:
Overview
ONS
ONS
Noden
Mid-tier1
ONS
Node1
Service or node
DOWN event
Connections
marked down &
cleaned up
JDBC ICC
Service
UP event
Connections
reconnected
Listeners
Connection Cache
Event
handler
Connections
load balancing
………
Connections
using
service names
Connections
using
service names
20. Using Oracle Streams Advanced
Queuing for FAN
– Use AQ to publish FAN to ODP.NET and OCI.
– Turn on FAN notification to alert queue.
–
– View published FAN events:
exec DBMS_SERVICE.MODIFY_SERVICE (
service_name => 'SELF-SERVICE', aq_ha_notification => TRUE);
SQL> select object_name,reason
2 from dba_outstanding_alerts;
OBJECT_NAME REASON
----------- ----------------------------------------
xwkE Database xwkE (domain ) up as of time
2005-12-30 11:57:29.000000000 -05:00;
reason code: user
JFSERV Composite service xwkE up as of time
2006-01-02 05:27:46.000000000 -05:00;
reason code: user
21. JDBC/ODP.NET FCF Benefits
– Database connections are balanced across
preferred instances according to LBA.
– Database work requests are balanced across
preferred instances according to LBA.
– Database connections are anticipated.
– Database connection failures are immediately
detected and stopped.
22. Load Balancing Advisory
– The Load Balancing Advisory (LBA) is an advisory for
sending work across RAC instances.
– The LBA advice is available to all applications that
send work:
• JDBC and ODP connection pools
• Connection load balancing
– The LBA advice sends work to where services are
executing well and resources are available:
• Relies on service goodness
• Adjusts distribution for different power nodes, different
priority and shape workloads, changing demand
• Stops sending work to slow, hung, or failed nodes
23. JDBC/ODP.NET Runtime Connection
Load Balancing: Overview
Connection Cache
RAC
Inst2
CRM is
not busy.
CRM is
very busy.
CRM is
busy.
10%
60%
30%
?
CRM work requests
RAC
Inst1
RAC
Inst3
24. Connection Load Balancing in RAC
– Connection load balancing allows listeners to distribute
connection requests to the best instances.
– Three metrics are available for listeners to decide:
• Session count by instance
• Run queue length of the node
• Service goodness
– The metric used depends on the connection
load-balancing goal defined for the service:
• LONG
• NONE
• SHORT
25. Load Balancing Advisory: Summary
– Uses DBMS_SERVICE.GOAL
• Service time: weighted moving average of elapsed time
• Throughput: weighted moving average of throughput
– AWR
• Calculates goodness locally (MMNL), forwards to master MMON
• Master MMON builds advisory for distribution of work across RAC, and
posts load balancing advice to AQ
• IMON retrieves advice and send it to ONS
• EMON retrieves advice and send it to OCI
• Local MMNL post goodness to PMON
– Listeners use DBMS_SERVICE.CLB_GOAL=SHORT
• Use goodness from PMON to distribute connections.
– Load Balancing Advisory users (inside the pools)
• Use percentages and flags to send work.
27. FAN Release Map
Oracle
Release
FAN Product
Integration
Event
System
FAN Event Received and Used
10.1.0.2 JDBC ICC&FCF
Server-side callouts
ONS
RAC
Up/down/Load Balancing Advisory
Up/down
10.1.0.3 CMAN
Listeners
ONS
PMON
Down
Up/down/LBA
10.2 OCI connection pool
OCI session pool
TAF
ODP.NET
Custom OCI
DG Broker (10.2.0.3)
AQ
AQ
AQ
AQ
AQ
AQ
Down
Down
Down
Up/down/LBA
All
Down
11.1 OCI session pool AQ LBA
32. TAF Verification
SELECT machine, failover_method, failover_type,
failed_over, service_name, COUNT(*)
FROM v$session
GROUP BY machine, failover_method, failover_type,
failed_over, service_name;
MACHINE FAILOVER_M FAILOVER_T FAI SERVICE_N COUNT(*)
------- ---------- ---------- --- -------- --------
node1 BASIC SESSION NO AP 1
node1 PRECONNECT SESSION NO ERP 1
MACHINE FAILOVER_M FAILOVER_T FAI SERVICE_N COUNT(*)
------- ---------- ---------- --- --------- --------
node2 NONE NONE NO ERP_PRECO 1
MACHINE FAILOVER_M FAILOVER_T FAI SERVICE_N COUNT(*)
------- ---------- ---------- --- -------- --------
node2 BASIC SESSION YES AP 1
node2 PRECONNECT SESSION YES ERP_PRECO 1
1st
node
2nd
node
2nd
node
after
33. FAN Connection Pools and TAF
Considerations
– Both techniques are integrated with services and
provide service connection load balancing.
– Do not use FCF when working with TAF, and vice
versa.
– Connection pools that use FAN are always
preconnected.
– TAF may rely on operating system (OS) timeouts to
detect failures.
– FAN never relies on OS timeouts to detect failures.
34. Summary
• In this lesson, you should have learned how to:
– Configure client-side connect-time load balancing
– Configure client-side connect-time failover
– Configure server-side connect-time load balancing
– Use the Load Balancing Advisory
– Describe the benefits of Fast Application Notification
– Configure server-side callouts
– Configure the server- and client-side ONS
– Configure Transparent Application Failover
35. Practice 8: Overview
• This practice covers the following topics:
– Monitoring high availability of connections
– Creating and using callout scripts
– Using the Load Balancing Advisory
– Using the Transparent Application Failover feature