高效的WebSphere应用程序服务器管理脚本

安装IBM WebSphere Application Server(WAS)时,包含了125个以上的shell脚本文件。

并非所有脚本都有用,如果你是一个初学者,可能不知道一些强大的脚本在日常工作中的使用。

我列出了一些最有用的脚本,以方便WebSphere管理员的生活。

以下脚本在IBM WAS ND 8.5.5环境中经过测试,没有任何理由它不能在其他环境中运行。

停止和启动部署管理器、节点代理和JVM

stopManager.sh

您可以使用上述命令停止部署管理器。

[root@localhost bin]# ./stopManager.sh
ADMU0116I: 工具信息被记录在文件中
           /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/stopServer.log
ADMU0128I: 使用Dmgr01配置文件启动工具
ADMU3100I: 读取服务器配置:dmgr
ADMU3201I: 发出停止服务器请求。等待停止状态。
ADMU4000I: 服务器dmgr停止完成。
[root@localhost bin]#

注意:这必须在DMGR配置文件路径中执行。

startManager.sh

您可以使用上述命令启动部署管理器。

[root@localhost bin]# ./startManager.sh
ADMU0116I: 工具信息被记录在文件中
           /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/startServer.log
ADMU0128I: 使用Dmgr01配置文件启动工具
ADMU3100I: 读取服务器配置:dmgr
ADMU3200I: 服务器已启动。等待初始化状态。
ADMU3000I: 服务器dmgr已打开,用于电子商务;进程ID为9183
[root@localhost bin]#

注意:这必须在DMGR配置文件路径中执行。

startServer.sh

要启动JVM,您可以使用startServer.sh并指定服务器名称。

[root@localhost bin]# ./startServer.sh server1
ADMU0116I: 工具信息被记录在文件中
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/startServer.log
ADMU0128I: 使用AppSrv01配置文件启动工具
ADMU3100I: 读取服务器配置:server1
ADMU3200I: 服务器已启动。等待初始化状态。
ADMU3000I: 服务器server1已打开,用于电子商务;进程ID为10633
[root@localhost bin]#

注意:在启动JVM之前必须先启动节点代理。

stopServer.sh

您可以通过执行上述命令关闭JVM并指定JVM名称。

[root@localhost bin]# ./stopServer.sh server1
ADMU0116I: 工具信息被记录在文件中
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/stopServer.log
ADMU0128I: 使用AppSrv01配置文件启动工具
ADMU3100I: 读取服务器配置:server1
ADMU3201I: 发出停止服务器请求。等待停止状态。
ADMU4000I: 服务器server1停止完成。
[root@localhost bin]#

stopNode.sh

要停止相应的节点代理,您必须进入该配置文件并执行stopNode.sh停止节点代理。

[root@localhost bin]# ./stopNode.sh
ADMU0116I: 工具信息被记录在文件中
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/nodeagent/stopServer.log
ADMU0128I: 使用AppSrv01配置文件启动工具
ADMU3100I: 读取服务器配置:nodeagent
ADMU3201I: 发出停止服务器请求。等待停止状态。
ADMU4000I: 服务器nodeagent停止完成。
[root@localhost bin]#

startNode.sh

进入相应的配置文件并执行startNode.sh以启动节点代理。

[root@localhost bin]# ./versionInfo.sh
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/versionInfo.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU0503I: Retrieving version information for all servers
ADMU0505I: Servers found in configuration:
ADMU0506I: Server name: nodeagent
ADMU0506I: Server name: server1
ADMU0509I: The cell name is: AppSrv01
ADMU0511I: The node name is: localhostNode01
ADMU0512I: The deployment manager name is: dmgr
ADMU0513I: The host name is: localhost
ADMU0514I: The product name is: WebSphere Application Server
ADMU0515I: The product version is: 8.5.5.0
ADMU0516I: The fix pack version is: 20130528_1712
ADMU0517I: The package version is: ND
ADMU0518I: The architecture is: x86-64
ADMU0519I: The installed repositories are: /opt/IBM/WebSphere/AppServer/UpdateInstaller/repository
ADMU0520I: The installed packages are: Base,FeaturePacks,Applications,SDK,WebServices,Web2FEP11
[root@localhost bin]#

