May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Different approaches for connecting Weblogic Server to RAC database

Oracle Real Application Clusters (RAC) is a software component you can add to a high-availability solution that enables users on multiple machines to access a single database with increased performance. RAC comprises two or more Oracle database instances running on two or more clustered machines and accessing a shared storage device via cluster technology.

oracle

If your application requires load balancing across RAC nodes, WebLogic Server supports this capability through use of Using Connect-Time Load Balancing/Failover with Oracle RAC(JDBC URL based Load Balancing/Failover), JDBC Multi Data sources with Oracle RAC nodes and Gridlink Data Source.
Multi Data Source:

Refer the below URL’s for details on Multi Data Source.

 

JDBC Multi Data Sources in weblogic server

multi data source is an abstraction around a group of data sources that provides load balancing or failover processing between the data sources associated with the multi data source. Multi data sources are bound to the JNDI tree or local application context just like data sources are bound to the JNDI tree. The Multi Data Source can be used in the same way as we use a Data Source.

oracle-2

When an application requests a connection, the Multi Data Source determines which data source will provide a connection based on the selected algorithm.

Create two or more data sources, and then create a Multi Data Source and assign data sources to the Multi Data Source.

weblogicssrrerew-11

Configurations for the Multi Data Source.

Algorithm Type

Load-Balancing

Connection requests to a load-balancing multi data source are served from any data source in the list. The multi data source selects data sources to use to satisfy connection requests using a round-robin scheme. When the multi data source provides a connection, it selects a connection from the data source listed just after the last data source that was used to provide a connection. Multi data sources that use the Load Balancing algorithm also fail over to the next data source in the list if a database connection test fails and the connection cannot be replaced, or if the data source is suspended.

Failover

The Failover algorithm provides an ordered list of data sources to use to satisfy connection requests. Normally, every connection request to this kind of multi data source is served by the first data source in the list. If a database connection test fails and the connection cannot be replaced, or if the data source is suspended, a connection is sought sequentially from the next data source on the list.

FailoverRequestIfBusy

With the Failover algorithm, this attribute enables failover when all connections in a data source are in use.

TestFrequencySeconds

This attribute controls the frequency at which Weblogic Server checks the health of data sources previously marked as unhealthy to see if connections can be recreated and if the data source can be re-enabled.

 

Creating JDBC Multi Data Source through WLST

The below WLST script will help us to create the Multi Data Source in weblogic server.CreateMultiDataSource.py

adminURL=’t3://<<Admin Server Host>>:<<Port>>’
adminUserName=’weblogic’
adminPassword='<<Password>>’
connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
jdbcSystemResource = create(“MS1″,”JDBCSystemResource”)
jdbcResource = jdbcSystemResource.getJDBCResource() 
jdbcResource.setName(“MS1”)
dsParams = jdbcResource.getJDBCDataSourceParams()
jndiName=’jdbc/MS1′
dsParams.setJNDINames([jndiName])
dsParams.setAlgorithmType(‘Failover’)
dsParams.setDataSourceList(‘DS1,DS2’)
dsParams.setFailoverRequestIfBusy(true)
jdbcSystemResource.addTarget(getMBean(‘Servers/AdminServer’))
print(‘MDS1 created successfully…’)
save()
activate()
disconnect()

Before executing this script the member data sources(DS1,DS2) should be created.

 

Connect-Time Load Balancing/Failover with Oracle RAC(JDBC URL based Load Balancing/Failover):

The JDBC connection string can be configure with single data source to support the load balancing and failover with RAC data source nodes.
Create a Generic Data source in weblogic server and provide the JDBC URL as below.Enable and disable the load balancing and failover accordingly.

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=tcp)(HOST=RAC node1)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=RAC node2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))

 

weblogicssrrerew-12

 

There are some limitation using this approach like the Global XA transactions are not supported.

Gridlink Data Source:

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 new feature is called WebLogic Active GridLink for RAC; which is implemented as the GridLink data source within WebLogic Server.

weblogicssrrerew-13

 

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:
 GridLink data sources use runtime connection load balancing to distribute connections to Oracle RAC instances based on Oracle FAN events issued by the database.
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
Refer the following URL to create the Gridlink datasource through WLST script

Creating the Gridlink data source through WLST script

The below WLST script will help as to create a GridLink datasource in weblogic server.

GridLinkDataSource.properties

dbURL=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)HOST=dbhost1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=SERVICENAME)))

connectionpool.test.query=SQL SELECT * FROM DUAL
connectionpool.driver.class=oracle.jdbc.OracleDriver
connectionpool.username=SOA_EAIOWNER
connectionpool.password=orasoa11g
connectionpool.initCapacity=10
connectionpool.maxCapacity=60
datasource.name=EAISOAMetadataSource
datasource.jndi.name=eai/ds/EAISOAMetadataSource
datasource.target=Servers/AdminServer

