Oracle RAC Database Connection Configuration

Source: Internet
Author: User
Tags connection pooling documentation failover taf time interval

The connection URL of the database is configured as jdbc:oracle:thin:@ (description= (address_list= (address= (protocol=tcp) (HOST=VIP1)) (port=1521) ( Address= (PROTOCOL=TCP) (HOST=VIP2) (port=1521)) (Load_balance=yes) (Failover=on)) (Connect_data= (SERVICE_NAME=GS)))

String url=
"Jdbc:oracle:thin:@ (description= (address_list=" +
(Address= (PROTOCOL=TCP) (HOST=IP1) (port=1521)) +
(Address= (PROTOCOL=TCP) (HOST=IP2) (port=1521)) +
"(Load_balance=yes) (Failover=on))" +
"(Connect_data= (SERVICE_NAME=ORCL)))";

OLTP =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.2.131) (PORT = 1521))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.2.132) (PORT = 1521))
# (load_balance = yes)
(Connect_data =
(service_name = OLTP)
)
)

Is this the client's TNS?
Commenting out load_banance indicates that you are using server-side banlance?


Google results:
Http://www.easyora.net/blog/rac_10g_study_catalog_4.html


RAC provides high-performance and high-availability services for applications, and the core function for users is failover and load banance.
(1) Failover
In the 10GR2 version, Failover is implemented in two ways, one is TAF (Transparent application Failover) and one is FCF (Fast Connection Failover).
TAF and implementation:
TAF is the net layer transparent failover, which is a passive mode of failover and relies on VIPs. TAF policies can be configured through the client and server side.
<1> Client Side TAF configuration
The following is a simple Tnsnames.ora content with TAF functionality

Demo =
(DESCRIPTION =
(Failover=on)
(Address= (PROTOCOL=TCP) (host=10.194.129.145) (port=1521))
(Address= (PROTOCOL=TCP) (host=10.194.129.146) (port=1521))
(Connect_data =
(service_name = demo)
(server=dedicated)
(Failover_mode= (Type=select)
(Method=basic)
(RETRIES=50)
(delay=5)
)
)

)
Parameter description of the control TAF policy:

Parameters
Describe

FAILOVER
The Failover control switch (on/off), if off, does not provide failover functionality, but the address list is attempted on the connection until the availability is found

TYPE
Two types: Session/select

Session: Provides session-level failover.

Select: Provides select-level failover, which is transparent to query statements, but the thing class processing requires a rollback operation

METHOD
Two types: Basic/preconnect

Basic:client Connect only one node at a time, jump to another node when failover

Preconnect: Need to be used in conjunction with backup, client connects to master and backup node simultaneously


BACKUP
Alternate connection configuration with Preconnect mode

Retries
Number of retries during failover

DELAY
Retry Interval time during failover


<2> server-Side TAF configuration
The 10GR2 provides a server-side TAF configuration that requires calls to Dbms_service packages to be modified on the instance.

sql> exec dbms_service.modify_service (service_name = ' DEMO ', Failover_method = ' BASIC ', Failover_type = ' SELECT ', failover_retries = 180,failover_delay = 5);

The client connection string is modified as follows:

Demo =
(DESCRIPTION =
(Address= (PROTOCOL=TCP) (host=10.194.129.145) (port=1521))
(Address= (PROTOCOL=TCP) (host=10.194.129.146) (port=1521))
(Connect_data =
(service_name = demo)
(server=dedicated)
)
)

FCF and realization
FCF is a new failover mechanism introduced by 10g, which relies on the ONS process of each node to obtain the operation of each node through the broadcast fan event, which is a kind of proactive judgment and supports jdbc/oci/odp.net
(1). ONS configuration
The Onsctl tool configures the LOCAL/REMOTE nodes and ports for each node. configuration file Path Oracle_home/opmn/ons.config.
Use Onsctl Debug to track whether the ONS process is working correctly.
(2). Configuring connection pooling (for example in JDBC)
A connection pool is required to support implicit Connection Cache, set fastconnectionfailoverenabled=true.
Add Ojdbc14.jar/ons.jar, etc. to classpath. Specific code can be found in the online documentation or Metalink related documents.

= = another Article = =
Connection configuration for failover

There are two ways to connect a database failover

1. TAF (Transparent application Failover)

