Configuring JDBC data-sources

Similar documents
What every DBA needs to know about JDBC connection pools Bridging the language barrier between DBA and Middleware Administrators

What every DBA needs to know about JDBC connection pools * Bridging the language barrier between DBA and Middleware Administrators

FCUBS GridLink Datasource Configuration Oracle FLEXCUBE Universal Banking Release [May] [2018]

White Paper. Major Performance Tuning Considerations for Weblogic Server

Application High Availability with Oracle

SOA Cloud Service Automatic Service Migration

Contents at a Glance. vii

WebLogic & Oracle RAC Active GridLink for RAC

WebLogic Active GridLink: Intelligent integration between WebLogic Server and Oracle Database Real Application Clusters

Configuring and Managing JDBC Data Sources for Oracle WebLogic Server g Release 1 (10.3.6)

Bipul Sinha, Amit Ganesh, Lilian Hobbs, Oracle Corp. Dingbo Zhou, Basavaraj Hubli, Manohar Malayanur, Fannie Mae

BEAWebLogic. Server. Configuring and Managing WebLogic JDBC

ORACLE DATA SHEET KEY FEATURES AND BENEFITS ORACLE WEBLOGIC SUITE

X100 ARCHITECTURE REFERENCES:

<Insert Picture Here> WebLogic JMS Messaging Infrastructure WebLogic Server 11gR1 Labs

Oracle Database 11g: RAC Administration Release 2 NEW

Maximum Availability Architecture

BEAWebLogic. Server. Automatic and Manual Service-level Migration

Oracle WebLogic Server

Administering WebLogic Server on Java Cloud Service I Ed 1 Coming Soon

BEAAquaLogic. Service Bus. Interoperability With EJB Transport

Putting Oracle Database 11g to Work for Java. Kuassi Mensah Group Product Manager, Java Platform Group db360.blogspot.com

Oracle WebLogic Server Integration with Oracle Database 12c O R A C L E W H I T E P A P E R O C T O B E R

WLS Neue Optionen braucht das Land

Must know Database facts for WAS 6.1

Oracle WebLogic Server 12c: Administration I

Contract Information Management System (CIMS) Technical System Architecture

Oracle Fusion Middleware

BEA WebLogic. Server. MedRec Clustering Tutorial

Installing and Configuring Oracle HTTP Server 12c (12.1.3)

Oracle WebLogic Server 11g: Administration Essentials

1Z Oracle WebLogic Server 12c - Administration I Exam Summary Syllabus Questions

ORACLE WEBLOGIC SERVER

Ignite Key-Value Transactions Architecture

Oracle Fusion Middleware

An Oracle White Paper November Oracle RAC One Node 11g Release 2 User Guide

Migrating to the P8 5.2 Component Manager Framework

BEAWebLogic Server. Introduction to BEA WebLogic Server and BEA WebLogic Express

Sustaining Planned/Unplanned Database Outages: Best Practices for DBAs & Developers

Developing JTA Applications for Oracle WebLogic Server 12c (12.2.1)

Oracle Privileged Account Manager

Diplomado Certificación

Chapter 2 WEBLOGIC SERVER DOMAINS. SYS-ED/ Computer Education Techniques, Inc.

1z z Oracle WebLogic Server 12c: Administration I

Administering JMS Resources for Oracle WebLogic Server c (12.1.3)

WebLogic Server- Tips & Tricks for Troubleshooting Performance Issues. By: Abhay Kumar AST Corporation

Data Management in Application Servers. Dean Jacobs BEA Systems


An Oracle White Paper July Oracle WebLogic Suite 12c (12.1.2) Technical White Paper

CO Oracle WebLogic Server 12c. Administration II. Summary. Introduction. Prerequisites. Target Audience. Course Content.

Roadmap to Cloud with Cloud Application Foundation

Oracle Fusion Middleware

Understanding Oracle RAC ( ) Internals: The Cache Fusion Edition

Oracle Database 12c: RAC Administration Ed 1

RAC for Beginners. Arup Nanda Longtime Oracle DBA (and a beginner, always)

How to Setup Application Server to Access DB2 z/os with High Availability

Dynamic Clusters in WebLogic Server

