X

Proactive insights, news and tips from Oracle Fusion Middleware Support. Learn Oracle from Oracle.

Migrating from Multi Data Source to Active GridLink - Take 2

Stephen Felts
Manager

In the original blog article on this topic at this link, I proposed that you delete the multi data source (MDS) and create a replacement Active GridLink (AGL) data source.  In the real world, the multi data source is likely referenced by another objects like a JDBC store and deleting the MDS will create an invalid configuration.  Further, those objects using connections from the MDS will fail during and after this re-configuration.  That implies that for this type of operation the related server needs to be shut down, the configuration updated with offline WLST, and the server restarted.  The administration console cannot be used for this type of migratoin.  Except for the section that describes using the console, the other information in the earlier blog article still aplies to this process.  No changes should be required in the application, only in the configuration, because we preserve the JNDI name.

The following is a sample of what the offline WLST script might look like.  You could parameterize it and make it more flexible in handling multiple datasources.

# java weblogic.WLST file.py
import sys, socket, os

# Application values
dsName='myds'
memberds1='ds1'
memberds2='ds2'
domain='/domaindir
onsNodeList=host1:6200,host2:6200'
url='jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=' \
 + '(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))' \
 + '(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521)))' \
 + '(CONNECT_DATA=(SERVICE_NAME=servicename)))'
user='user1'
password='password1'

readDomain(domain)

# change type from MDS to AGL
# The following is for WLS 12.1.2 and 12.1.3 if not setting
# FanEnabled true, which is not recommended
# set('ActiveGridlink','true')
# The following is for WLS 12.2.1 and later
#cd('/JDBCSystemResources/' + dsName + '/JdbcResource/' + dsName )
#set('DatasourceType', 'AGL')

# set the AGL parameters
cd('/JDBCSystemResources/' + dsName + '/JdbcResource/'
+ dsName)
create('myJdbcOracleParams','JDBCOracleParams')
cd('JDBCOracleParams/NO_NAME_0')
set('FanEnabled','true')
set('OnsNodeList',onsNodeList)

# Set the data source parameters
cd('/JDBCSystemResources/' + dsName + '/JdbcResource/'
+ dsName + '/JDBCDataSourceParams/NO_NAME_0')
set('GlobalTransactionsProtocol','None')
unSet('DataSourceList')
unSet('AlgorithmType')

# Set the driver parameters
cd('/JDBCSystemResources/' + dsName + '/JdbcResource/'
+ dsName)
create('myJdbcDriverParams','JDBCDriverParams')
cd('JDBCDriverParams/NO_NAME_0')
set('Url',url)
set('DriverName','oracle.jdbc.OracleDriver')
set('PasswordEncrypted',password)
create('myProps','Properties')
cd('Properties/NO_NAME_0')
create('user', 'Property')
cd('Property')
cd('user')
set('Value', user)

# Set the connection pool parameters
cd('/JDBCSystemResources/' + dsName + '/JdbcResource/'
+ dsName)
create('myJdbcConnectionPoolParams','JDBCConnectionPoolParams')
cd('/JDBCSystemResources/' + dsName + '/JdbcResource/'
+ dsName + '/JDBCConnectionPoolParams/NO_NAME_0')
set('TestTableName','SQL ISVALID')

# remove member data sources if they are not needed
cd('/')
delete(memberds1, 'JDBCSystemResource')
delete(memberds2, 'JDBCSystemResource')

updateDomain()
closeDomain()
exit()

 

In WLS 12.1.2 and 12.1.3, there is an explicit ActiveGridlink flag that can be used to identify an AGL datasource, even if FanEnabled is not set to true (which is not recommended) and auto-ONS is used (12.1.2 is the first release in which auto-ONS is supported). In the script above, uncomment the line to set it only if FanEnabled and OnsNodeList are not set.

Starting in WLS 12.2.1, there is an explicit datasource type at the JDBCResource level. If that is set to GENERIC, you must re-set it using set("DatasourceType",
"AGL"). In the script above, uncomment the lines to set it.  In this case, the ActiveGridlink flag is not necessary.

If you are using an Oracle wallet for ONS, that needs to be added to the JDBCOracleParams object as well.  Prior to WLS 12.2.1, the ONS information needs to be explicitly specified.  In WLS 12.2.1 and later, the ONS information can be excluded and the database will try to determine the correct information.  For more complex ONS topologies, the configuration can be specified using the format described in http://docs.oracle.com/middleware/1221/wls/JDBCA/gridlink_datasources.htm#BABGJBIC.  

Note: the unSet() method was not added to offline WLST until WLS 12.2.1.2.0.  There is a related patch to add this feature to WLS 12.1.3 at Patch 25695948.  For earlier releases, one option is to edit the MDS descriptor file and delete the lines for "data-source-list" and "algorithm-type" and commend out the "unSet()" calls before running the offline WLST script.  Another option is to run the following online WLST script, which does support the unSet() method.  However, the server will need to be restarted after the update and before the member datasources can be deleted.

# java weblogic.WLST file.py
import sys, socket, os

# Application values
dsName='myds'
memberds1='ds1'
memberds2='ds2'
onsNodeList=host1:6200,host2:6200'
url='jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=' \
 + '(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))' \
 + '(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521)))' \
 + '(CONNECT_DATA=(SERVICE_NAME=otrade)))'
user='user1'
password='password1'
hostname='localhost'
admin='weblogic'
adminpw='welcome1'

connect(admin,adminpw,"t3://"+hostname+":7001")
edit()

startEdit()

# change type from MDS to AGL
# The following is for WLS 12.1.2 and 12.1.3 if not setting
# FanEnabled to  true.  It is recommended to always set FanEnabled to true.
# cd('/JDBCSystemResources/' + dsName)
# set('ActiveGridlink','true')
# The following is for WLS 12.2.1 and later
# cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName )
# set('DatasourceType', 'AGL')

# set the AGL parameters
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/'
+ dsName + '/JDBCOracleParams/' + dsName)
set('FanEnabled','true')
set('OnsNodeList',onsNodeList)

# Set the data source parameters
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/'
+ dsName + '/JDBCDataSourceParams/' + dsName)
set('GlobalTransactionsProtocol','None')
cmo.unSet('DataSourceList')
cmo.unSet('AlgorithmType')

# Set the driver parameters
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/'
+ dsName + '/JDBCDriverParams/' + dsName)
set('Url',url)
set('DriverName','oracle.jdbc.OracleDriver')
set('PasswordEncrypted',password)
cd('Properties/' + dsName)
userprop=cmo.createProperty('user')
userprop.setValue(user)

# Set the connection pool parameters
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/'
+ dsName + '/JDBCConnectionPoolParams/' + dsName)
set('TestTableName','SQL PINGDATABASE')

# cannot remove member data sources until server restarted
#cd('/')
#delete(memberds1, 'JDBCSystemResource')
#delete(memberds2, 'JDBCSystemResource')

save()
activate()
exit()

A customer was having problems setting multiple targets in a WLST script.  It's not limited to this topic but here's how it is done.

targetlist = []
targetlist.append(ObjectName('com.bea:Name=myserver1,Type=Server'))
targetlist.append(ObjectName('com.bea:Name=myserver2,Type=Server'))

targets = array(targetlist, ObjectName)
cd('/JDBCSystemResources/' + dsName)
set('Targets',targets)

 

 

 

 

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services