1.WebSphere控制台停止
停止WebSphere应用程序可以通过账号密码登录到WebSphere控制台,
可以依次点开应用程序-->应用程序类型-->WebSphereq企业应用程序-->可以看到部署在服务器上的企业应用程序,
页面中有操作按钮,此时可以对应用程序启动停止,卸载更新等操作;
同时在最右侧有帮助页面-->命令辅助的下方-->查看上一个操作的脚本编制命令,点击查看,就能查看到相关的命令,
我们就是使用这些查看到相关的命令进行shell脚本的编写;
2.shell脚本停止/启动应用程序
停止脚本如下:
#!/bin/bash #判断执行用户,为was用户 if [ $(whoami) != was ] then echo "execute user must be [was]!" exit 2 fi echo "====wasStopApp.sh===" #was用户 wasUser=admin #was密码 wasPasswd='Test@1234' #was家目录 wasHome='/was/IBM/WebSphere/AppServer/profiles' #单机或集群部署 profilesNames=`ls ${wasHome}/grep -Ei 'Custom|AppSrv'` #was命令路径 wasPath="${wasHome}/${profilesNames}" #获取was节点的相关参数 cd $wasPath/bin clusterserver=`sh serverStatus.sh -all -username $wasUser -password $wasPasswd 2>/dev/null | grep 'Application Server' | grep 'STARTED' | head -n 1 | awk -F ' " ' '{print $2}' | awk -F ' " ' '{print $1}'` process=$clusterserver platform=proxy node=`ps -ef | grep was | grep java | grep $process | awk '{print $(NF-1)}'` version='9.0.5.5' cell=`ps -ef | grep was | grep java | grep $process | awk '{print $(NF-2)}'` #停止单个应用程序 sh wsadmin.sh -user $wasUser -password $wasPasswd -c "AdminControl.invoke('WebSphere:name=ApplicationManager,process=$process,platform=$platform,node=$node,version=$version,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=$cell,spec=1.0','stopApplication','[DefaultApplication]')"
启动脚本如下:
#!/bin/bash #判断执行用户,为was用户 if [ $(whoami) != was ] then echo "execute user must be [was]!" exit 2 fi echo "====wasStopApp.sh===" #was用户 wasUser=admin #was密码 wasPasswd='Test@1234' #was家目录 wasHome='/was/IBM/WebSphere/AppServer/profiles' #单机或集群部署 profilesNames=`ls ${wasHome}/grep -Ei 'Custom|AppSrv'` #was命令路径 wasPath="${wasHome}/${profilesNames}" #获取was节点的相关参数 cd $wasPath/bin clusterserver=`sh serverStatus.sh -all -username $wasUser -password $wasPasswd 2>/dev/null | grep 'Application Server' | grep 'STARTED' | head -n 1 | awk -F ' " ' '{print $2}' | awk -F ' " ' '{print $1}'` process=$clusterserver platform=proxy node=`ps -ef | grep was | grep java | grep $process | awk '{print $(NF-1)}'` version='9.0.5.5' cell=`ps -ef | grep was | grep java | grep $process | awk '{print $(NF-2)}'` #停止单个应用程序 sh wsadmin.sh -user $wasUser -password $wasPasswd -c "AdminControl.invoke('WebSphere:name=ApplicationManager,process=$process,platform=$platform,node=$node,version=$version,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=$cell,spec=1.0','startApplication','[DefaultApplication]')"