2-PHASE COMMIT PROTOCOL

Configuring the Oracle Network Environment. Copyright 2009, Oracle. All rights reserved.

Websphere Server 8.5 Best Practices Oracle FLEXCUBE Universal Banking Release [December] [2016]

dist_tran_fail.sql connect rem reenable distributed recovery to clean up rem any in-doubt distributed transactions pause

Oracle Fusion Middleware

Oracle Fusion Middleware

J2EE: Best Practices for Application Development and Achieving High-Volume Throughput. Michael S Pallos, MBA Session: 3567, 4:30 pm August 11, 2003

Oracle 1Z0-054 Exam Questions and Answers (PDF) Oracle 1Z0-054 Exam Questions 1Z0-054 BrainDumps

1z Number: 1z0-133 Passing Score: 800 Time Limit: 120 min File Version: z0-133

Oracle Fusion Middleware

Oracle Service Bus. Interoperability with EJB Transport 10g Release 3 (10.3) October 2008

Oracle Database 12c: RAC Administration Ed 1 LVC

Oracle EXAM - 1Z Oracle Database 11g: Performance Tuning. Buy Full Product.

TRANSACTION PROCESSING CONCEPTS

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 10: Transaction processing. November 14, Lecturer: Rasmus Pagh

Broker Clusters. Cluster Models

Using Clusters for Oracle WebLogic Server g Release 1 (10.3.6)

CORBA Object Transaction Service

Oracle Application Server 10g Release 3 (10.1.3) - Data Access for the Agile Enterprise. An Oracle White Paper August 2005

Information Systems (Informationssysteme)

ORACLE WEBLOGIC SERVER 10g R3 ENTERPRISE EDITION

Load Balancing and Failover with Oracle 10gR2 RAC

Oracle Fusion Middleware

Oracle Fusion Middleware

MTAT Enterprise System Integration. Lecture 11: Integrity Aspects in Enterprise System Integration

Oracle 11g Release 2 RAC & Grid Infrastructure Administration Course Overview

Oracle Database 10g The Self-Managing Database

Oracle WebLogic Server

JAP transaction processing failure scenarios

Monday, November 21, 2011

Transaction service settings

Oracle WebLogic Server 12c on AWS. December 2018

Oracle Database 12c: Clusterware & RAC Admin Accelerated Ed 1

Oracle WebLogic Server 12c: JMS Administration Student Guide

Configuring Weblogic Server Oracle FLEXCUBE Universal Banking Release [September] [2013] Part No. E

1Z Oracle Application Grid 11g Essentials Exam Summary Syllabus Questions

The Oracle DBMS Architecture: A Technical Introduction

VMware HA: Overview & Technical Best Practices

Database Binding Component User's Guide

5. Distributed Transactions. Distributed Systems Prof. Dr. Alexander Schill

Masterclass: WebLogic Server for OAS Administrators

Oracle 1Z Oracle Weblogic Server 11g- System(R) Administration I.

1Z Oracle. Oracle Real Application Clusters 11g Release 2 and Grid Infrastructure Administration

Transcription:

Configuring JDBC data-sources Author: Jacco H. Landlust Date: 05 november 2012 Introduction Within multiple layered Oracle Middleware products different types of JDBC data-sources are configured out of the box. JDBC data sources provide database access and database connection management. Each data source contains a pool of database connections that are created when the data source is created and at server startup. Every data source has a name with a sole purpose an unique identifier within the WebLogic domain. To avoid conflicts the name should be unique amongst other objects in the WebLogic domain (servers, clusters, etc). A data source binds to the JNDI with a configurable name. A data source can use multiple names for binding to the JNDI tree. You can use a multi-jndi-named data source in place of legacy configurations that included multiple data sources that pointed to a single JDBC connection pool. Based on the type of JDBC driver Oracle automatically selects default transaction options for you. The defaults work mostly with some exceptions. These will be described at Configure WebLogic. Only deviations from default will be mentioned. To be able to use all features of a data-source, sometimes changes to the database configuration are needed. These changes are described at Configure Database. This document is not a full insight into the working of every aspect of JDBC data-sources, it only highlights what I think is relevant in most out of the box situations. Lots of the content is just cutand-paste from documents written by other smart people. I tried to add all of them in the appendixes so they can be used as reference. The document assumes you are running at least WebLogic Server 10.3.4 and Oracle RDBMS 11.2. Features and caveats from older versions of WebLogic or the Oracle RDBMS are not discussed.

