Wednesday, April 23, 2014

WLST script to create Gridlink data source in weblogic

WLST script to create Gridlink data source in weblogic

This tutorial explains the approach to create Gridlink data source through WLST script in weblogic

Refer the below URL for details on Gridlink data source

https://www.albinsblog.com/2014/04/different-approaches-for-connecting.html


WLST Script


The below WLST script creates the Gridlink datasource with enabled configurations

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=7201

domain.AdminPasswd=Albin123!

GridLinkDatasourceCreation.py

from java.io import FileInputStreamdef 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('/')
   dbURL= configProps.get("dbURL")           
   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',datasourceTargetsprint '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(dbURL)     
   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()

Script

https://github.com/techforum-repo/youttubedata/tree/master/scripts/wlst/GridLinkDatasourceCreation

Before executing the script, change the configurations as required.Change the ONS node details in the script.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd GridLinkDatasourceCreation.py



After the successful execution of the script login to console and verify the Gridlink datasource created.




Monday, April 21, 2014

Enable the ClusterConstraints in weblogic server - Oracle SOA Suite 11g

Enable the ClusterConstraints in weblogic server - Oracle SOA Suite 11g :

It is possible to change WebLogic Server’s default deployment behavior for clusters by setting the ClusterConstraintsEnabled option when starting the WebLogic Server domain. The ClusterConstraintsEnabled option enforces strict deployment for all servers configured in a cluster. A deployment to a cluster succeeds only if all members of the cluster are reachable and all can deploy the specified files.

This post will explain the different approaches to change Cluster Constraint.

Through EM console:

Login to EM console 
Right click on soa-infra-->Admiistration-->System MBean browser
Enter com.bea:Name=SOACoreDomain,Type=Domain in the MBean browser filter and click ok


Change the ClusterConstraintEnabled attribute accordingly and click on Apply button




Friday, April 18, 2014

Configuring the Shared FileStore for TLOGS in Weblogic Servers through WLST Script

Configuring the Shared FileStore for TLOGS in Weblogic Servers through WLST Script


WebLogic Server maintains transaction logs (referred to as tlog files). The server uses the transaction logs to track all current transactions. WebLogic Server only records information about uncommitted transactions in the transaction log. When a server restarts after a failure, it uses the information in the transaction log to recover transactions.

By default, weblogic uses FileStore and the default location of a WebLogic server’s file-store containing the TLOG is at:

<<DOMAIn_HOME>>/servers/<<SERVER_NAME>>/data/store/default/_WLS_<<SERVER_NAME>>000000.DAT

For High Availability, this TLog (Transaction Log) directory must be on shared file system (or in Database) so that after failover new WebLogic Server can pick transactions not yet completed. The JDBC Persistent store can also be used to store the TLOGS for High availability setup.

This tutorial explains the approach to configure shared FileStore for TLOGS to the weblogic servers in a domain through WLST script

WLST Script


The below script will help us to set the shared location to the tlogs for the weblogic servers in a domain.

ConfigureTLOGSSharedFileStore.py

import sys


Script

https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/ConfigureTLOGSSharedFileStore.py


Before executing the script, change the configurations as required.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd ConfigureTLOGSSharedFileStore.py




Now the servers are configured with shared file store for TLOGS









Thursday, April 17, 2014

WLST script to migrate default File Stores to JDBC store in weblogic servers

WLST script to migrate default File Stores to JDBC store in weblogic servers

The persistent store provides a built-in, high-performance storage solution for WebLogic Server subsystems and services that require persistence. For example, it can store persistent JMS messages or temporarily store messages sent using the Store-and-Forward feature. The persistent store supports persistence to a file-based store or to a JDBC-enabled database.
By default, File store is used as a persistence store for weblogic servers
File stores are generally easier to configure and administer, and do not require that WebLogic subsystems depend on any external component.
File stores generate no network traffic; whereas, JDBC stores will generate network traffic if the database is on a different machine from WebLogic Server.
JDBC stores may make it easier to handle failure recovery since the JDBC interface can access the database from any machine on the same network. With the file store, the disk must be shared or migrated.
This tutorial explains the approach to migrate the default JMS file store to a DB store through WLST script.

Data Source

As a first step, create a schema in target database(beloSQL for Oracle database)
alter session set “_ORACLE_SCRIPT”=true;
create user JDBC_STORE_USER
identified by “jdbcstoreuser”
temporary tablespace temp
default tablespace users;
grant connect to JDBC_STORE_USER;
grant resource to JDBC_STORE_USER;
grant create session to JDBC_STORE_USER;
ALTER USER JDBC_STORE_USER quota unlimited on USERS;
Create a data source with name “JDBCStoreDataSource” to connect to the database
weblogic-migrate-file-store-to-jdbc-store
A JDBC store must use a JDBC data source that uses a non-XA JDBC driver and has Supports Global Transactions disabled.
weblogic-migrate-file-store-to-jdbc-store
weblogic-migrate-file-store-to-jdbc-store
weblogic-migrate-file-store-to-jdbc-store.png
Test the configurations and ensure the test connection successful
weblogic-migrate-file-store-to-jdbc-store
Target the data source to all the servers in the domain so the same data source can be used by all the servers to manage the JDBC stores(For demo i am targeting only to Admin Server)
Now the data source is ready and can be used for JDBC store configurations