Let's take a look at the official documentation. TAF allows Oracle NET to transfer a failed connection from the point of failure to another listener, and the user can use this new connection to continue the unfinished work, which is a client-side feature.
The TAF can be configured to connect using the client-side (Transparent Network substrate) TNS connection string, or to use server-side services. If both methods are used, the server-side service configuration is used.
Taf can work in two modes: Session failover and select failover. The former rebuilds the failed connection when failover, while the latter is able to continue the unfinished query in the process (if the previous session of failover is fetching data from a cursor, the new session will rerun the SELECT statement under the same snapshot. and return the remaining rows). If the session performs a DML operation and is not committed when failover, failover will receive an error message after performing a new operation without performing a rollback rollback ora-25402:transaction must scroll back
TAF is used in Dataguard and can be failover automatically

A typical TNS connection string that uses TAF is as follows:
Newsdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = RAC1-VIP) (PORT = 1521))
(ADDRESS = (PROTOCOL = TCP) (HOST = RAC2-VIP) (PORT = 1521))
(load_balance = yes)
(Connect_data =
(SERVER = dedicated)
(service_name = Dyora)
(Failover_mode =
(TYPE = SELECT)
(METHOD = BASIC)
(retries = 180)
(DELAY = 5)
)
)
)

Failover_mode parameter Introduction
Failover_mode parameter Description
The Network service name of the backup standby connection. If you use the Preconnect connection method, you need to specify this parameter
The time interval (in seconds) that the delay connection retries. If the retries parameter is specified, the default is 1 seconds if the parameter is not specified. If callback is registered, the parameter will be ignored
method to set failover methods. Basic:failover attempts to connect to the standby instance, Preconnect: Each time the database is connected, a connection is also generated on the standby instance for a faster switchover
The number of attempts to connect after Retriesfailover. If the delay parameter is specified, retries defaults to 5 times. If callback is registered, the parameter is ignored
TYPEOCI provides 3 types by default: session: If the user connection is lost, it will be recreated on the alternate node; select: In addition to rebuilding the connection, the data will continue to be fetched from the open cursor, and if this is the case, the normal select operation will incur overhead on the client; none: Default value, can also be specified to disable the failover feature

2. FCF (Fast Connect Failover)

ORACLE11G provides a FCF way to connect to the database, which supports JDBC thin and JDBC OCI drivers, and provides higher connection performance and high availability in conjunction with the connection cache (implicit connection cache), and can be set in app code without additional configuration
Required conditions: With the implicit connection cache enabled, FCF needs to work with the JDBC Connection caching mechanism to ensure high availability for application management connections, and applications to connect to the database using the service name rather than the service identifier; The Oracle Notification is configured and enabled on the node of the JDBC runtime Service (ONS); the Java Virtual machine running the JDBC routine must contain oracle.ons.oraclehome and point to Oracle_home
Example:
Configuring ONS
Ods.setonsconfiguration ("nodes=racnode1.example.com:4200,racnode2.example.com:4200");
Enable FCF
DECLARE datasource
Ods.seturl (
"Jdbc:oracle:oci:@ (description=
(Address= (PROTOCOL=TCP) (Host=cluster_alias)
(port=1521))
(Connect_data= (Service_name=service_name)));
Ods.setuser ("Scott");
Ods.setconnectioncachingenabled (TRUE);
Ods.setfastconnectionfailoverenabled (True):
Ctx.bind ("MyDS", ODS);
Ds= (Oracledatasource) ctx.lookup ("MyDS");
try {
Ds.getconnection (); Transparently creates and accesses cache
catch (SQLException SE {
}
}

You look confused? The above Java code contains an exception handling. The working process is as follows:
1. One instance is down, leaving some outdated connections in the cache
2. RAC generates an event and sends it to a Java virtual machine that contains JDBC
3. The background thread in the JVM finds all the connections affected by the RAC event, notifies them to close the connection by SQL exception (ORA-17008), and rolls back the transaction
4. Connect to receive SQL exception and re-execute failed operation

FCF differs from TAF in the following ways:
1. FCF supports application-level connection retry, which is used by the application to determine what to do with failover, whether to re-execute or throw an exception; Taf can only reconnect at oci/net level
2. The FCF is well combined with the connection cache to allow the connection cache manager to manage the cache, and failed connections are automatically invalidated in the cache. While the TAF is pre-connected at the network level, when a connection fails, the connection cache cannot detect
3. FCF based on Oracle RAC events, can quickly detect a failure for an active/idle connection
4. FCF load balancing with instance up events, allocated to online RAC instances

Oracle recommends that you do not use both TAF and FCF in one application

Note: This article is reproduced in http://wallimn.iteye.com/blog/1345102

Oracle RAC Database Connection Configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.