Configure WebLogic When changing configuration of default JDBC data sources the following subjects are relevant: 1. JDBC URL 2. JTA timeout 3. XA 4. GridLink 5. Statement Cache 6. Connection Testing JDBC URL Single Client Access Name (SCAN) is s a new Oracle Real Application Clusters (RAC) 11g Release 2 feature that provides a single name for clients to access Oracle Databases running in a cluster. The benefit is that the client s connect information does not need to change if you add or remove nodes in the cluster. Having a single name to access the cluster allows clients to use the simple JDBC thin URL to access any database running in the cluster, independently of which server(s) in the cluster the database is active. SCAN provides load balancing and failover for client connections to the database. The JDBC URL should be setup as: jdbc:oracle:thin:@rdbms-scan:scan-port/service_name Where rdbms-scan is the scan of the database cluster, the scan-port is the port of the scan listeners, the service_name is the service_name that is used for connection to the database. JTA timeout You can configure Java Transaction API (JTA) attributes to suit your environment. The Administration Console provides default values for all JTA configuration attributes. Configuration settings for JTA are applicable at the domain level. This means that configuration attribute settings apply to all servers within a domain. Monitoring and logging tasks for JTA are performed at the server level. Once you configure WebLogic JTA and any transaction participants, the system can perform transactions using the JTA API and the WebLogic JTA extensions. The timeout can be set either from the console, or by running this WLST snippet: cd( /JTA/area51_domain ) cmo.settimeoutseconds(300) Please replace area51_domain with the name of the domain you are changing the JTA timeout for XA XA data-sources are used. XA stands for extended Architecture and is an X/Open group standard for executing a "global transaction" that accesses more than one back-end data-store. XA specifies how a transaction manager will roll up the transactions against the different data-stores into an "atomic" transaction and execute this with the two-phase commit (2PC) protocol for the transaction. Thus, XA is a type of transaction coordination, often among databases. ACID Transactions are a key feature of databases, but typically databases only provide the ACID guarantees for activities that

happen inside a single database. XA coordination allows many resources (again, often databases) to participate in a single, coordinated, atomic update operation. In computing, the XA standard is a specification by The Open Group for distributed transaction processing (DTP). It describes the interface between the global transaction manager and the local resource manager. The goal of XA is to allow multiple resources (such as databases, application servers, message queues, transactional caches, etc.) to be accessed within the same transaction, thereby preserving the ACID properties across applications. XA uses a two-phase commit to ensure that all resources either commit or rollback any particular transaction consistently (all do the same). The XA specification describes what a resource manager must do to support transactional access. Resource managers that follow this specification are said to be XA-compliant. The XA specification was based on an interface used in the Tuxedo system developed in the 1980s, but adopted by several systems since then An XA transaction can span Oracle RAC instances by default, allowing any application that uses the Oracle XA library to take full advantage of the Oracle RAC environment to enhance the availability and scalability of the application. Whenever you select a JDBC data source with an XA JDBC driver (oracle.jdbc.xa.client.oraclexadatasource) the XA transaction timeout should be enabled and configured to a time value. This time value should be greater than the JTA timeout: XA Transaction Timeout >= WebLogic Server JTA timeout Next to the timeout you need to enable cleaning unfinished/pending transactions. The WebLogic Server transaction manager retries the commit call every minute, until a valid XAResource instance is registered with the WebLogic Server transaction manager, if the setting Recover only once is allowed and the commit call failure then the Weblogic Server transaction manager calls recover on the resource only once and not every minute. If you set the XaTransactionTimeout ot 0 it defaults to the WebLigic Server JTA timeout. The following WLST snippet enables the XA transaction timeout for all XA data sources in the domain and sets the timeout to 0 (default JTA timeout). Also it sets the XaEndOnlyOnce setting and RecoverOnlyOnce settings to clean up pending transactions. cd('/jdbcsystemresources') redirect('/dev/null','false') DSS=ls(returnMap='true') redirect('/dev/null','true') for DS in DSS: cd('/jdbcsystemresources/' + DS) dsname = cmo.getname() cd('/jdbcsystemresources/' + DS + '/JDBCResource/' + DS + '/JDBCDriverParams/' + DS ) dsdrivername = cmo.getdrivername() print "JDBC " + dsname + " has driver " + dsdrivername if dsdrivername == 'oracle.jdbc.xa.client.oraclexadatasource':

