【问题标题】:IBM WebSphere: How to map an application to multiple clusters using wsadmin scripting?IBM WebSphere:如何使用 wsadmin 脚本将应用程序映射到多个集群?
【发布时间】:2019-10-23 02:16:31
【问题描述】:

我正在尝试使用 wsadmin 脚本自动部署应用程序,该应用程序映射到一个单元中的两个集群。但无论我怎么尝试,应用程序都只映射到一个集群。结果,应用程序根本没有启动。

我收到以下错误消息:

Application helloteam_07062019_1956 is not deployed on the cluster SPPAbcd
Exception: exceptions.AttributeError WASL6048E: The helloteam_07062019_1956 application is not deployed on the SPPAbcd target.  
WASX7017E: Exception received while running file "/app/was_scripts/main_scripts/deploy_mutlitest.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 175, in ?
  File "/app/service/IBM/WebSphere/AppServer/scriptLibraries/application/V70/AdminApplication.py", line 4665, in startApplicationOnCluster
ScriptLibraryException: : 'exceptions.AttributeError WASL6048E: The helloteam_07062019_1956 application is not deployed on the SPPAbcd target. '

从报错信息中可以看出app只映射到SRVApp集群,而没有映射到SPPAbcd集群。结果,它无法启动应用程序。

这是脚本

targetServerOne = "WebSphere:cell=DIGIAPP1Cell02,cluster=SPPAbcd"
targetServerTwo = "WebSphere:cell=DIGIAPP1Cell02,cluster=SRVApp"

AdminApp.install(location, ['-appname',"hellotest",'-defaultbinding.virtual.host',virtualHost,'-usedefaultbindings','-contextroot',ctxRoot,'-MapModulesToServers',[["EchoApp",URI,targetServerOne],["EchoApp",URI,targetServerTwo]]])
AdminConfig.save()

cell=AdminConfig.list('Cell')
cellName=AdminConfig.showAttribute(cell, 'name')
clusters=AdminConfig.list('ServerCluster').split('\n')
print("The clusters in "+cellName+" are...")
print(clusters)

for name in startClusters:
    startapp = AdminApplication.startApplicationOnCluster(newWar, name)
    print(startapp)

如前所述,无论我尝试什么,应用程序都只会映射到 SRVApp 集群(在 DMGR 控制台中检查应用程序的管理模块部分之后)。它没有映射到 SPPAbcd 集群。

如何实现正确的模块映射到多集群? adminapp.install 命令中提到了模块映射部分。这是映射模块的正确方法吗?

提前致谢和问候。

-克里斯

【问题讨论】:

  • 我会做一个循环并调用 install 两次。不是说不可能,只是一个建议。我从来不需要在同一个单元内的两个集群中部署同一个应用程序。
  • @Nic3500 我已经解决了这个问题。请在下面查看我的答案:)

标签: python websphere jython websphere-8 wsadmin


【解决方案1】:

为了解决这个问题,我利用 Jenkins 的 EnvInject 插件在构建时注入属性。

我没有使用两个目标服务器(targetServerOne 和 targetServerTwo),而是只使用了目标服务器,并从属性文件中调用了它。

这是我的属性文件:

moduleMapping=WebSphere:cell=cell1,cluster=cluster1+WebSphere:cell=cell1,cluster=cluster2

我的脚本已修改如下:

from os import getenv as env

targetServer = env(‘moduleMapping’)

AdminApp.install(filename, [ ‘-MapModulesToServers, [[‘moduleName’, ‘uri’, targetServer]]])

这已将我的应用映射到一个单元格内的两个集群。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多