Upload
shahid-farooq
View
228
Download
0
Embed Size (px)
Citation preview
8/14/2019 Oracle 10g Rac Load Balance Connection
1/52
Oracle 10g RAC load-balancing configuration
This is a discussion on Oracle 10g RAC load-balancing configuration within the Database
Discussions forums in Database and Unix Discussions category; Hi, I am new to RACadministration. I have been trying to configure load-balancing across two nodes in a cluster.
192.168.2.5, 192.168.2.6 are public IP addresses of the nodes and 192.168.2.9, 192.168.2.10are the VIP addresses. My configuration files look like this:
-------------------- SQLNET.ORA ---------------------------
TRACE_LEVEL_CLIENT = OFFnames.directory_path = (TNSNAMES)
names.default_domain = worldname.default_zone = world
break_poll_skip=2000000000----------------------------------------------------------------------------
--------------------- TNSNAMES.ORA --------------------------
TPCC.world =
(DESCRIPTION =(load_balance = on)
(failover = on)(ADDRESS_LIST =
(FAILOVER = ON)(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.9)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.10)(PORT = 1521)))
(CONNECT_DATA =
(SERVICE_NAME = tpcc))
)
TPCC1.world =(DESCRIPTION =
(load_balance = on)(failover = on)
(ADDRESS_LIST =(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.9)(PORT = 1521)))
(CONNECT_DATA =(SERVICE_NAME = tpcc)
)
)
TPCC2.world =(DESCRIPTION =
(load_balance = on)(failover = on)
(ADDRESS_LIST =(FAILOVER = ON)
8/14/2019 Oracle 10g Rac Load Balance Connection
2/52
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.10)(PORT = 1521)))
(CONNECT_DATA =(SERVICE_NAME = tpcc)
))
EXTPROC_CONNECTION_DATA =(DESCRIPTION =
(ADDRESS_LIST =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
(CONNECT_DATA =
(SID=PLSExtProc)(PRESENTATION=RO)))
LISTENERS_TPCC =
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.9)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.10)(PORT = 1521)))
----------------------------------------------------------------------------
--------------------- LISTENER.ORA --------------------------LISTENER_TPCC1 =
(DESCRIPTION =(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.9)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.5)(PORT = 1521))
)(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))))
LISTENER_TPCC2 =
(DESCRIPTION =
(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.10)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.6)(PORT = 1521)))
(ADDRESS_LIST =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
)
----------------------------------------------------------------------------
INIT.ORA ---------------------------
BACKGROUND_DUMP_DEST =/home/oracle/app/oracle/OraHome_1/rdbms/log
USER_DUMP_DEST =/home/oracle/app/oracle/OraHome_1/rdbms/log
control_files = ?/dbs/tpcc_disks/control_001
8/14/2019 Oracle 10g Rac Load Balance Connection
3/52
parallel_max_servers = 48DB_BLOCK_SIZE = 2048
recovery_parallelism = 20compatible = 10.1.0.2
db_name = tpccdb_files = 200
db_file_multiblock_read_count = 16pga_aggregate_target = 800m
dml_locks = 500log_checkpoint_interval = 100000000
log_checkpoints_to_alert = TRUEopen_cursors = 400
processes = 200
sessions = 600transactions = 400
transactions_per_rollback_segment = 1
cursor_sharing = forcecursor_space_for_time = TRUE
timed_statistics = TRUEdisk_asynch_io = TRUE
db_writer_processes = 5hpux_sched_noage = 178
db_cache_size = 2700m
java_pool_size = 0large_pool_size = 300m
shared_pool_size = 1000m
log_buffer = 1024000db_recycle_cache_size = 16m
db_cache_advice = ON
plsql_optimize_level = 2undo_management = AUTO
#####cluster parameter #######################cluster_database = true
cluster_database_instances = 2tpcc1.thread = 1
tpcc1.instance_name = tpcc1
tpcc1.instance_number = 1tpcc1.undo_tablespace = UNDOTBS1
tpcc2.thread = 2
tpcc2.instance_name = tpcc2tpcc2.instance_number = 2
tpcc2.undo_tablespace = UNDOTBS2tpcc1.local_listener = 'LISTENER_TPCC1'
tpcc2.local_listener = 'LISTENER_TPCC2'remote_listener = 'LISTENERS_TPCC'
#############################################
-------------------------------------------------------------------
8/14/2019 Oracle 10g Rac Load Balance Connection
4/52
On both the nodes I have started the listeners LISTENER_TPCC1 andLISTENER_TPCC2 respectively and their status looks similar to this:
-------------------------------------------------------------------> lsnrctl start LISTENER_TPCC1
LSNRCTL for HPUX: Version 10.1.0.2.0 - Production on 25-APR-2006
20:16:12
Copyright (c) 1991, 2004, Oracle. All rights reserved.
Starting /home/oracle/app/oracle/OraHome_1/bin/tnslsnr: please wait...
TNSLSNR for HPUX: Version 10.1.0.2.0 - Production
System parameter file is
/home/oracle/app/oracle/OraHome_1/bench/bench1000/benchrun/network/listener.ora
Log messages written to/home/oracle/app/oracle/OraHome_1/network/log/listener_tpcc1.log
Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168. 2.9)(PORT=1521)))
Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168. 2.5)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)) )
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.
2.9)(PORT=1521)))STATUS of the LISTENER
------------------------
Alias LISTENER_TPCC1Version TNSLSNR for HPUX: Version 10.1.0.2.0 -Production
Start Date 25-APR-2006 20:16:12Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level offSecurity ON: Local OS Authentication
SNMP OFF
Listener Parameter File/home/oracle/app/oracle/OraHome_1/bench/bench1000/benchrun/network/listener
.ora
Listener Log File/home/oracle/app/oracle/OraHome_1/network/log/listener_tpcc1.log
Listening Endpoints Summary...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168. 2.9)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168. 2.5)(PORT=1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)) )
The listener supports no servicesThe command completed successfully
-------------------------------------------------------------------
8/14/2019 Oracle 10g Rac Load Balance Connection
5/52
Everytime I try to start the database instances I get the following
error:
SQL> startup pfile=init.oraORA-00119: invalid specification for system parameter REMOTE_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENERS_TPCC'ORA-01078: failure in processing system parameters
Can somebody please help me out in pointing out what am I doing wrong?
Thanks a lot,
Sudhanshu
SOLUTION
Thanks for your time guys. I tried quite a few things in the pfile -
single quotes, without quotes, double quotes - finally I just took theentry from the tnsnames.ora and pasted it there in the pfile itself. So
the entries in the new pfile look like this:
tpcc1.local_listener = '(ADDRESS =
(PROTOCOL=TCP)(HOST=192.168.2.9)(PORT=1521))'tpcc2.local_listener = '(ADDRESS =
(PROTOCOL=TCP)(HOST=192.168.2.10)(PORT=1521))'
remote_listener = '(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.9) (PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.2.10)(PORT = 1521)))'
After this the database came up without problems. Still connection loadbalancing was not working. So I figured it had to do something with
tnsnames.ora. I rewrote the tnsnames.ora file as:
TPCC.WORLD =(DESCRIPTION =
(load_balance = on)(failover = on)
(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.9)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.10)(PORT = 1521)))
(CONNECT_DATA = (SERVICE_NAME = tpcc))
)
TPCC1.WORLD =
(DESCRIPTION =(load_balance = on)
(failover = on)
8/14/2019 Oracle 10g Rac Load Balance Connection
6/52
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.9)(PORT = 1521))(CONNECT_DATA =
(SERVICE_NAME = tpcc)(INSTANCENAME = tpcc1)
(SERVER = DEDICATED))
)
TPCC2.WORLD =(DESCRIPTION =
(load_balance = on)(failover = on)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.10)(PORT = 1521))
(CONNECT_DATA =(SERVICE_NAME = tpcc)
(INSTANCENAME = tpcc2)
(SERVER = DEDICATED))
---------------------------------------------------------------------------
Restarting the listeners the new status was like this:
---------------------------------------------------------------------------------------------
--------------------------> lsnrctl services LISTENER_TPCC1
LSNRCTL for HPUX: Version 10.1.0.2.0 - Production on 27-APR-2006
11:54:26
Copyright (c) 1991, 2004, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(address=(protocol=ipc)(key=extproc)) )Services Summary...
Service "plsextproc" has 1 instance(s).Instance "plsextproc", status UNKNOWN, has 1 handler(s) for this
service...Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVERService "tpcc" has 2 instance(s).
Instance "tpcc1", status READY, has 2 handler(s) for this service...
Handler(s):"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.9)(PORT=152 1))
"DEDICATED" established:0 refused:0 state:readyLOCAL SERVER
Instance "tpcc2", status READY, has 1 handler(s) for this service...Handler(s):
"DEDICATED" established:0 refused:0 state:readyREMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.10)(PORT=15 21))
8/14/2019 Oracle 10g Rac Load Balance Connection
7/52
The command completed successfully
--------------------------------------------------------------------------------------------After checking several connections using:
sqlplus "tpcc-at-tpcc/tpcc"
I could see the connections were being load balanced properly betweenthe two nodes.
Thanks a lot for your time guys! Seems the problem had to do withentries in tnsnames.ora and pfile.
- Sudhanshu
8/14/2019 Oracle 10g Rac Load Balance Connection
8/52
RAC Networking,
Failover, and LoadBalancing
Setting up failover, loadbalancing, TAF and FCF
ObjectivesAt the end of this module the
student will understand the
following tasks and concepts.
Understand how Oracle Netinteracts with RAC.
Understand how to configuretnsnames for RAC with
Transparent Application Failover(TAF)
Understand how to configureJDBC connections for RAC
8/14/2019 Oracle 10g Rac Load Balance Connection
9/52
Understand how to configureFast Connection Failover as an
alternative to RAC
Overview The Listener Configuration Files Oracle Net and RAC Connect-Time Failover TAF Failover Load Balancing
JDBC Configuration for Failoverand Load Balancing Fast Connection Failover
Listener
ClientNode 1
Node 2
8/14/2019 Oracle 10g Rac Load Balance Connection
10/52
Database
Listener
Resides on the server Listens for incoming client
connection requests
Manages the traffic to theserver; when a client requests anetwork session with a server,the listener actually receives therequest and brokers the clientrequest
If the client's informationmatches the listener'sinformation, then the listenergrants a connection to theserver.
listener.ora
8/14/2019 Oracle 10g Rac Load Balance Connection
11/52
Configuration file for the listenerprocess. Identifies:
o The listener name
o Protocol addresses that it willaccept connection requestson
o Services for which it islistening
Typically resides in the%ORACLE_HOME%\network\admin directory on Windows NT.
tnsnames.ora Configuration file that
determines how you connect tothe database.
o Connect to specific instanceo Load Balancingo Connect Time Failovero TAF Client Failover
8/14/2019 Oracle 10g Rac Load Balance Connection
12/52
Must be present on server andthick clients (ODBC and JDBC
thick OCI driver)
Oracle Net and RAC
Oracle Netunderstands RAC Is used to set up thecluster behavior
Supports multiplemodes
o Connect-Time Failovero Load Balancingo TAF
Connect-Time Failover
8/14/2019 Oracle 10g Rac Load Balance Connection
13/52
One serviceo Tries one nodeo then the other node
Used for failover Balance is done manually In the event of a failure
o Transaction is losto Session is losto Reconnection occurs
automatically
Connect-Time Failover TESTA1 = (DESCRIPTION= (ADDRESS_LIST= (LOAD_BALANCE=OFF) (FAILOVER=ON) (ADDRESS=(PROTOCOL=TCP)(HOST=oradb1)(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=oradb2)(PORT=1521))) (CONNECT_DATA= (SERVICE_NAME=TESTA) ) )
TESTA2 = (DESCRIPTION= (ADDRESS_LIST= (LOAD_BALANCE=OFF)
8/14/2019 Oracle 10g Rac Load Balance Connection
14/52
(FAILOVER=ON) (ADDRESS=(PROTOCOL=TCP)(HOST=oradb2)(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=oradb1)(PORT=1521))) (CONNECT_DATA= (SERVICE_NAME=TESTA)
) )
Failover - Backup
Pairs of services
o The first service defines thesecond as its backup
o The second service definesthe first service as its backup
Used for RAC failover Balance is done manually In the event of a failure
o Transaction is losto Session is maintainedo Queries are restartedo Reconnection occursautomatically
8/14/2019 Oracle 10g Rac Load Balance Connection
15/52
Failover Backup TESTA1 =
(DESCRIPTION = (ENABLE = BROKEN) (LOAD_BALANCE = off) (FAILOVER = on) (ADDRESS = (PROTOCOL = TCP)(HOST = oradb1)(PORT = 1523)) (CONNECT_DATA = (SERVICE_NAME = TESTA) (INSTANCE_NAME = TESTA1) (FAILOVER_MODE = (BACKUP = TESTA2) (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 120) (DELAY = 5))))
TESTA2 = (DESCRIPTION = (ENABLE = BROKEN) (LOAD_BALANCE = off) (FAILOVER = on) (ADDRESS = (PROTOCOL = TCP)(HOST = oradb2)(PORT = 1523)) (CONNECT_DATA = (SERVICE_NAME = TESTA) (INSTANCE_NAME = TESTA2) (FAILOVER_MODE = (BACKUP = TESTA1) (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 120) (DELAY = 5))))
Failover - Preconnect
8/14/2019 Oracle 10g Rac Load Balance Connection
16/52
Pairs of serviceso The first service defines the second as
its backupo The second service defines the first
service as its backupo Both services preconnect to their
backup when the primary connectionsare made
Used for RAC failover Balance is done manually In the event of a failure
o Transaction is losto Session is maintainedo Queries are restartedo Connection is quickly switched over to
the preconnected backup
Failover - Preconnect TESTA1 = (DESCRIPTION = (ENABLE = BROKEN) (LOAD_BALANCE = off) (FAILOVER = on) (ADDRESS = (PROTOCOL = TCP)(HOST = oradb1-vip)(PORT = 1523)) (CONNECT_DATA = (SERVICE_NAME = TESTA) (INSTANCE_NAME = TESTA1) (FAILOVER_MODE = (BACKUP = TESTA2) (TYPE = SELECT)
8/14/2019 Oracle 10g Rac Load Balance Connection
17/52
(METHOD = PRECONNECT) (RETRIES = 120) (DELAY = 5))))
TESTA2 = (DESCRIPTION = (ENABLE = BROKEN) (LOAD_BALANCE = off) (FAILOVER = on) (ADDRESS = (PROTOCOL = TCP)(HOST = oradb2-vip)(PORT = 1523)) (CONNECT_DATA = (SERVICE_NAME = TESTA) (INSTANCE_NAME = TESTA2) (FAILOVER_MODE = (BACKUP = TESTA1) (TYPE = SELECT) (METHOD = PRECONNECT) (RETRIES = 120) (DELAY = 5))))
Load Balancing
One serviceo Oracle Net determines which
node you use Tries to balance the load
Only active nodes are used Balance is somewhat random In the event of a failure
o Transaction is lost
8/14/2019 Oracle 10g Rac Load Balance Connection
18/52
o Connection is lost
Load Balancing TESTA = (DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = on) (FAILOVER = off) (ADDRESS = (PROTOCOL =TCP)(HOST = oradb1-vip)(PORT= 1523))
(ADDRESS = (PROTOCOL =TCP)(HOST = oradb2-vip)(PORT= 1523))
) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TESTA) ) )
8/14/2019 Oracle 10g Rac Load Balance Connection
19/52
Transparent ApplicationFailover
One serviceo Multiple sessions are created
Only active nodes are used In the event of a failure
o available node is usedo No loss ofconnectiono Transaction is losto Query is restarted
Transparent ApplicationFailover
TESTA = (DESCRIPTION = (ENABLE = BROKEN) (ADDRESS_LIST = (LOAD_BALANCE = on) (FAILOVER = on) (ADDRESS = (PROTOCOL = TCP)(HOST = oradb1-
vip)(PORT = 1523))
8/14/2019 Oracle 10g Rac Load Balance Connection
20/52
(ADDRESS = (PROTOCOL = TCP)(HOST = oradb2-vip)(PORT = 1523))
) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TESTA) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 120) (DELAY = 5) ) ) )
Characteristics of TAF
TAF protects:o
Client/server connection
o User session stateo OCI programso Java thick drivers (OCI
drivers)o Sql*pluso Active cursors (select
statements) that have begunto return results
Not failed over:
8/14/2019 Oracle 10g Rac Load Balance Connection
21/52
o Active update transactionso PL/SQL procedure stateso PL/SQL server-side packagevariableso alter session statementso Server side program
variableso Uncommitted transactions
Network Timeouts andTAF
When a planned instanceshutdown occurs, failover occursquickly
o Shutdown instance withsrvctl or OEM
o Failover takes a few seconds
When an unplanned instancefailure occurs, failover timing is
8/14/2019 Oracle 10g Rac Load Balance Connection
22/52
sensitive to network timeoutparameters
o
Failover cannot occur untilthe network connection isreleased
o By default, it may take up toeight minutes for the networkconnection to be released
and for failover to occur Server-side and client-side
operating system level TCP/IPtimeout parameters may beshortened to speed up failover
o Failover can occur as quicklyas one minuteo Can increase risk of disrupted
network connections andunnecessary failover events
8/14/2019 Oracle 10g Rac Load Balance Connection
23/52
Example Windows
TCP/IP TimeoutParameters for TAF
The following steps may beperformed on Windowsdatabase servers, mid-tier
servers, and clients to speed upfailover
o Open the registry hive underHKEY_LOCAL_MACHINE :SYSTEM CurrentControlSet :
Services : Tcpip : Parameterso Add KeepAliveTime :
REG_DWORD to the registryNote: The correct case isrequired for KeepAlive
o Set the value to a reasonable
timeout. Eg: (120000 = 2minutes, 60000 = 1 minute)
8/14/2019 Oracle 10g Rac Load Balance Connection
24/52
JDBC Connections and
TAF
The Oracle JDBC thick driversupports TAF
o tnsnames,ora file must bedefined on the server-side
o JDBC Data Source file mustbe defined on the client-side(or mid-tier)
o TAF failover and loadbalancing are supported
The Oracle JDBC thin driver does
not fully support TAFo tnsnames,ora file must be
defined on the server-sideo JDBC Data Source file must
be defined on the client-side
(or mid-tier)o Load balancing is supported,
but not TAF failover
8/14/2019 Oracle 10g Rac Load Balance Connection
25/52
JDBC Thick Driver
Example
JDBC Thin DriverExample
8/14/2019 Oracle 10g Rac Load Balance Connection
26/52
o
8/14/2019 Oracle 10g Rac Load Balance Connection
27/52
Fast Application
Notification
ONS and FastApplicationNotification
o The Oracle NotificationService provides a frameworkfor passing event messagesabout failover between nodes
o ONS may notify both RAC
nodes and client or mid-tiernodeso Fast Application Notification
provides the basis for FastConnection Failover
Fast ConnectionFailover
8/14/2019 Oracle 10g Rac Load Balance Connection
28/52
Fast Connection Failoverprovides a way to control
failover response
o Effective for Oracle 10gApplication Server JDBCconnections
o More mid-tier applicationsmay be supported in the
futureo Works with JDBC Thick andJDBC Thin drivers
o Provides an alternative to TAFo Avoids network timeout
sensitivity
o Fast and efficient
Pre-requisites for Fast
Connection Failover The JDBC Implicit Connection
Cache is enabled.
8/14/2019 Oracle 10g Rac Load Balance Connection
29/52
The application uses servicenames to connect to the
database, not service ids.
The database should be at leastrelease 10.1.0.2 (10.1.0.3 ispreferred).
ONS is configured and runningon the node where JDBC is
running. The JVM in which the JDBC
instance is running must haveoracle.ons.oraclehome set topoint to the ORACLE_HOME
where the ONS files wereinstalled.
Setting Up the Implicit
Connection Cache forFCF
8/14/2019 Oracle 10g Rac Load Balance Connection
30/52
The following JDBC Data Source file sets upthe Implicit Connection Cache for FCF onthe Application Tier:
OracleDataSource ods = newOracleDataSource()
... ods.setUser(Scott); ods.setPassword(tiger); ods.setConnectionCachingEnabled(Tru
e); ods.setFastConnectionFailoverEnabled
(True); ods.setConnectionCacheName(MyCache); ods.setConnectionCacheProperties(cp); ods.setURL("jdbc:oracle:thin:@(DESCRIPTIO
N= (LOAD_BALANCE=on) (ADDRESS=(PROTOCOL=TCP)(HOST=VIP1)
(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=VIP2)
(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service
_name)))");
8/14/2019 Oracle 10g Rac Load Balance Connection
31/52
8/14/2019 Oracle 10g Rac Load Balance Connection
32/52
ONS on theApplications Tier
Edit the file%ORACLE_HOME%\opmn\conf\ons.config on each mid-tier node:
o localport=6100 # This is theport ONS is writing to on thisnode
o remoteport=6200 # This isthe port ONS is listening on
this node
o loglevel=3o # This is the list of hosts and
ports ONS is posting to.o # Include RAC and client
nodes.o nodes=RAC1.mycompany.co
m:6200,RAC2.mycompany.com:6200,
8/14/2019 Oracle 10g Rac Load Balance Connection
33/52
o RAC3.mycompany.com:6200,APPS1.mycompany.com:6200
,
o APPS2.mycompany.com:6200
ONS on the
Applications Tier
When starting theapplication:
o Specify the system property
Doracle.ons.iraclehome=
o Include the ons.jar file in theapplication CLASSPATH
8/14/2019 Oracle 10g Rac Load Balance Connection
34/52
Modifying Server-Side
ONS for FCF
Use the%ORA_CRS_HOME%\bin\racgonscommand to modify the server-side ONS configuration to be
aware of the mid-tier nodes:
o racgons add_configAPPS1.mycompany.com:6200APPS2.mycompany.com:6200
o This adds the host and portnames to the OCR
Differences betweenFCF and TAF
8/14/2019 Oracle 10g Rac Load Balance Connection
35/52
Application-Level
ConnectionRetries.o Fast Connection Failover
supports application-levelconnection retries. This
gives the application controlof responding to connectionfailovers.
o TAF supports connectionretries only at the OCI/Netlayer.
Differences betweenFCF and TAF
8/14/2019 Oracle 10g Rac Load Balance Connection
36/52
Integration with
the ConnectionCacheo Fast Connection Failover is
well-integrated with theImplicit Connection Cache,
which allows the connectioncache manager to managethe cache for HA.
o Failed connections areautomatically invalidated inthe cache.
o TAF works at the networklevel on a per-connectionbasis, which means that theconnection cache cannot benotified of failures.
8/14/2019 Oracle 10g Rac Load Balance Connection
37/52
Differences between
FCF and TAF
Event-Basedo Fast Connection Failover is
based on the RAC eventmechanism. This means that
Fast Connection Failover isefficient and detects failuresquickly for both active andinactive connections.
o TAF is based on the network
call mechanism.
Differences betweenFCF and TAF
Load-BalancingSupport
8/14/2019 Oracle 10g Rac Load Balance Connection
38/52
o Fast Connection Failoversupports UP event load
balancing of connections andruntime work requestdistribution across activeRAC instances.
Review
What are the two keyconfiguration files for OracleNet?
What key phrase in thetnsnames.ora file influencesloadbalance behaviour?
What key phrase in thetnsnames.ora file influencesfailover behaviour?
Which Oracle Net configurationsallow users to maintainconnections through a failoverevent?
8/14/2019 Oracle 10g Rac Load Balance Connection
39/52
Which JDBC drivers aresupported under TAF and FCF?
What is the name of the utilityto add mid-tier nodes to theserver-side ONS configuration?
Summary
Listener process Configuration files
o listener.orao tnsnames.ora
Failover
o Basico Preconnect
Load Balancing TAF JDBC Thick and Thin drivers and
TAF Setting up Fast Connection
Failover
8/14/2019 Oracle 10g Rac Load Balance Connection
40/52
The listener is a process that resides on the server whose responsibility is tolisten for incoming client connection requests and manage the traffic to theserver.
The listener brokers the client request, handing off the request to the server.
Every time a client (or server acting as a client) requests a network session witha server, a listener receives the actual request. If the client's information matchesthe listener's information, then the listener grants a connection to the server.
Oracle databases do not require identification of the database service inlistener.ora because of service registration. However, static service configurationis required for an Oracle databases if you plan to use a listener.
The tnsnames.ora (or the equivalent) must be used if you want to useTransparent Application Failover. There must be a copy located on each RACserver. In addition, key components of the server-side tnsnames.ora file must bepresent in a client-side tnsnames.ora file. However, for JDBC connections, thetnsnames.ora content is often contained in a long connection string in the JDBCconfiguration file on the client. Note that the JDBC driver for TAF must be theOracle supported thick OCI driver.
Connect-Time Failover
By setting up multiple network paths, OCI will try each of the paths in the connection list. In thismanner you can set up multiple nodes in the cluster, but at the same time, specifying which nodeis the primary connection. This can be done by putting the following entry into the tnsnames.orafile.
prod1.us.company.com =(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)(ADDRESS=(PROTOCOL=tcp)(HOST=prod1)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=prod2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=prod1.us.company.com)))
prod2.us.company.com =(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)
8/14/2019 Oracle 10g Rac Load Balance Connection
41/52
8/14/2019 Oracle 10g Rac Load Balance Connection
42/52
In this example, there are two different service names. The first uses prod1 as the primary and prod2 as the failover, the seconduses prod2 as the primary and prod1 as the failover. Note the extended syntax under FAILOVER_MODE= as compared toconnect-time failover. This syntax is RAC specific, and allows the session state to be maintained through failover for queries(transactions are rolled back). The RETRIES and DELAY parameters allow the connection to be retried if the first attempt is not
successful.
Note that the IP addresses or host names used in the tnsnames.ora file shouldbe Virtual IP addresses or host names for Oracle 10g RAC.
Failover - Preconnect
Note that setting the METHOD = preconnect allows the backup connection to be pre-allocated. This can aid failover speed, at the cost of twice as many concurrent connections.
prod1.us.company.com =(DESCRIPTION =(LOAD_BALANCE = off)(FAILOVER = on)(ADDRESS = (PROTOCOL=tcp)(HOST=prod1)(PORT=1521))(CONNECT_DATA =
(SERVER = DEDICATED)(SERVICE_NAME = prod.us.company.com)
(INSTANCE_NAME = prod1.us.company.com)
(FAILOVER_MODE =(BACKUP = prod2.us.company.com)
(TYPE = select)
(METHOD = preconnect))))prod2.us.company.com =(DESCRIPTION =(LOAD_BALANCE = off)(FAILOVER = on)(ADDRESS = (PROTOCOL=tcp)(HOST=prod1)(PORT=1521))(CONNECT_DATA =
(SERVER = DEDICATED)(SERVICE_NAME = prod.us.company.com)
(INSTANCE_NAME = prod2.us.company.com)
(FAILOVER_MODE =(BACKUP = prod1.us.company.com)
(TYPE = select)
(METHOD = preconnect))))
8/14/2019 Oracle 10g Rac Load Balance Connection
43/52
Note that the IP addresses or host names used in the tnsnames.ora file shouldbe Virtual IP addresses or host names for Oracle 10g RAC.
Load Balancing
Load balancing is similar to Connect-time Failover in that one service is definedwith multiple addresses. In this case, automatic load balancing is turned onwhile failover is turned off. This can be done by putting the following entry intothe tnsnames.ora file.
prod.us.company.com =(DESCRIPTION=
(ADDRESS_LIST=(LOAD_BALANCE=ON)(ADDRESS=(PROTOCOL=tcp)(HOST=prod1)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=prod2)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME=prod.us.company.com)))
Here either prod1 or prod2 will be used. The system used is determined atconnection time. Load balancing is commonly used with RAC, both in theserver-side tnsnames.ora file and the client-side tnsnames.ora file.
Note that the IP addresses or host names used in the tnsnames.ora file shouldbe Virtual IP addresses or host names for Oracle 10g RAC.
Transparent Application Failover (TAF)
The TAF mechanism provides some fault tolerance in the event of a node failure. It does this byestablishing a connection to multiple nodes in the cluster. TAF will automatically resend some
transactions, and will not result in the loss ofconnection to the user in the event of a failure. TAFis configured by specifying both FAILOVER and LOAD_BALANCE as shown here:
prod.us.company.com=(DESCRIPTION=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=
(PROTOCOL=tcp)
8/14/2019 Oracle 10g Rac Load Balance Connection
44/52
(HOST=prod1)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=prod2)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=prod.us.company.com)(FAILOVER_MODE=
(TYPE=select)(METHOD=basic))))
The TYPE parameter accepts the following options:
session - In this mode a new session is created on the failover server in the event of a failure.
select - Cursor processing is maintained. This incurs significant overhead on the client.
none (default) - No failover is done.
The METHOD parameter accepts the following options:
basic - establishes the connection to the failover server when it is needed.
preconnect - establishes the connection to the failover server at initial connection time.
Note that the IP addresses or host names used in the tnsnames.ora file shouldbe Virtual IP addresses or host names for Oracle 10g RAC.
What TAF Restores
TAF automatically restores some or all of the following elements associated with active database connections. Other elements,
however, may need to be embedded in the application code to enable TAF to recover the connection.
Client-Server Database ConnectionsTAF automatically reestablishes the connection using the same connect string or an alternate connect string that you specify
when configuring failover.
Users' Database Sessions
TAF automatically logs a user in with the same user ID as was used prior to failure. If multiple users were using the connection,then TAF automatically logs them in as they attempt to process database commands. Unfortunately, TAF cannot automatically
restore other session properties. These properties can, however, be restored by invoking a callback function.
Executed CommandsIf a command was completely executed upon connection failure, and it changed the s tate of the database, TAF does not resendthe command. If TAF reconnects in response to a command that may have changed the database, TAF issues an error message
to the application.
Open Cursors Used for FetchingTAF allows applications that began fetching rows from a cursor before failover to continue fetching rows after failover. This is
8/14/2019 Oracle 10g Rac Load Balance Connection
45/52
called "select" failover. It is accomplished by re-executing a SELECT statement using the same snapshot, discarding those rowsalready fetched and retrieving those rows that were not fetched initially. TAF verifies that the discarded rows are those that were
returned initially, or it returns an error message
Active TransactionsAny active transactions are rolled back at the time of failure because TAF cannot preserve active transactions after failover. The
application instead receives an error message until a ROLLBACK is submitted.
Server-side Program VariablesServer-side program variables, such as PL/SQL package states, are lost during failures; TAF cannot recover them. They can be
initialized by making a call from the failover callback.
Note the failover=on, failover_mode=, and rac_enabled=true sections.
Note the LOAD_BALANCE=on is set, but failover is not set (TAF failover is notsupported with the thin driver).
The command %ORACLE_HOME%\opmn\bin\onsctl start can be used to startONS, and the command %ORACLE_HOME%\opmn\bin\onsctl stop can beused to stop ONS.
Do not modify the server-side ons.config file to add the mid-tier hosts and ports.This does not modify the OCR. Use the racgons command instead.
Note: The application should not try to roll back the transaction; the transactionwas already rolled back in the database by the time the application received theexception.You should not attempt to run both TAF and FCF at the same time.
Note: The application should not try to roll back the transaction; the transactionwas already rolled back in the database by the time the application received theexception.You should not attempt to run both TAF and FCF at the same time.
8/14/2019 Oracle 10g Rac Load Balance Connection
46/52
Note: The application should not try to roll back the transaction; the transactionwas already rolled back in the database by the time the application received theexception.You should not attempt to run both TAF and FCF at the same time.
Note: The application should not try to roll back the transaction; the transactionwas already rolled back in the database by the time the application received theexception.You should not attempt to run both TAF and FCF at the same time.
8/14/2019 Oracle 10g Rac Load Balance Connection
47/52
Oracle RAC Administration - Part 15: Connection LoadBalancing and FAN
Tarry Singh, [email protected]
Brief intro
In our last article, we looked at the service architecture. We will continue our quest to understandthe workload characteristics and the load balancing connections in our Virtualized RAC.
Introduction to Workload Management
Connection Load Balancing
With Oracle Notification Services (ONS), we are able to have our RAC balance our clientconnections across the nodes. The CLB (connection load balancing) can be handled on theserver-side or on the client-side. The client-side takes care of the connection sharing across theListeners, while server-side load balancing manages and handles the connection requests to themost willingly available node whose information is in turn provided to it by the LBA (LoadBalancing Advisory).
This in turn is analyzing the goals that may have been set for the LBA. You can use a long goal ora short goal for this connection load balancing. Lets take a look at them both quickly.
Long Goals: Use long goals for applications that need long uninterrupted connections. It is thedefault connection load balancing goal. To see how to implement them, lets take a simple syntax.Using the DBMS_SERVICE and CLB_GOAL_LONG packages, you can define the connection load
balancing for long connections as follows and here FOKESERV is our service:
EXECUTE DBMS_SERVICE.MODIFY_SERVICE (service_name =>'FOKESERV'
, clb_goal => DBMS_SERVICE.CLB_GOAL_LONG);
Short Goals: Think of quick and fast transactions like ordering or placing a secure purchase likethat on Amazon or any other place. You would prefer to fill the order up fast and if, for any reasonthe process is delayed, the connection is restarted, ensuring that the transaction is performed in a
short-lived connection. Checking the syntax, here CARTSERV is the service in question:
EXECUTE DBMS_SERVICE.MODIFY_SERVICE (service_name =>'CARTSERV'
, CLB_GOAL => DBMS_SERVICE.CLB_GOAL_SHORT);
Note: When you install your RAC with the DBCA (Database Configuration Assistant), server-sideload balancing is enabled by default. Also check out the sample script in tnsnames.ora file. The
mailto:[email protected]:[email protected]8/14/2019 Oracle 10g Rac Load Balance Connection
48/52
services created through the DBCA will have the Connection Load Balancing default setting asCLB_GOAL=CLB_GOAL_LONG.
The ONS maintains client connections until the client decides to close the connection or if a nodefails or any other form of outage prevents the continuity of that connection. However, if youconfigure TAF (transparent application failover) then the connections are moved to another
healthy instance. For a typical SARG (Select Arguments), TAF can restart the query. Alternately,from the client side, if you were accessing information on the web, the search would simply carryon without you noticing the failover of the connection to another node. However, if you were in themiddle of a transaction (INSERT, UPDATE, or DELETE) then the application must rollback thefailed transaction and submit it again. Any other session's customizations must be re-executed.However, in a normal processing scenario the sessions dont move irrespective of the workloadchanges, newer sessions are just redirected to other nodes.
With the services, the deployment of TAF only becomes easier. By defining a TAF policy for aservice, all connections using this service will have TAF automatically enabled for them. No client-side intervention is required, meaning the server-side TAF setting will override the TAF setting atthe client level. In order to define the TAF policy you will need the DBMS_SERVICE procedure:
EXECUTE DBMS_SERVICE.MODIFY_SERVICE (service_name =>'fokeserv.domain.com', aq_ha_notifications => TRUE, failover_method => DBMS_SERVICE.FAILOVER_METHOD_BASIC, failover_type => DBMS_SERVICE.FAILOVER_TYPE_SELECT, failover_retries => 180, failover_delay => 5, clb_goal => DBMS_SERVICE.CLB_GOAL_LONG);
Client-side load balancing is defined in your client connection with the parameterLOAD_BALANCE=ON (the default is ON). Upon setting this parameter to ON, Oracle will pick out an
address from the address list at random and connect to that node, thereby balancing the clientconnections across the cluster. Run the command lsnrctl services occasionally to see what
services a listener supports.
FAN (Fast Application Notification)
As the Oracle RAC manual states:
FAN is a notification mechanism that RAC uses to notify other processes about configuration andservice level information such as includes service status changes, such as UP or DOWN events.
Applications can respond to FAN events and take immediate action. FAN UP and DOWN eventscan apply to instances, services, and nodes.
RAC publishes the FAN events the minute any changes are made to the cluster. So, instead ofwaiting for the application to check on individual nodes to detect an anomaly, the applications arenotified by FAN events and are able to react immediately.
FAN also publishes load balancing advisory (LBA) events. Applications are in a position to takefull advantage of the LBA FAN events to facilitate a smooth transition of connections to healthiernodes in a cluster. One can take advantage of FAN is the following ways:
8/14/2019 Oracle 10g Rac Load Balance Connection
49/52
When using integrated Oracle Client, the applications can use FAN with no
programming whatsoever. Oracle 120g JDBC, ODP.NET and OCI would beconsidered as the components of the integrated clients.
Programmatic changes in ONS API make it possible for applications to still
subscribe to the FAN events and can execute the event handling actionsappropriately.
FAN can be implemented with server-side callouts on your database tier.
For instance, a typical DOWN event will prevent any further disruption of service by cleanly
terminating the sessions on that failed node and notifying the user. Moreover, a typical UP event
can address and allocate extra resources for new incoming requests/ connections. There arehowever several additional benefits with the server-side callouts, mainly you can utilize FAN inorder to:
Logging
Paging/SMS the DBA and/or to open trouble tickets when the resources fail
to (re)start Change resource plans or to shut down services when the number of
available instances decreases, thus preventing further load on the clusterand keeping the RAC running until another healthy node is added to thecluster.
Automate the fail service back to PREFERRED instances when required.
Conclusion
In this article, we looked at the CLB and FAN. In future articles, we will continue to discuss theservices architecture and discuss FAN in detail and take a look at the LBA.
Oracle RAC Administration - Part 16: Balancing act
between Server and Client
Brief intro
We will take a little detour from our regular path of following the manual, some would say, to morepractical path. One topic that most intrigues both an Oracle DBA and their clients (in their ownway) is connectivity. DBAs are sometimes puzzled with the load balancing and failover part ofconnectivity. Where is it, on the Client-side OR the Server-side? Is tnsnames.ora still useful if Ideploy the Easy Connect Net Naming method? Let's brush up on some basics.
Easy Connect Naming Methods
Easy Connect Naming methods were introduced in Oracle 10g. The benefits were simple. Theneed to do a service name lookup in the tnsnames.ora files for TCP/IP environment waseliminated, a directory naming system is no longer needed and clients are connectedautomatically. Connecting is also fairly simple:
Syntax:
CONNECT username/password@[//]host[:port][/service_name]
8/14/2019 Oracle 10g Rac Load Balance Connection
50/52
So our typical examples could look like:
CONNECT oe/oe@localhost/nickservCONNECT scott/[email protected]/examples
Connect-Time Failover
From the clients end, when your connection fails at one node or service, you can then do a lookup from your tnsnames.ora file and go on seeking a connection with the other available node.Take this example of our 4-node VMware ESX 3.x Oracle Linux Servers:
FOKERAC =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =
nick01.wolga.com)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = nick02.wolga.
com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = brian01.wolga.com)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = brian02.wolga.
com)(PORT = 1521))(CONNECT_DATA =(SERVICE_NAME = fokerac)
))
Here the first address in the list is tried at the clients end. Should the connection tonick01.wolga.nl fail, then the next address, nick02.wolga.nl, will be tried. This phenomenon iscalled connection-time failover. You could very well have a 32-node RAC cluster monitoring the
galactic system at NASA and thus have all those nodes typed in your tnsnames.ora file.Moreover, these entries do not necessarily have to be part of the RAC cluster. So it is possiblethat you are using Streams, Log Shipping or Advanced Replication to maintain your HA (HighAvailability) model. These technologies facilitate continued processing of the database by such aHA (High Availability) model in a non-RAC environment. In a RAC environment we know (andexpect) the data to be the same across all nodes since there is only one database.
TAF (Transparent Application Failover)
Transparent Application Failover actually refers to a failover that occurs when a node or instanceis unavailable due to an outage or other reason that prohibits a connection to be established onthat node. This can be set to on with the following parameter FAILOVER. Setting it to ON willactivate the TAF. It is turned on by default unless you set it to OFF to disable it. Now, when youturn it on you have two types of connections available by the means of the FAILOVER_MODEparameter. The type can be session, which is default or select. When the type is SESSION, if theinstance fails, then the user is automatically connected to the next available node without theusers manual intervention. The SQL statements need to be carried out again on the next node.However, when you set the TYPE to SELECT, then if you are connected and are in the middle ofyour query, then your query will be restarted after you have been failed over to the next availablenode. Take this example of our tnsnames.ora file, (go to the section beginning withCONNECT_DATA):
8/14/2019 Oracle 10g Rac Load Balance Connection
51/52
(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = fokerac.wolga.com)(FAILOVER_MODE =(TYPE = SELECT)
(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))
)
This is also demonstrated in thisimage from my article on Quests soRAC tool.
This is more intelligent in the sense that should the instance, (where the user has fired a query),go down then the session will remember the rows in its Global Buffer Cache, restart the queryand pick up from where the user left off when they were disconnected from the first node.
Compare it to a scenario where the manager is running the query through a client such as CrystalReports or Oracle Reports. Running the monthly query to get the data from his Server Monitoringsoftware, let's say NetIQ, to get the statistics of all the servers the DBA needs to draw a report onmonitoring the CPU, memory or disk usage. Now if he ran a query that had to fetch 5000 rowsand he gets cut off at 3000 rows, he still has to reissue (not manually though) start from thebeginning but will only see the results when he crosses the 3001 mark. Then upon prompt, theresults will be shown. However, this does not apply to the DML (Data Manipulation Language)such as insert, update, delete. The user is met with an error if node failure happens in the middleof the processing and all the (uncommitted) transactions are rolled back. The session eventuallyfails over without the user having to connect, however, he does have to issue the query again.
Preconnect Method
Consider our tnsnames.ora file again. Here in our older example, where the METHOD wasBASIC, there is some additional time loss in reconnecting the lost connection to the immediateavailable node. However, when you set the METHOD to PRECONNECT, a session is connectedto all available nodes in the list. The advantage is that failover is a lot quicker than the BASICmethod but the downside is that the other instances will continue to claim necessary resourcessuch a system memory to keep those connections alive.
(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = fokerac.wolga.com)(FAILOVER_MODE =(TYPE = SELECT)
(METHOD = PRECONNECT)(RETRIES = 180)(DELAY = 5))
)
http://www.dbasupport.com/img/ts_soRAC1_image002.jpghttp://www.dbasupport.com/img/ts_soRAC1_image002.jpghttp://www.dbasupport.com/img/ts_soRAC1_image002.jpg8/14/2019 Oracle 10g Rac Load Balance Connection
52/52
Conclusion
As a DBA, these little things are very crucial in deciding what you intend to do with the RAC. Is ita DSS or will it be used for a heavy OLTP environment. On a DSS, you can easily choose aPRECONNECT method as you expect to have less connections with long durations (batchprocessing, etc.) where as a typical OLTP will perform better if the cluster is optimally configured
with a BASIC method.