cd('/jdbcsystemresources/' + DS + '/JDBCResource/' + DS + '/JDBCXAParams/' + DS) XaTimeOut = cmo.getxatransactiontimeout() print "XA transaction timeout for " + dsname + " was set to " + str(xatimeout) try: cmo.setxatransactiontimeout(0) cmo.setxasettransactiontimeout(true) cmo.setxaendonlyonce(true) cmo.setrecoveronlyonce(true) print dsname + now has XA timeout enabled and set to 300 except: print cannot set XaTransactionTimeout GridLink Active GridLink for Oracle RAC In Oracle WebLogic Server 10.3.4, a single data source implementation has been introduced to support an Oracle RAC cluster. It responds to FAN events to provide Fast Connection Failover (FCF), Runtime Connection Load-Balancing (RCLB), and RAC instance graceful shutdown. XA affinity is supported at the global transaction Id level. The feature is called WebLogic Active GridLink for RAC; which is implemented as the GridLink data source within WebLogic Server. The name changed over versions and is nowadays called just GridLink. The Universal Connection Pool Java library has been integrated with WebLogic Server to utilize WebLogic Server work manager and timer manager implementations for internal task scheduling and timer event processing for improved resource utilization and manageability. The RAC integration capabilities of UCP have been utilized by the Oracle RAC data source implementation to provide the FCF, RCLB and affinity features. To simplify and consolidate its support for Oracle RAC, WebLogic Server has provided a single data source that is enhanced to support the capabilities of Oracle RAC. It provides a single connection pool/data source within Oracle WebLogic Server that supports the consumption of database services in an unrestricted manner. This is the key foundation for providing deeper integration with Oracle RAC. This single data source implementation in Oracle WebLogic Server supports the full and unrestricted use of database services as the connection target for a data source. The active management of the connections in the pool is based on static settings configured on the connection pool itself (min/max capacity, timeouts, etc.) and real time information the connection pool receives from the RAC ONS subsystem that advises the client of any state changes within the RAC cluster. FastConnection Failover A GridLink data source uses Fast Connection Failover to: Provide rapid failure detection Abort and remove invalid connections from the connection pool Perform graceful shutdown for planned and unplanned Oracle RAC node outages Adapt to changes in topology, such as addingor removing a node

Distribute runtime work requests to all active Oracle RAC instances, including those rejoining a cluster Runtime Connection Load Balancing To provide better throughput and more efficient use of resources, the Oracle Database provides a runtime load balancing service to distribute connections across the RAC instance based on performance goals set by a DBA. The load balancing advisory service issues FAN events that advise clients on the current state of the cluster including advice on where to direct connections. GridLink data sources provide load balancing in XA and non-xa environments. GridLink data sources use runtime connection load balancing to distribute connections to Oracle RAC instances based on Oracle FAN events issued by the database. This simplifies data source configuration and improves performance as the database drives load balancing of connections through the GridLink data source, independent of the database topology. Runtime Connection Load Balancing allows WebLogic Server to: Adjust the distribution of work based on back end node capacities such as CPU, availability, and response time React to changes in Oracle RAC topology Manage pooled connections for high performance and scalability XA Affinity XA affinity is a performance feature that ensures that all database operations performed on a RAC cluster within the context of a global transaction are directed to the same RAC instance. Affinity will be established based on the global transaction id, instead of by individual data source, to ensure that connections obtained from different data sources that are configured for the same RAC cluster are all associated with the same RAC instance. The affinity capabilities provided by UCP will be leveraged to assign connections based on GTRID even when different data sources are accessed on the same, and separate, WebLogic Server instances. The Last Logging Resource two-phase commit optimization will be supported by the RAC data source and will also participate in XA affinity. The first connection request for an XA transaction is load balanced using RCLB and is assigned an Affinity context. All subsequent connection requests are routed to the same Oracle RAC instance using the Affinity context of the first connection. Configure Generic Data Source into a GridLink Data Source To change a generic data source into a GridLink data source FAN needs to be enabled and configured. The following WLST snippet enables FAN and configures the ONS servers: cd('/jdbcsystemresources') redirect('/dev/null','false') DSS=ls(returnMap='true') redirect('/dev/null','true') for DS in DSS: cd('/jdbcsystemresources/' + DS + '/JDBCResource/' + DS + '/JDBCOracleParams/' + DS ) try: cmo.setfanenabled(true)

