Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
RAC Networking, Failover, and Load Balancing Setting up failover, load balancing, TAF and FCF Objectives At the end of this module the student will understand the following tasks and concepts. Understand how Oracle Net interacts with RAC. Understand how to configure tnsnames for RAC with Transparent Application Failover (TAF) Understand how to configure JDBC connections for RAC Understand how to configure Fast 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 Failover and Load Balancing Fast Connection Failover Listener Node 1 Database Client Node 2 Listener Resides on the server Listens for incoming client connection requests Manages the traffic to the server; when a client requests a network session with a server, the listener actually receives the request and brokers the client request If the client's information matches the listener's information, then the listener grants a connection to the server. listener.ora Configuration file for the listener process. Identifies: The listener name Protocol addresses that it will accept connection requests on Services for which it is listening Typically resides in the %ORACLE_HOME%\network\admin directory on Windows NT. tnsnames.ora Configuration file that determines how you connect to the database. Connect to specific instance Load Balancing Connect Time Failover TAF Client Failover Must be present on server and “thick” clients (ODBC and JDBC “thick” OCI driver) Oracle Net and RAC Oracle Net understands RAC Is used to set up the cluster behavior Supports multiple modes Connect-Time Failover Load Balancing TAF Connect-Time Failover One service Tries one node then the other node Used for failover Balance is done manually In the event of a failure Transaction is lost Session is lost 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) (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 The first service defines the second as its backup The second service defines the first service as its backup Used for RAC failover Balance is done manually In the event of a failure Transaction is lost Session is maintained Queries are restarted Reconnection occurs automatically 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 Pairs of services The first service defines the second as its backup The second service defines the first service as its backup Both services preconnect to their backup when the primary connections are made Used for RAC failover Balance is done manually In the event of a failure Transaction is lost Session is maintained Queries are restarted 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) (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 service 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 Transaction is lost 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) ) ) Transparent Application Failover One service Multiple sessions are created Only active nodes are used In the event of a failure available node is used No loss of connection Transaction is lost Query is restarted Transparent Application Failover TESTA = (DESCRIPTION = (ENABLE = BROKEN) (ADDRESS_LIST = (LOAD_BALANCE = on) (FAILOVER = on) (ADDRESS = (PROTOCOL = TCP)(HOST = oradb1-vip)(PORT = 1523)) (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: Client/server connection User session state OCI programs Java thick drivers (OCI drivers) Sql*plus Active cursors (select statements) that have begun to return results Not failed over: Active update transactions PL/SQL procedure states PL/SQL server-side package variables alter session statements Server side program variables Uncommitted transactions Network Timeouts and TAF When a “planned” instance shutdown occurs, failover occurs quickly When an “unplanned” instance failure occurs, failover timing is sensitive to network timeout parameters Shutdown instance with srvctl or OEM Failover takes a few seconds Failover cannot occur until the network connection is released By default, it may take up to eight minutes for the network connection to be released and for failover to occur Server-side and client-side operating system level TCP/IP timeout parameters may be shortened to speed up failover Failover can occur as quickly as one minute Can increase risk of disrupted network connections and unnecessary failover events Example Windows TCP/IP Timeout Parameters for TAF The following steps may be performed on Windows database servers, mid-tier servers, and clients to speed up failover Open the registry hive under HKEY_LOCAL_MACHINE : SYSTEM CurrentControlSet : Services : Tcpip : Parameters Add KeepAliveTime : REG_DWORD to the registry Note: The correct case is required for KeepAlive Set the value to a reasonable timeout. Eg: (120000 = 2 minutes, 60000 = 1 minute) JDBC Connections and TAF The Oracle JDBC thick driver supports TAF tnsnames,ora file must be defined on the server-side JDBC Data Source file must be defined on the clientside (or mid-tier) TAF failover and load balancing are supported The Oracle JDBC thin driver does not fully support TAF tnsnames,ora file must be defined on the server-side JDBC Data Source file must be defined on the clientside (or mid-tier) Load balancing is supported, but not TAF failover JDBC Thick Driver Example <data-source class="com.evermind.sql.DriverManagerDataSource" name="OracleDS" location="jdbc/OracleCoreDS" xa-location="jdbc/xa/OracleXADS" ejb-location="jdbc/OracleDS" connection-driver="oracle.jdbc.driver.OracleDriver" username="scott" password="tiger" url="jdbc:oracle:oci8:@(description=(load_balance=on)(failover=on) (address=(protocol=tcp)(host=db-node1)(port=1521)) (address=(protocol=tcp)(host=db-node2)(port=1521)) (address=(protocol=tcp)(host=db-node3)(port=1521)) (address=(protocol=tcp)(host=db-node4)(port=1521)) (connect_data= (service_name=sales.us.oracle.com) (failover_mode=(type=select)(method=basic)(retries=20)(delay=15))))" rac-enabled="true" inactivity-timeout="300" connection-retry-interval="2" max-connect-attempts="60" max-connections="60" min-connections="12" /> JDBC Thin Driver Example <data-source class="com.evermind.sql.DriverManagerDataSource" name="OracleDS" location="jdbc/OracleCoreDS" xa-location="jdbc/xa/OracleXADS" ejb-location="jdbc/OracleDS" connection-driver="oracle.jdbc.driver.OracleDriver" username="scott" password="tiger" url="jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on) (ADDRESS=(PROTOCOL=TCP) (HOST=host1) (PORT=1521)) (ADDRESS=(PROTOCOL=TCP) (HOST=host2) (PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service_name)))" inactivity-timeout="300" connection-retry-interval="2" max-connect-attempts="60" max-connections="60" min-connections="12" /> Fast Application Notification ONS and Fast Application Notification The Oracle Notification Service provides a framework for passing event messages about failover between nodes ONS may notify both RAC nodes and client or mid-tier nodes Fast Application Notification provides the basis for Fast Connection Failover Fast Connection Failover Fast Connection Failover provides a way to control failover response Effective for Oracle 10g Application Server JDBC connections More mid-tier applications may be supported in the future Works with JDBC Thick and JDBC Thin drivers Provides an alternative to TAF Avoids network timeout sensitivity Fast and efficient Pre-requisites for Fast Connection Failover The JDBC Implicit Connection Cache is enabled. The application uses service names to connect to the database, not service ids. The database should be at least release 10.1.0.2 (10.1.0.3 is preferred). ONS is configured and running on the node where JDBC is running. The JVM in which the JDBC instance is running must have oracle.ons.oraclehome set to point to the ORACLE_HOME where the ONS files were installed. Setting Up the Implicit Connection Cache for FCF The following JDBC Data Source file sets up the Implicit Connection Cache for FCF on the Application Tier: OracleDataSource ods = new OracleDataSource() ... ods.setUser(“Scott”); ods.setPassword(“tiger”); ods.setConnectionCachingEnabled(True); ods.setFastConnectionFailoverEnabled(True); ods.setConnectionCacheName(“MyCache”); ods.setConnectionCacheProperties(cp); ods.setURL("jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on) (ADDRESS=(PROTOCOL=TCP)(HOST=VIP1)(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=VIP2)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service_name)))"); ONS on the Applications Tier The Oracle Notification Service must be installed and running on the Applications Tier nodes The ONS client is available with the 10.1.0.3 client CD For the 10.1.0.2 ONS client, contact Oracle Support Run “onsctl ping” on each application node to determine that ONS is running ONS on the Applications Tier Edit the file %ORACLE_HOME%\opmn\conf\ons.config on each mid-tier node: localport=6100 # This is the port ONS is writing to on this node remoteport=6200 # This is the port ONS is listening on this node loglevel=3 # This is the list of hosts and ports ONS is posting to. # Include RAC and client nodes. nodes=RAC1.mycompany.com:6200,RAC2.mycompany.com:6 200, RAC3.mycompany.com:6200,APPS1.mycompany.com:6200, APPS2.mycompany.com:6200 ONS on the Applications Tier When starting the application: Specify the system property – Doracle.ons.iraclehome=<location of ons on client> Include the ons.jar file in the application CLASSPATH Modifying Server-Side ONS for FCF Use the %ORA_CRS_HOME%\bin\racgons command to modify the server-side ONS configuration to be aware of the mid-tier nodes: racgons add_config APPS1.mycompany.com:6200 APPS2.mycompany.com:6200 This adds the host and port names to the OCR Differences between FCF and TAF Application-Level Connection Retries. Fast Connection Failover supports application-level connection retries. This gives the application control of responding to connection failovers. TAF supports connection retries only at the OCI/Net layer. Differences between FCF and TAF Integration with the Connection Cache Fast Connection Failover is well-integrated with the Implicit Connection Cache, which allows the connection cache manager to manage the cache for HA. Failed connections are automatically invalidated in the cache. TAF works at the network level on a perconnection basis, which means that the connection cache cannot be notified of failures. Differences between FCF and TAF Event-Based Fast Connection Failover is based on the RAC event mechanism. This means that Fast Connection Failover is efficient and detects failures quickly for both active and inactive connections. TAF is based on the network call mechanism. Differences between FCF and TAF Load-Balancing Support Fast Connection Failover supports UP event load balancing of connections and runtime work request distribution across active RAC instances. Review What are the two key configuration files for Oracle Net? What key phrase in the tnsnames.ora file influences load balance behaviour? What key phrase in the tnsnames.ora file influences failover behaviour? Which Oracle Net configurations allow users to maintain connections through a failover event? Which JDBC drivers are supported under TAF and FCF? What is the name of the utility to add mid-tier nodes to the server-side ONS configuration? Summary Listener process Configuration files Failover listener.ora tnsnames.ora Basic Preconnect Load Balancing TAF JDBC Thick and Thin drivers and TAF Setting up Fast Connection Failover