findFixpack.sh

To find out the installed Fix Pack level of the WebSphere Application Server.

[root@localhost bin]# ./findFixPack.sh
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/findFixPack.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU0503I: Retrieving fix pack information for all servers
ADMU0505I: Servers found in configuration:
ADMU0506I: Server name: nodeagent
ADMU0506I: Server name: server1
ADMU0508I: The Node Agent "nodeagent" has fix pack level: 8.5.5.0
ADMU0508I: The Application Server "server1" has fix pack level: 8.5.5.0
[root@localhost bin]#

Workload Management

setupWebServer.sh

This script setups Web Server Plugin configuration between IBM HTTP Server (IHS) and WebSphere Application Server (WAS).

There are two ways to setup IHS with WAS.

  1. Preparation of IHS before installing WebSphere.
  2. Using WebSphere Customization Toolbox.
[root@localhost bin]# ./setupWebServer.sh -ihsPath /opt/IBM/HTTPServer -wasPath /opt/IBM/WebSphere/AppServer
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/setupWebServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU0519I: The installed repositories are: /opt/IBM/WebSphere/AppServer/UpdateInstaller/repository
ADMU0520I: The installed packages are: Base,FeaturePacks,Applications,SDK,WebServices,Web2FEP11
ADMU0521I: The installed IHS package is: IHS
ADMU0522I: The installed IBM HTTP Server version is: 8.0.0.0
ADMU0523I: The installed IBM HTTP Server fix pack level is: 20130528_1403
ADMU0524I: The installed IBM HTTP Server installation path is: /opt/IBM/HTTPServer
ADMU0525I: The installed WAS package is: ND
ADMU0526I: The installed WAS version is: 8.5.5.0
ADMU0527I: The installed WAS fix pack level is: 8.5.5.0
ADMU0528I: The installed WAS installation path is: /opt/IBM/WebSphere/AppServer
ADMU0530I: Creating plugin-cfg.xml
ADMU0532I: All server instances are listed in this group:
ADMU0533I: server1
ADMU0533I: nodeagent
ADMU0534I: All web servers in the group are listed in this group:
ADMU0535I: webserver1
ADMU0536I: All applications in the "All Applications" application group are listed in this group:
ADMU0537I: All applications in this group are listed in this group:
ADMU0538I: The Application Server "server1" is listed in this group
ADMU0539I: All web servers in the "default_host" virtual host group are listed in this group:
ADMU0540I: The web server "webserver1" is listed in this group
ADMU0541I: The plugin-cfg.xml file is created
[root@localhost bin]#

removeWebServer.sh

After setting up Web Server Plugin configuration, if you want to remove the configuration, you can use this script.

[root@localhost bin]# ./removeWebServer.sh -ihsPath /opt/IBM/HTTPServer -wasPath /opt/IBM/WebSphere/AppServer
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/removeWebServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU0530I: Creating plugin-cfg.xml
ADMU0532I: All server instances are listed in this group:
ADMU0533I: server1
ADMU0533I: nodeagent
ADMU0534I: All web servers in the group are listed in this group:
ADMU0535I: webserver1
ADMU0536I: All applications in the "All Applications" application group are listed in this group:
ADMU0537I: All applications in this group are listed in this group:
ADMU0538I: The Application Server "server1" is listed in this group
ADMU0539I: All web servers in the "default_host" virtual host group are listed in this group:
ADMU0540I: The web server "webserver1" is listed in this group
ADMU0541I: The plugin-cfg.xml file is created
[root@localhost bin]#

Stop WAS & Start WAS

stopServer.sh

Use this script to stop the server.

If you execute this script with -all as argument, it will stop all the servers. If you execute this script with server1 as argument, it will stop server1. Similarly, if you execute this script with nodeagent as argument, it will stop nodeagent.