WLST Script

The below wlst script migrate the existing File Store to JDBC Persistence store — my case the server is enabled with one persistence store(BAMMonitoringJMSFileStore) for JMS Server(BAMMonitoringServer) and targeted only to Admin Server so the script migrate the JMS store to JDBC store and target to Admin Server, modify the script based on the number of existing File store configuration
weblogic-migrate-file-store-to-jdbc-store
weblogic-migrate-file-store-to-jdbc-store.

MigrateFileStoreToJDBSStore.py

import sysprint "@@@ Starting the script ..."from java.util import *
from javax.management import *#The directory of the domain configuration
#/app/oracle/products/11g/admin/domains
wlsDomain='C://Albin/SW/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain'
print "WLSDOMAIN="+wlsDomainadminURL='t3://localhost:7001'
adminUserName='weblogic'
adminPassword='weblogic1'
connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
############# JDBC stores for STANDALONE ADMINSERVER ## Enable and target unique JDBC Store for all the servers in the domain
cd('/')
cmo.createJDBCStore('BAMMonitoringJMSJDBCStore')
cd('/JDBCStores/BAMMonitoringJMSJDBCStore')
cmo.setDataSource(getMBean('/SystemResources/JDBCStoreDataSource'))
cmo.setPrefixName('bammonitoring')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))#### Add 
#### end of creating jdbc stores############Set Persistent Stores for the sub systems e.g JMS Serverscd('/JMSServers/BAMMonitoringServer')
cmo.setPersistentStore(getMBean('/JDBCStores/BAMMonitoringJMSJDBCStore'))#################DESTROY ALL THE EXISTING FILE STOREScd('/')
cmo.destroyFileStore(getMBean('/FileStores/BAMMonitoringJMSFileStore'))
 
save()
activate()
Script

techforum-repo/youttubedata

Contribute to techforum-repo/youttubedata development by creating an account on GitHub.

github.com


Before executing the script, change the configurations as required.
Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd MigrateFileStoreToJDBSStore.py
weblogic-migrate-file-store-to-jdbc-store
The existing file store is deleted after enabling the JDBC store for the modules.
weblogic-migrate-file-store-to-jdbc-store
weblogic-migrate-file-store-to-jdbc-store
For clustered environment the same should be executed for all the servers in the cluster with unique JDBC store name(e.g BAMMonitoringJMSJDBCStore for server 1 and BAMMonitoringJMSJDBCStore2 for server 2).
Restart the servers, the required tables({PrefixName}WLStore) — BAMMonitoringWLStore will be created.
The config.xml file will be enabled with required JDBC store configurations as below.
weblogic-migrate-file-store-to-jdbc-store
The table with name “BAMMONITORINGWLSTORE” created in database
select object_name as table_name from user_objects where object_type = ‘TABLE’ order by object_name;
weblogic-migrate-file-store-to-jdbc-store
The required data now stored into the JDBC store
weblogic-migrate-file-store-to-jdbc-store
This concludes the migration of existing Default File Store to JDBC store. The File Store and JDBC store has its own merits and demerits, the stores should be selected based on the uses cases — File Store provides better performance but JDBC store provides better recovery support.




WLST script to update Graceful Shutdown parameters in weblogic server

WLST script to update Graceful Shutdown parameters in weblogic server


A graceful shutdown gives WebLogic Server subsystems time to complete certain application processing currently in progress.

Graceful Shutdown


The Graceful Shutdown command transitions a server instance from the RUNNING state to the SHUTDOWN state, allowing work in process to be handled gracefully, with this sequence of state transitions:

RUNNING > SUSPENDING > ADMIN > SHUTTING_DOWN > SHUTDOWN

Controlling Graceful Shutdown


Ignore Sessions During Shutdown — If you enable this option WebLogic Server will drop all HTTP sessions immediately, rather than waiting for them to complete or timeout. Waiting for abandoned sessions to timeout can significantly lengthen the graceful shutdown process, because the default session timeout is one hour.

Graceful Shutdown Timeout — Specifies a time limit for a server instance to complete a graceful shutdown. If you supply a timeout value, and the server instance does not complete a graceful shutdown within that period, WebLogic Server performs a forced shutdown on the server instance.

This tutorial explains the approach to update graceful update parameters through WLST script in weblogic

WLST Script


The script will help us to update the Graceful Shutdown parameter for the servers in the weblogic domain.

UpdateGracefulShutdownParameters.py


Script

https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/UpdateGracefulShutdownParameters.py

Before executing the script, change the configurations as required.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd UpdateGracefulShutdownParameters.py

Now the Graceful Shutdown Parameters updated for all the servers in the domain