我想使用ant脚本启动远程weblogic服务器。 我创建了停止和启动weblogic服务器的ant脚本,对于本地weblogic服务器停止并开始工作很好但是当我尝试使用相同的ant脚本用于远程weblogic服务器时,它可以用于停止但是为了启动它运行,而不是抛出任何错误
<project name="Svn" default="startserver">
<property name="wldeploy.source" value="napf-main/napf-build/release/target/Release/dist/nfapp.ear" />
<property name="basedir" location="C:/Jenkinserver/workspace/NAPF_PRO/NAPF_SERVER_SOURCE"/>
<property name="ant.home" location="D:/tools/apache-ant-1.10.1"/>
<property name="wls.home" value="C:/Oracle/Middleware/Oracle_Home/wlserver"/>
<property name="wldeploy.admin.protocol" value="t3"/>
<property name="wldeploy.admin.host" value="10.254.6.206"/>
<property name="wldeploy.admin.port" value="7001"/>
<property name="wldeploy.user" value="weblogic" />
<property name="wldeploy.password" value="weblogic12.2.1" />
<property name="admin.server.name" value="AdminServer" />
<property name="wl.domain.name" value="NAPF_domain" />
<property name="wldeploy.verbose" value="true"/>
<property name="wldeploy.debug" value="false"/>
<property name="wldeploy.targets" value="AdminServer"/>
<property name="wldeploy.nonExclLock" value="true"/>
<property name="wldeploy.upload" value="true"/>
<property name="wldeploy.remote" value="true"/>
<target name="deploy">
<echo message="basedir: ${basedir}"/>
<echo message="ant.home: ${ant.home}"/>
<echo message="wls.home: ${wls.home}"/>
<property name="wldeploy.admin.url"
value="${wldeploy.admin.protocol}://${wldeploy.admin.host}:${wldeploy.admin.port}/"/>
<property name="wldeploy.classpath" value="${wls.home}/modules/features/wlst.wls.classpath.jar"/>
<!-- windows -->
<exec dir="${basedir}" executable="cmd" osfamily="windows">
<env key="CLASSPATH" value="${wldeploy.classpath}"/>
<env key="ANT_HOME" value="${ant.home}"/>
<arg value="/c"/>
<arg value="${ant.home}/bin/ant"/>
<arg value="-Dwldeploy.verbose=${wldeploy.verbose}"/>
<arg value="-Dwldeploy.debug=${wldeploy.debug}"/>
<arg value="-Dwldeploy.nonExclLock=${wldeploy.nonExclLock}"/>
<arg value="-Dwldeploy.upload=${wldeploy.upload}"/>
<!-- <arg value="-Dwldeploy.appName=${wldeploy.appName}"/> -->
<arg value="-Dwldeploy.source=${wldeploy.source}"/>
<!-- <arg value="-Dwldeploy.plan=${wldeploy.plan}"/> -->
<arg value="-Dwldeploy.user=${wldeploy.user}"/>
<arg value="-Dwldeploy.password=${wldeploy.password}"/>
<arg value="-Dwldeploy.admin.url=${wldeploy.admin.url}"/>
<arg value="-Dwldeploy.targets=${wldeploy.targets}"/>
<arg value="-Dwldeploy.admin.host=${wldeploy.admin.host}"/>
<arg value="-Dwldeploy.admin.port=${wldeploy.admin.port}"/>
<!-- target -->
<arg value="stop-server"/>
<arg value="start-server"/>
<!--<arg value="wldeploy"/> -->
</exec>
</target>
<target name="stop-server" description="stop to a WebLogic domain">
<taskdef name="wlserver" classname="weblogic.ant.taskdefs.management.WLServer"/>
<wlserver adminserverurl="${wldeploy.admin.url}" username="${wldeploy.user}" password="${wldeploy.password}" servername="${admin.server.name}" action="shutdown" noexit="true" host="${wldeploy.admin.host}" port="${wldeploy.admin.port}"/>
<sleep seconds="2" />
</target>
<target name="start-server">
<wlserver dir="C:/Oracle/Middleware/Oracle_Home/user_projects/domains/NAPF_domain" host="${wldeploy.admin.host}" port="${wldeploy.admin.port}" domainname="${wl.domain.name}" servername="${admin.server.name}" action="start" username="${wldeploy.user}" password="${wldeploy.password}" weblogichome="${wls.home}" verbose="true" noexit="true" protocol="${wldeploy.admin.protocol}">
</wlserver>
</target>
<target name="wldeploy" description="Deploy to a WebLogic domain">
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy"/>
<wldeploy action="deploy" verbose="${wldeploy.verbose}" debug="${wldeploy.debug}"
source="${wldeploy.source}" user="${wldeploy.user}" password="${wldeploy.password}"
adminurl="${wldeploy.admin.url}" targets="${wldeploy.targets}" usenonexclusivelock="${wldeploy.nonExclLock}" upload="${wldeploy.upload}" remote="${wldeploy.remote}"/>
</target>
请建议。
答案 0 :(得分:1)
我已使用节点管理器使用WLST脚本启动了远程weblogic服务器。 启动远程weblogic服务器时要考虑的几点。
1.执行wlst start命令时需要运行本地weblogic服务器。
2.远程weblogic服务器的节点管理员需要处于运行模式。
3.domains.properties包含远程weblogic服务器和节点的设置。
详情请参阅:
<强> http://100bytes.com/tutorials/weblogic/weblogic-server-start-stop-operations 强> 的 http://weblogic-tips.com/2012/02/17/starting-the-administration-server-using-node-manager-and-wlst-2/ 强>
<强>的build.xml 强>
<project name="ws">
<property name="oracle.home" value="C:/Oracle/Middleware/Oracle_Home" />
<property name="wl.home" value="C:/Oracle/Middleware/Oracle_Home/wlserver" />
<path id="wl.classpath">
<fileset dir="${wl.home}/server/lib">
<include name="*.jar"/>
</fileset>
</path>
<taskdef name="wlst" classpathref="wl.classpath" classname="weblogic.ant.taskdefs.management.WLSTTask" />
<target name="Shutdown-server" >
<echo message="WebLogic Home is : ${wl.home}" />
<wlst debug="true" executescriptbeforefile="false" filename="wlstscript/StopAdminServer.py" failonerror="false" classpathref="wl.classpath">
</wlst>
</target>
<target name="Start-server" >
<echo message="WebLogic Home is : ${wl.home}" />
<wlst debug="true" executescriptbeforefile="true" failonerror="false" filename="wlstscript/StartAdminServer.py" classpathref="wl.classpath">
</wlst>
</target>
</project>
<强> domains.properties 强>
node.username=weblogic
node.password=weblogic123
node.host=10.254.5.186
node.port=5556
node.type=plain
server.name=AdminServer
server.url=t3://10.254.5.186:7001
server.user=weblogic
server.password=weblogic12.2.1
domain.name=NAPF_domain
domain.dir=C:/Oracle/Middleware/Oracle_Home/user_projects/domains/NAPF_domain
<强> StopAdminServer.py 强>
#############################################################################
#
# This Script is used to stop the admin server using WLST script.
#
#############################################################################
from java.io import FileInputStream
import java.lang
import os
import string
propInputStream = FileInputStream("wlstscript/domains.properties")
configProps = Properties()
configProps.load(propInputStream)
Username = configProps.get("server.user")
Password = configProps.get("server.password")
serverUrl = configProps.get("server.url")
serverName= configProps.get("server.name")
connect(Username,Password,serverUrl)
print ''
print '============================================='
print 'Connected to Admin Server Successfully...!!!'
print '============================================='
print ''
shutdown(serverName,'Server','false',1000, block='false')
print ''
print '============================================='
print ' ShutDown Admin Server Successfully...!!!'
print '============================================='
print ''
<强> StartAdminServer.py 强>
#############################################################################
#
# This Script is used to start the admin server using node manager.
#
#############################################################################
from java.io import FileInputStream
import java.lang
import os
import string
propInputStream = FileInputStream("wlstscript/domains.properties")
configProps = Properties()
configProps.load(propInputStream)
Username = configProps.get("node.username")
Password = configProps.get("node.password")
Host = configProps.get("node.host")
nmPort = configProps.get("node.port")
domainName = configProps.get("domain.name")
domainDir = configProps.get("domain.dir")
nmType = configProps.get("node.type")
nmConnect(Username,Password,Host,nmPort,domainName,domainDir,nmType)
print ''
print '============================================='
print 'Connected to NODE MANAGER Successfully...!!!'
print '============================================='
print ''
serverName = configProps.get("server.name")
print '###### serverName = ', serverName
nmStart(serverName)
serverName = configProps.get("server.name")
print ''
print '============================================='
print '===> Successfully started ', serverName, ' <==='
print '============================================='
print ''
nmDisconnect()