[root@localhost bin]# ./stopServer.sh -all
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/stopServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: nodeagent
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server nodeagent open for e-business; process id is 11363
ADMU0503I: Retrieving server status for all servers
ADMU0505I: Servers found in configuration:
ADMU0506I: Server name: nodeagent
ADMU0506I: Server name: server1
ADMU0508I: The Node Agent "nodeagent" is STARTED
ADMU0508I: The Application Server "server1" is STARTED
ADMU0520I: The installed packages are: Base,FeaturePacks,Applications,SDK,WebServices,Web2FEP11
ADMU0530I: Creating plugin-cfg.xml
ADMU0532I: All server instances are listed in this group:
ADMU0533I: server1
ADMU0533I: nodeagent
ADMU0534I: All web servers in the group are listed in this group:
ADMU0535I: webserver1
ADMU0536I: All applications in the "All Applications" application group are listed in this group:
ADMU0537I: All applications in this group are listed in this group:
ADMU0538I: The Application Server "server1" is listed in this group
ADMU0539I: All web servers in the "default_host" virtual host group are listed in this group:
ADMU0540I: The web server "webserver1" is listed in this group
ADMU0541I: The plugin-cfg.xml file is created
[root@localhost bin]#

startServer.sh

Use this script to start the server.

If you execute this script with -all as argument, it will start all the servers. If you execute this script with server1 as argument, it will start server1. Similarly, if you execute this script with nodeagent as argument, it will start nodeagent.

[root@localhost bin]# ./startServer.sh -all
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/startServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: nodeagent
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server nodeagent open for e-business; process id is 11363
ADMU3101I: Server launched. Waiting for initialization status.
ADMU3000I: Server nodeagent open for e-business; process id is 11363
ADMU0503I: Retrieving server status for all servers
ADMU0505I: Servers found in configuration:
ADMU0506I: Server name: nodeagent
ADMU0506I: Server name: server1
ADMU0519I: The installed repositories are: /opt/IBM/WebSphere/AppServer/UpdateInstaller/repository
ADMU0520I: The installed packages are: Base,FeaturePacks,Applications,SDK,WebServices,Web2FEP11
ADMU0521I: The installed IHS package is: IHS
ADMU0522I: The installed IBM HTTP Server version is: 8.0.0.0
ADMU0523I: The installed IBM HTTP Server fix pack level is: 20130528_1403
ADMU0524I: The installed IBM HTTP Server installation path is: /opt/IBM/HTTPServer
ADMU0525I: The installed WAS package is: ND
ADMU0526I: The installed WAS version is: 8.5.5.0
ADMU0527I: The installed WAS fix pack level is: 8.5.5.0
ADMU0528I: The installed WAS installation path is: /opt/IBM/WebSphere/AppServer
ADMU0530I: Creating plugin-cfg.xml
ADMU0532I: All server instances are listed in this group:
ADMU0533I: server1
ADMU0533I: nodeagent
ADMU0534I: All web servers in the group are listed in this group:
ADMU0535I: webserver1
ADMU0536I: All applications in the "All Applications" application group are listed in this group:
ADMU0537I: All applications in this group are listed in this group:
ADMU0538I: The Application Server "server1" is listed in this group
ADMU0539I: All web servers in the "default_host" virtual host group are listed in this group:
ADMU0540I: The web server "webserver1" is listed in this group
ADMU0541I: The plugin-cfg.xml file is created
[root@localhost bin]#
[root@localhost bin]# ./versionInfo.sh
WVER0010I:版权所有IBM Corporation 2002, 2012;保留所有权利。
WVER0012I:VersionInfo报告器版本1.15.1.48,日期为2/8/12 
——————————————————————————–
IBM WebSphere产品安装状态报告
——————————————————————————– 
报告日期和时间为2015年4月12日上午3:18:41 PDT 
安装
——————————————————————————–
产品目录       /opt/IBM/WebSphere/AppServer
版本目录       /opt/IBM/WebSphere/AppServer/properties/version
DTD目录           /opt/IBM/WebSphere/AppServer/properties/version/dtd
日志目录           /var/ibm/InstallationManager/logs 
产品列表
——————————————————————————–
NDTRIAL                 已安装
已安装产品
——————————————————————————–
名称                 IBM WebSphere Application Server Network Deployment
版本               8.5.5.0
ID                   NDTRIAL
构建级别           gm1319.01
构建日期           5/14/13
包               com.ibm.websphere.NDTRIAL.v85_8.5.5000.20130514_1044
架构         x86-64 (64位)
已安装功能   IBM 64位 WebSphere SDK for Java
                     WebSphere Application Server Full Profile
                     预-EJB 3.0模块的EJBDeploy工具
                     可嵌入EJB容器
                     独立的轻型客户端和资源适配器 