cmo.setonsnodelist('area51-scan:6200') except: print cannot set FAN parameters You have to replace area51-scan with the scan address of your database cluster. Statement Cache When you use a prepared statement or callable statement in an application or EJB, there is considerable processing overhead for the communication between the application server and the database server and on the database server itself. To minimize the processing costs, WebLogic Server can cache prepared and callable statements used in your applications. When an application or EJB calls any of the statements stored in the cache, WebLogic Server reuses the statement stored in the cache. Reusing prepared and callable statements reduces CPU usage on the database server, improving performance for the current statement and leaving CPU cycles for other tasks. The Statement Cache Size attribute determines the total number of prepared and callable statements to cache for each connection in each instance of the data source. By caching statements, you can increase your system performance. However, you must consider how your DBMS handles open prepared and callable statements. In many cases, the DBMS will maintain a cursor for each open statement. This applies to prepared and callable statements in the statement cache. If you cache too many statements, you may exceed the limit of open cursors on your database server. For example, if you have a data source with 10 connections deployed on 2 servers, if you set the Statement Cache Size to 10 (the default), you may open 200 (10 x 2 x 10) cursors on your database server for the cached statements. The following WLST sets the statement cache to 10 for all data sources in the domain: cd('/jdbcsystemresources') redirect('/dev/null','false') DSS=ls(returnMap='true') redirect('/dev/null','true') for DS in DSS: cd('/jdbcsystemresources/' + DS) dsname = cmo.getname() cd('/jdbcsystemresources/' + DS + '/JDBCResource/' + DS + '/JDBCConnectionPoolParams/' + DS ) try: cmo.setstatementcachesize(10) except: print Cannot set StatementCacheSize Connection Testing To make sure that the database connections in a data source remain healthy, you should periodically test the connections. Automatic testing is configured out of the box. The only caveat is the actual query it runs (select 1 from dual). Whenever you setup a data source with a high number of inactive connections, you spend lots of logical I/O s on testing connections. This high number of inactive connections might be appropriate though (it hardly ever is!). If it is appropriate, then change the query to show user.

Multi data sources Multi data sources are the usual solutions from a Java prospective for a problem: add another abstraction layer. It is an abstraction layer over multiple data sources, hence the name. In my opinion multi data sources are obsolete and are fully replaced with GridLink.

Configure Database For a database there is no difference in connections from a JDBC data source or some other client. Specific settings do apply because of choices made while configuring the JDBC data sources. The following settings should be reviewed upon every installation of some Oracle Middleware product: - Open cursors - Processes - Service names When running XA the following should be reviewed additionally: - Distributed lock timeout - DTP services open cursors The Oracle Repository Creation Utility (RCU) requires the open_cursors to be set to 500. In my opinion this is an arbitrary number, since the number of open cursors depends on the statement cache of the JDBC data sources (amongst other things). For example, if you have a data source with 10 connections deployed on 2 servers, if you set the Statement Cache Size to 10 (the default), you may open 200 (10 x 2 x 10) cursors on your database server for the cached statements just for this data source. The minimum number for open_cursors per instance should be: SUM ( For each data source with a JDBC URL pointing to one specific database: ( statement_cache_size X targeted_servers ) ) Processes Every JDBC data source has a maximum number of connections. This value should be multiplied with the number of servers the data source is deployed on. Summing this for all data sources that are running on one database you would get the minimum number of processes that need to be available on an instance. For example, if you have a data source with maximum 10 connections deployed on 2 servers, you would need at least 20 (10 x 2) processes available on every instance in your RAC for the JDBC data source to work properly. Service names It is good practice to use a non-default RAC service to connect to the database. This enables resource management and enhanced monitoring capabilities. You can create a service via the srvctl utility. This example assumes that you database is called RACDB and it has instances on at least two nodes (RAC1 and RAC2). The service_name chosen is FMW_SERVICE and it is running preferred on instance RAC1. If for some reasons that instance fails it has RAC2 as available instance. srvctl add service d RACDB s FMW_SERVICE r RAC1 a RAC2 srvctl start service FMW_SERVICE

