且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在命令行上挂起weblogic数据源

更新时间:2023-09-22 11:16:10

您可以使用WLST脚本来完成。从命令行运行$ BEA_HOME / wlserver10.0 / common / bin / wlst.sh(Windows上的.cmd):
连接到正在运行的服务器。使用托管服务器端口,因为这是服务器运行时属性:

  wls:/ offline> connect('weblogic','weblogic','t3:// localhost:7002')



到服务器运行时树:
wls:/ mydomain / serverConfig> serverRuntime()



导航到JDBCService,管理服务器名称,JDBCDataSource运行时到您的数据源名称:
  wls:/ mydomain / serverRuntime> cd('JDBCServiceRuntime / managedsrv1 / JDBCDataSourceRuntimeMBeans / MyDS')

然后暂停并恢复: p>

  wls:/ mydomain / serverRuntime / JDBCServiceRuntime / managedsrv1 / JDBCDataSourceRuntimeMBeans / MyDS> cmo.suspend()
wls:/ mydomain / serverRuntime / JDBCServiceRuntime / managedsrv1 / JDBCDataSourceRuntimeMBeans / MyDS> cmo.resume()

使用命令ls()查看其他变量和操作。 p>

I was Wondering if there is anyway of suspending / resuming weblogic 10 jdbc datasources via the command line. I am aware that i can do this in the admin console, but because our app has many different datasources it is a bit of a pain.

The reason behind this is that our testers are doing error flow tests and have to simulate the db going down. Ideally i would like to give then a bat file for suspending all datasources and another one for resuming all datasources.

Any ideas?

Thanks

You can use the WLST scripting to do that. From the command line, run $BEA_HOME/wlserver10.0/common/bin/wlst.sh (.cmd on Windows): Connect to the running server. Use the managed server port as this is a server runtime property:

wls:/offline> connect('weblogic','weblogic','t3://localhost:7002')

Go to the serverRuntime tree: wls:/mydomain/serverConfig> serverRuntime()

Navigate to the JDBCService, to your managed server name, the JDBCDataSource Runtime and finally to your datasource name:

wls:/mydomain/serverRuntime> cd('JDBCServiceRuntime/managedsrv1/JDBCDataSourceRuntimeMBeans/MyDS')

Then just suspend and resume it:

wls:/mydomain/serverRuntime/JDBCServiceRuntime/managedsrv1/JDBCDataSourceRuntimeMBeans/MyDS> cmo.suspend()
wls:/mydomain/serverRuntime/JDBCServiceRuntime/managedsrv1/JDBCDataSourceRuntimeMBeans/MyDS> cmo.resume()

use command ls() to see the the other variables and operations.