——————————————————————————–
结束安装状态报告
——————————————————————————–
[root@localhost bin]#

注意:您可能会对以下支持的参数感兴趣。

  • -fixpacks:显示修补程序信息
  • -long:显示所有修补程序和ifixes
  • -ifixes:显示ifixes信息

getHistoryReport.sh

如果您正在进行审核或只是想列出组件、修复程序和刷新包及其日期,您可以运行此命令,它将在当前工作目录(通常是bin文件夹)中生成historyReport.html。

getVersionReport.sh

显示WebSphere安装的构建版本和构建日期。IBM支持人员常常要求这样做,以调查特定版本是否存在任何可疑问题。

清除缓存

清除缓存的原因可能有很多,最明显的一种是升级后。有两个缓存需要考虑清除:1)JVM 2)OSGi。

clearClassCache.sh

要清除JVM的类缓存,可以执行上述脚本。

注意:清除类缓存前必须停止JVM。

osgiCfgInit.sh

执行上述命令以清除OSGi配置文件和服务器缓存。

[root@localhost bin]# ./osgiCfgInit.sh
OSGi配置文件已成功清理为/opt/IBM/WebSphere/AppServer/profiles/Dmgr01。
OSGi服务器缓存已成功清理为/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/servers/dmgr。
[root@localhost bin]#

注意:清除缓存前,请勿忘记停止正在运行的进程。

管理配置文件

managesdk.sh

如果您安装了多个SDK,您可以切换版本。您还可以使用此脚本查找与您的配置文件关联的可用SDK。以下示例显示了可用SDK的列表。

[root@localhost bin]# ./managesdk.sh -listAvailable
CWSDK1003I:可用的SDK:
CWSDK1005I:SDK名称:1.6_64
CWSDK1001I:成功执行请求的managesdk任务。
[root@localhost bin]#

pmt.sh

PMT(Profile Management Tool)可以用于在图形用户界面模式下创建WebSphere配置文件。使用PMT创建配置文件非常简单 – 您只需要创建所需级别的配置文件并按照向导进行操作。您应该尝试一下!

syncNode.sh

如果由于某种原因您无法通过管理控制台执行节点同步操作,则可以在配置文件级别使用syncNode.sh脚本。在使用此脚本之前,必须停止节点代理。

您必须传递DMGR主机和SOAP端口号的参数。

[root@localhost bin]# ./syncNode.sh localhost 8879
ADMU0116I:工具信息被记录在文件/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/syncNode.log中
ADMU0128I:使用AppSrv01配置文件启动工具
ADMU0401I:开始对位于Deployment Manager localhost: 8879的节点localhostNode01执行syncNode操作
ADMU0016I:正在同步节点和单元的配置。
ADMU0402I:节点localhostNode01的配置已与Deployment Manager localhost: 8879同步
[root@localhost bin]#
  • localhost = Deployment Manager主机名
  • 8879 = DMGR SOAP端口号

希望上述脚本对您的日常工作有所帮助。通过 learning cloud computing 将您的职业发展提升到一个新的水平。

类似文章