Distributed lock timeout When defining the value for distributed_lock_timeout one should consider the settings of the XA Transaction Timeout. The distributed lock timeout should be longer than the XA timeout. XA Transaction Timeout <= distributed_lock_timeout The actual value that is appropriate should be defined by the development team that is working on the application. Whenever the timeout has been reached, an error will be thrown at the client starting the transaction. The actual transaction will be rolled back. The actual error is: ORA-02049 timeout: distributed transaction waiting for lock DTP services Please be aware that DTP services is not supported in combination with GridLink data sources. This option is only available if you choose not to use GridLink and therefore not discussed in this document. Administration When managing JDBC data sources some basic tooling exists. Not all of it will be discussed in this document, but especially for XA enabled JDBC data sources some special administration tooling / skill is required. Privileges To be able to configure JDBC data sources in WebLogic Server you need a user that is member of the Administrators group. For monitoring of JDBC data sources membership of the Operators group is sufficient. To be able to modify Oracle RDBMS settings as required for JDBC data sources the ALTER SYSTEM system privilege is needed. If you want to configure DTP service s you need access to the OSDBA group on the RDBMS server. For monitoring of XA transaction first the xaviews.sql script from $ORACLE_HOME/rdbms/admin needs to be run. Next up select privleges on the following needs to be available: - v$xatrans$ - pending_trans$ - dba_2pc_pending - dba_pending_transactions Also grant force any transaction to my_datasource_user and grant execute on dbms_system to my_datasource_user needs to be executed For monitoring of DTP services you need access to the GV$ACTIVE_SERVICES view. Monitor running transactions The Oracle database allows access to the following information on distributed transactions within the database: - Information on unresolved distributed transactions (e.g. prepared and awaiting commit/rollback) is available via the DBA_PENDING_TRANSACTIONS system view.

- Information on distributed transactions awaiting recovery (e.g. in-doubt transactions) is available via the DBA_2PC_PENDING system view. - Information on the currently active distributed transactions is available via the V$GLOBAL_TRANSACTION system view. - Information on incoming and outgoing connections for pending transactions within an Oracle distributed transaction is available via the DBA_2PC_NEIGHBORS system view. Purging old distributed transactions that have been manually resolved can be achieved using EXECUTE DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('<tran_id>') Details of how this procedure is used is described in My Oracle Support Note: 159377.1 How to Purge a Distributed Transaction from a Database.

Appendixes References Services and Services and Distributed Transaction Processing in Oracle RAC http://docs.oracle.com/cd/e11882_01/rac.112/e16795/hafeats.htm#babbbcfg X/Open XA http://en.wikipedia.org/wiki/x/open_xa WebLogic documentation for datasources http://docs.oracle.com/cd/e13222_01/wls/docs90/jdbc_admin/jdbc_datasources.html Active GridLink configuration http://www.oracle.com/technetwork/middleware/weblogic/wls-jdbc-gridlink-howto-333331.html Coordinating XAResources with the WebLogic Server Transaction Manager http://docs.oracle.com/cd/e13222_01/wls/docs100/jta/jtatxexp.html XA and Oracle controlled Distributed Transactions http://www.oracle.com/technetwork/database/clustering/overview/distributed-transactions-andxa-163941.pdf Oracle Fusion Middleware Configuring and Managing JDBC Data Sources for Oracle WebLogic Server 11g Release 1 (10.3.6) http://docs.oracle.com/cd/e23943_01/web.1111/e13737/oracle_rac.htm#chdhhcaj SINGLE CLIENT ACCESS NAME (SCAN) http://www.oracle.com/technetwork/database/clustering/overview/scan-129069.pdf