domain.AdminIP=localhost
domain.AdminPort=8000

domain.AdminPasswd=welcome1

GridLinkDatasourceCreation.py

from java.io import FileInputStream

def createGridLinkJDBCResources(configProps):
edit()
startEdit()
 
server=’AdminServer’
cd(“Servers/”+server)
target=cmo
cd(“../..”)
print ‘=========================================’
print ‘Creating GridLink DataSource….’
print ‘=========================================’
dsTestQuery=configProps.get(“connectionpool.test.query”)
dsDriverName=configProps.get(“connectionpool.driver.class”)

cd(‘/’)
dsURL= configProps.get(“dsURL”)           
dsUserName = configProps.get(“connectionpool.username”)
dsPassword = configProps.get(“connectionpool.password”)
initCapacity = configProps.get(“connectionpool.initCapacity”)
maxCapacity = configProps.get(“connectionpool.maxCapacity”)
dsName = configProps.get(“datasource.name”)
jndiname = configProps.get(“datasource.jndi.name”)
datasourceTargets = configProps.get(“datasource.target”).split(“,”)

print ‘dsUserName’,dsUserName
print ‘dsPassword’,dsPassword
print ‘initCapacity’,initCapacity
print ‘maxCapacity’,maxCapacity
print ‘dsName’,dsName
print ‘jndiname’,jndiname
print ‘datasourceTargets’,datasourceTargets

print ‘Creating DataSource: ‘,dsName,’ ….’
 
myResourceName = dsName   
jdbcSystemResource = create(myResourceName,”JDBCSystemResource”)
myFile = jdbcSystemResource.getDescriptorFileName()
jdbcResource = jdbcSystemResource.getJDBCResource()
jdbcResource.setName(myResourceName)   
 
 

# Create the DataSource Params
dpBean = jdbcResource.getJDBCDataSourceParams()
myName=jndiname
dpBean.setJNDINames([myName]) 
dpBean.setGlobalTransactionsProtocol(‘TwoPhaseCommit’)

# Create the Driver Params
drBean = jdbcResource.getJDBCDriverParams()
drBean.setPassword(dsPassword)
drBean.setUrl(dsURL)
drBean.setDriverName(dsDriverName)

#Create the Oracle params
orapr=jdbcResource.getJDBCOracleParams()
orapr.setFanEnabled(true)
orapr.setOnsNodeList(‘node1:6200,node2:6200’)
propBean = drBean.getProperties()
driverProps = Properties()
driverProps.setProperty(“user”,dsUserName)
e = driverProps.propertyNames()
while e.hasMoreElements() :             
   propName = e.nextElement()             
   myBean = propBean.createProperty(propName)
   myBean.setValue(driverProps.getProperty(propName))   
 
# Create the ConnectionPool Params
ppBean = jdbcResource.getJDBCConnectionPoolParams()
ppBean.setInitialCapacity(int(initCapacity))
ppBean.setMaxCapacity(int(maxCapacity))
ppBean.setTestConnectionsOnReserve(true)
ppBean.setTestTableName(‘SQL SELECT 1 FROM DUAL’)

xaParams = jdbcResource.getJDBCXAParams()
xaParams.setKeepXaConnTillTxComplete(1)   

# Add Target
for datasourceTarget in datasourceTargets:
print ‘DataSourceTargets’,datasourceTargets
print ‘DataSourceTarget’,datasourceTarget
if datasourceTarget==”:
   print ”
else:
   jdbcSystemResource.addTarget(getMBean(datasourceTarget))     
 

print ‘DataSource: ‘,dsName,’, has been created Successfully !!!’
print ‘=========================================’

save()
activate()   

def main():
propInputStream1 = FileInputStream(“GridLinkDataSource.properties”)
configProps = util.Properties()
configProps.load(propInputStream1)

adminURL=’t3://’+configProps.get(‘domain.AdminIP’)+’:’+configProps.get(‘domain.AdminPort’)
adminUserName=’weblogic’
adminPassword=configProps.get(“domain.AdminPasswd”)
connect(adminUserName, adminPassword, adminURL)

createGridLinkJDBCResources(configProps);

print ‘Successfully created JDBC resources for SOACoreDomain’

disconnect()

 
main()

Change the values accordingly in the property file and execute the  $WLSHOME/common/bin/wlst.sh GridLinkDatasourceCreation.py

weblogicssrrerew-14
After the successful execution of the script login to console and verify the Gridlink datasource created.
weblogicssrrerew-15

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>