Some basic knowledge about Oracle11gRAC

Source: Internet
Author: User
Tags taf
Oracle11gr2 also provides a new feature called RACOneNode. Oracle finds that the deployment of some RAC is purely for high availability, and more users are using virtualization.

Oracle 11g r2 also provides a new feature called RAC One Node. Oracle finds that the deployment of some RAC is purely for high availability, and more users are using virtualization.

In general, Oracle 11g R2 RAC provides the following features:

  • High Availability: shared-everything mode ensures that services are not stopped when a single node fails, and other nodes in the cluster will take over quickly
  • Scalability: multiple nodes share the load and can provide processing capabilities far beyond that of a single database. Addition and deletion of nodes can be completed online without downtime
  • Ease of use: multiple databases can be added to a cluster.
  • Low Cost: RAC can be deployed on standard hardware. The cost saved on the hardware offset the cost of purchasing the license.
  • Oracle 11g r2 also provides a new feature called RAC One Node. Oracle finds that the deployment of some RAC is purely for high availability, and virtualization is increasingly used by users and has become a new trend. Oracle One Node is built on the following foundations: Oracle Clusterware, Oracle ASM, and Oracle database.


    Let's take a look at the RAC structure.



    Compared with standalone databases, RAC requires a shared storage, a private network for internal communication within the cluster, and a public network for connection to applications and clients; configure a virtual IP address to increase the connection speed when a node fails. When a node fails, its virtual ip address immediately points to the ip address of another node (if no vip address is configured, when a node fails, a new connection will wait until time out occurs during communication with the ip address of the node ).


    Failover connection Configuration

    There are two Connection Methods for database connection failover


    1. TAF (Transparent Application Failover)

    Let's take a look at the official documentation. TAF allows Oracle Net to transfer an invalid connection from the fault point to another listener. the user can use this new connection to continue the unfinished work. This is a client-side function.

    TAF can be configured to connect to the client (Transparent Network Substrate) TNS connection string, or use the server service. If the two methods are used at the same time, the server-side service configuration is used.

    TAF can work in two modes: session failover and select failover. The former will rebuild the failed connection when failover, and the latter will be able to continue the unfinished query in the process (if the previous session of failover is retrieving data from a cursor, the new session will re-run the select statement in the same snapshot and return the remaining rows ). If the session performs the DML operation and is not submitted at failover, after failover, if a new operation is performed without rollback, an error message ORA-25402: transaction must roll back will be received

    TAF is used in dataguard and can automatically perform failover


    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

    Failover_mode parameter description

    The Network Service name of the BACKUP connection. If you use the preconnect connection method, you must specify this parameter.

    The interval (in seconds) between DELAY connections ). If the RETRIES parameter is specified, if this parameter is not specified, the default value is 1 second. If callback is registered, this parameter is ignored.

    Set the failover METHOD. Basic: the listener that tries to connect to the slave instance only when the slave instance is failover. preconnect: a connection is also generated on the slave instance every time you connect to the database to achieve faster switching.

    Number of attempts after RETRIESfailover. If the DELAY parameter is specified, RETRIES is set to 5 times by default. If callback is registered, this parameter is ignored.

    TYPEOCI provides three types by default: session: if a user's connection is lost, it will be re-created on the slave node; select: In addition to re-establishing the connection, it will continue to get data from the open cursor, if this method is used, normal select operations will also generate overhead on the client; none: default value, you can also specify to disable the failover Function


    2. FCF (Fast Connect Failover)

    Oracle11g provides the FCF method to connect to the database. It supports JDBC Thin and jdbc oci drivers. It works with the connection cache to provide higher connection performance and high availability; it can be set in the application code without additional configuration.

    Required condition: the implicit connection cache is enabled. FCF must work with the JDBC connection cache mechanism to manage connections for applications to ensure high availability; the application uses the Service name rather than the Service Identifier to connect to the database. Oracle Notification Service (ONS) is configured and enabled on the JDBC running node. the Java VM running the JDBC routine must contain oracle. ons. oraclehome and point to ORACLE_HOME

    Example:

    Configure 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 {
    }
    }


    Confused? The above java code contains an exception handling. The process is as follows:

    1. An Instance goes down, leaving some expired connections in the cache

    2. RAC generates an event and sends it to the Java Virtual Machine that contains JDBC.

    3. The background thread in JVM identifies all connections affected by this RAC event, notifies them through SQL exceptions (ORA-17008) to close the connection and roll back the transaction

    4. Operations that fail to be executed again after the connection receives an SQL exception


    FCF differs from TAF in the following ways:

    1. FCF supports application-level connection retries. The application determines how to handle the failover, whether to re-execute or throw an exception. TAF can only re-connect at the OCI/NET level.

    2. FCF works well with the connection cache to connect to the cache manager to manage the cache. Failed Connections will automatically expire in the cache. TAF performs a pre-connection on the network layer. When a connection fails, the connection cache cannot detect

    3. Based on Oracle RAC events, FCF can quickly detect faults for active/idle connections.

    4. FCF implements Load Balancing through instance UP events and is allocated to online RAC instances.


    We recommend that you do not use TAF and FCF in one application.

    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.