使用WSAdmin和ANT自动部署websphere6.1

一、WSAdmin介绍
WSAdmin是websphere6.1的管理控制台命令行工具,可以使用它与Websphere application server进行交互,或通过Jacl脚本运行管理命令。工具位于$WAS_HOME/bin目录下。

二、连接部署管理服务器
定位集群的部署管理服务器地址和端口号,我们测试环境的CellManager地址为192.168.20.38,端口为8879。
使用默认的SOAP方式连接。

wsadmin -conntype SOAP -host 192.168.20.38 -port 8879 -user admin -password ******

三、日常维护脚本
1、列出集群节点
$AdminConfig list Node


2、列出集群应用服务器
$AdminConfig list Server


3、列出应用服务
$AdminApp list


4、启动单个服务器
$AdminControl invoke [$AdminControl queryNames type=NodeAgent,node=test-95Node01,*] launchProcess server35


5、停止单个服务器
$AdminControl invoke [$AdminControl queryNames type=Server,node=test-95Node01,name=server35,*] stop


6、安装服务到集群
$AdminApp install e:/hello.war {-cluster b2bpool -contextroot hello -appname hello -usedefaultbindings}
$AdminControl save


7、开启服务
$AdminControl invoke [$AdminControl queryNames type=ApplicationManager,node=test-38Node01,*] startApplication hello

$AdminControl invoke [$AdminControl queryNames type=ApplicationManager,node=test-95Node01,*] startApplication hello
8、停止服务
$AdminControl invoke [$AdminControl queryNames type=ApplicationManager,process=server1,*] stopApplication hello


$AdminControl invoke [$AdminControl queryNames type=ApplicationManager,process=server35,*] stopApplication hello


9、更新服务(war包)到集群
$AdminApp update hello app {-operation update -cluster b2bpool -contextroot hello -contents e:/hello.war}
$AdminControl save


10、更新服务(单个文件)到集群
$AdminApp update hello file {-operation update  -cluster b2bpool -contextroot hello -contents e:/hello.jar -contenturi hello.war/WEB-INF/lib/hello.jar}
$AdminControl save


11、更新服务到节点
$AdminApp update hello app {-operation update -node test-95Node01 -contextroot hello -contents e:/hello.war}
$AdminControl save

四、使用ant自动部署websphere
1、websphere6.1的ws_ant工具在$WAS_HOME/bin下。
   使用的是$WAS_HOME/plugins/com.ibm.ws.runtime_6.1.0.jar中的任务,也可以自定义任务,更新任务com.ibm.websphere.ant.tasks.UpdateApplication就是自定义的。

2、编写builder.xml部署文件
<project name="wasant" basedir="." default="updateAndStart">
 <property name="was.root" value="E:/IBM/WebSphere/AppServer" />
     <property name="wsanttasks.jar" value="${was.root}/plugins/com.ibm.ws.runtime_6.1.0.jar"/>
     <property name="app.name" value="hello"/>
     <property name="ear.file" value="E:/hello.war"/>
 <property name="contextroot" value="hello"/>
 <property name="cluster" value="b2bpool"/>
 <!--登录信息 192.168.20.38 8879-->
     <property name="username" value="admin"/>
        <property name="password" value="******"/>
        <property name="host" value="192.168.20.38"/>
        <property name="port" value="8879"/>
        <property name="conntype" value="SOAP"/>
 <!-- 使用到的任务 -->
    <taskdef name="wsStartServer" classname="com.ibm.websphere.ant.tasks.StartServer" classpath="${wsanttasks.jar}" />
    <taskdef name="wsStopServer" classname="com.ibm.websphere.ant.tasks.StopServer" classpath="${wsanttasks.jar}" />
    <taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication" classpath="${wsanttasks.jar}" />
    <taskdef name="wsUpdateApp" classname="com.ibm.websphere.ant.tasks.UpdateApplication" classpath="${wsanttasks.jar}" />
    <taskdef name="wsUninstallApp" classname="com.ibm.websphere.ant.tasks.UninstallApplication" classpath="${wsanttasks.jar}" />
    <taskdef name="wsStartApp" classname="com.ibm.websphere.ant.tasks.StartApplication" classpath="${wsanttasks.jar}" />
    <taskdef name="wsStopApp" classname="com.ibm.websphere.ant.tasks.StopApplication" classpath="${wsanttasks.jar}" />
    <taskdef name="wsListApps" classname="com.ibm.websphere.ant.tasks.ListApplications" classpath="${wsanttasks.jar}" />
    <taskdef name="wsAdmin" classname="com.ibm.websphere.ant.tasks.WsAdmin" classpath="${wsanttasks.jar}" />
 <!-- 更新应用-->
 <target name="wsUpdateApp" description="Update Application ${app.name}">
         <wsUpdateApp user="${username}" password="${password}" host="${host}"
             ear="${ear.file}" appname="${app.name}" port="${port}" conntype="${conntype}" washome="${was.root}"
             options="-operation update -cluster ${cluster} -contextroot ${contextroot} -contents ${ear.file}">
         </wsUpdateApp>
 </target>

 <!-- 实际的任务组合    -->
 <target name="updateAndStart" description="Update and Save ${app.name}">
  <antcall target="wsUpdateApp"/>
 </target>
</project>

3、编写shell定时运行ant实现部署

 

原文地址:http://blog.csdn.net/andyxm/archive/2010/10/28/5971894.aspx

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值