CertMan

Post Contents

Oracle 19c Services with Client Applications in RAC

Oracle 19c Services with Client Applications in RAC

In this blog, we will explore the integration of services with client applications in an Oracle 19c Real Application Cluster (RAC) environment. This integration is crucial for achieving high availability, load balancing, and efficient resource management in a clustered database setup.

Oracle 19c’s RAC environment allows for the seamless operation of multiple database instances across different servers. By using RAC services, you can manage client connections more effectively, ensuring that applications experience minimal downtime and optimal performance. In this post, we’ll focus on configuring and managing RAC services to maximize the benefits of your RAC setup.

 

Setting Up RAC Services

Set up your RAC environment properly and ensure all nodes in the cluster communicate correctly before configuring RAC services. Check the network configuration, shared storage, and verify that Oracle Grid Infrastructure is installed and running on all nodes. Proper setup of the RAC environment is essential for smooth operation and service management.

Step 1: Define the Service Name

The first step in setting up RAC services is to define a service name that will be used by client applications to connect to the database. This name should be unique within the cluster and should reflect the purpose of the service.

Step 2: Configure the Service Parameters

Specify the table for data loading and the columns to receive the data. Define how to delimit the data fields and apply any necessary transformations.

Parameters to configure include:

  • Service Edition: Specifies the edition of the database service.
  • Service Management Policy: Determines how the service is managed, whether manually or automatically.
  • Database Role: Defines the role of the service, such as primary or standby.
  • Instance Preference: Specifies the preferred instances where the service should run.
  • Server Pool Assignment: Associates the service with a specific server pool for load balancing.
  • Load Balancing Advisory Goal: Sets the goal for runtime connection load balancing, either long or short.

Step 3: Create the Service

Use the srvctl command to create the service. For example, to create a service named MY_SERVICE with a preferred instance INSTANCE1 and an available instance INSTANCE2, use the following command:

srvctl add service -db MYDB -service MY_SERVICE -preferred INSTANCE1 -available INSTANCE2

If the preferred instance is unavailable, the service will start on the available instance.

 

Managing RAC Services

Managing RAC services involves monitoring their status, starting and stopping services, and modifying service parameters as needed. Effective management ensures that services are running optimally and that client applications can connect without issues.

Checking Service Status

To check the status of a service, use the following command:

srvctl status service -db MYDB -s MY_SERVICE

This command checks the status of the service and can be used to ensure that failover configurations are correctly applied.

Starting and Stopping Services

To start a service, use:

srvctl start service -db MYDB -service MY_SERVICE

To stop a service, use:

srvctl stop service -db MYDB -service MY_SERVICE

Disabling a Service

To disable a service on a specific instance, use:

srvctl disable service -db MYDB -service MY_SERVICE -instance INSTANCE1

Relocating a Service

To relocate a service from one instance to another, use:

srvctl relocate service -db MYDB -service MY_SERVICE -oldinst INSTANCE1 -newinst INSTANCE2

 

Configuring Load Balancing and Failover

RAC handles node failures gracefully. Configure your services with appropriate failover settings to minimize downtime. Load balancing distributes client connections across the instances in the cluster, optimizing resource utilization and performance.

Modifying Load Balancing Goal

You can modify the load balancing goal for a service using:

srvctl modify service -service MY_SERVICE -clbgoal LONG/SHORT
  • LONG: For applications with long-lived connections.
  • SHORT: For applications with short-lived connections.

Configuring Transparent Application Failover (TAF)

TAF allows client connections to automatically failover to another instance in the event of a failure. Configure TAF using:

srvctl modify service -db MYDB -service MY_SERVICE -failovermethod BASIC -failovertype SELECT -failoverretry 10 -failoverdelay 30
  • BASIC: The connection is reestablished at the time of failover.
  • PRECONNECT: A shadow connection is created in advance to anticipate failover.

 

Integrating RAC Services with Client Applications

Integrating RAC services with client applications involves configuring the tnsnames.ora file on the client side to ensure proper connectivity and load balancing.

TNS Configuration for Client Applications

The tnsnames.ora file needs to be configured to use the RAC services effectively. Below is an example configuration:

MY_SERVICE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = my-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = MY_SERVICE)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 10)
(DELAY = 30)
)
)
)

In this configuration:

  • HOST: Specifies the SCAN (Single Client Access Name) address for the RAC cluster.
  • SERVICE_NAME: Specifies the name of the service defined in the cluster.
  • FAILOVER_MODE: Configures the failover method, type, retries, and delay for TAF.

Client Application Connection

To connect to the RAC database using the service, the client application needs to reference the service name defined in the tnsnames.ora file. For example, a connection string in JDBC might look like this:

String url = "jdbc:oracle:thin:@my-cluster-scan:1521:MY_SERVICE";
Connection conn = DriverManager.getConnection(url, "username", "password");

This ensures that the application uses the RAC services for connections, taking advantage of load balancing and failover capabilities.

 

Advanced Service Management

For advanced service management, consider integrating services with Oracle Resource Manager and Scheduler. These integrations allow for more granular control over resource allocation and job scheduling, enhancing the overall efficiency of your RAC environment.

Resource Manager Integration

Associate services with consumer groups to manage workloads based on priority. For example, allocate more resources to high-priority services to ensure critical operations remain unaffected

Scheduler Integration

Associate services with job classes in Oracle Scheduler to enable load balancing and high availability of scheduled jobs. This ensures that jobs can continue to run even if one instance in the cluster fails.

Creating a Job Class with Service Association

To create a job class associated with a service, use:

BEGIN
DBMS_SCHEDULER.create_job_class(
job_class_name => 'my_job_class',
service => 'my_service',
logging_level => DBMS_SCHEDULER.LOGGING_FULL);
END;

This association allows for better workload management and performance tuning.

 

Conclusion

Effective use of RAC services with client applications ensures high availability, load balancing, and efficient resource management in an Oracle 19c RAC environment. By carefully configuring and managing these services, you can optimize your database performance and minimize downtime, providing a robust and reliable experience for your users.

See more on Oracle’s website!

Be Oracle RAC and GRID Certified Professional, this world is full of opportunities for qualified DBAs!

Leave a Reply

Your email address will not be published. Required fields are marked *