个性化阅读
专注于IT技术分析

有用的WebSphere Application Server管理脚本

本文概述

安装时, IBM WebSphere Application Server(WAS)中包含超过125个Shell脚本文件。

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

我列出了一些最有用的脚本, 以简化你作为WebSphere Administrator的生活。

以下脚本已在IBM WAS ND 8.5.5环境中进行了测试, 看不出它在任何其他环境中均无法使用的任何原因。

停止和启动Deployment Manager, 节点代理和JVM

stopManager.sh

你可以使用上述命令停止Deployment Manager。

[[email protected] bin]# ./stopManager.sh
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/stopServer.log
ADMU0128I: Starting tool with the Dmgr01 profile
ADMU3100I: Reading configuration for server: dmgr
ADMU3201I: Server stop request issued. Waiting for stop status.
ADMU4000I: Server dmgr stop completed.
[[email protected] bin]#

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

startManager.sh

你可以使用上述命令启动Deployment Manager。

[[email protected] bin]# ./startManager.sh
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/startServer.log
ADMU0128I: Starting tool with the Dmgr01 profile
ADMU3100I: Reading configuration for server: dmgr
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server dmgr open for e-business; process id is 9183
[[email protected] bin]#

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

startServer.sh

要启动JVM, 可以将startServer.sh与服务器名称一起使用, 如下所示。

[[email protected] bin]# ./startServer.sh server1
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/startServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: server1
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server server1 open for e-business; process id is 10633
[[email protected] bin]#

注意:必须先启动Node Agent, 然后再启动JVM。

stopServer.sh

你可以通过执行上述命令以及JVM名称来关闭JVM。

[[email protected] bin]# ./stopServer.sh server1
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/stopServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: server1
ADMU3201I: Server stop request issued. Waiting for stop status.
ADMU4000I: Server server1 stop completed. 
[[email protected] bin]#

stopNode.sh

要停止相应的节点代理, 你必须转到该配置文件并执行stopNode.sh以停止节点代理。

[[email protected] bin]# ./stopNode.sh
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/nodeagent/stopServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: nodeagent
ADMU3201I: Server stop request issued. Waiting for stop status.
ADMU4000I: Server nodeagent stop completed. 
[[email protected] bin]#

startNode.sh

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

[[email protected] bin]# ./startNode.sh
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/nodeagent/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
[[email protected] bin]#

serverStatus.sh

要了解JVM的状态, 可以将此脚本与–all参数一起使用。

这必须在各自的配置文件级别执行。如果你在DMGR配置文件级别执行此操作, 它将仅显示DMGR的状态。

[[email protected] bin]# ./serverStatus.sh -all
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/serverStatus.log
ADMU0128I: Starting tool with the AppSrv01 profile
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
[[email protected] bin]#

备份与还原

backupConfig.sh

在生产支持中学习的第一件事就是如何进行备份。如果什么都不起作用–备份会有所帮助。

你可以使用此脚本来备份WebSphere环境配置。最佳做法是, 你可以使用” –nostop”参数, 因此无需停止Deployment Manager即可进行备份。

[[email protected] bin]# ./backupConfig.sh -nostop
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/backupConfig.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU5001I: Backing up config directory
          /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config to file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/WebSphereConfig_2015-04-12.zip
....................................................................................................................................................................................................................................................................
ADMU5002I: 933 files successfully backed up
[[email protected] bin]#

restoreConfig.sh

如果更改了配置, 但情况与预期不符, 那么可以恢复一下配置了。好了, 你可以使用备份文件来还原配置。

[[email protected] bin]# ./restoreConfig.sh WebSphereConfig_2015-04-12.zip -nostop
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/restoreConfig.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU5502I: The directory /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config
           already exists; renaming to
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config.old
ADMU5504I: Restore location successfully renamed
ADMU5505I: Restoring file WebSphereConfig_2015-04-12.zip to location
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config
.........................................................................................................................................................................
ADMU5506I: 933 files successfully restored
ADMU6001I: Begin App Preparation -
ADMU6009I: Processing complete.
ADMU6002I: Begin Asset Preparation -
ADMU6009I: Processing complete.
[[email protected] bin]#

到目前为止你喜欢吗?向下滚动以获得更多乐趣!

获取版本和修订包信息

versionInfo.sh

要了解服务器上安装的WAS版本, 构建级别, 软件包, 体系结构和已安装的功能。

[[email protected] bin]# ./versionInfo.sh
WVER0010I: Copyright (c) IBM Corporation 2002, 2012; All rights reserved.
WVER0012I: VersionInfo reporter version 1.15.1.48, dated 2/8/12 
--------------------------------------------------------------------------------
IBM WebSphere Product Installation Status Report
-------------------------------------------------------------------------------- 
Report at date and time April 12, 2015 3:18:41 AM PDT 
Installation
--------------------------------------------------------------------------------
Product Directory       /opt/IBM/WebSphere/AppServer
Version Directory       /opt/IBM/WebSphere/AppServer/properties/version
DTD Directory           /opt/IBM/WebSphere/AppServer/properties/version/dtd
Log Directory           /var/ibm/InstallationManager/logs 
Product List
--------------------------------------------------------------------------------
NDTRIAL                 installed
Installed Product
--------------------------------------------------------------------------------
Name                 IBM WebSphere Application Server Network Deployment
Version               8.5.5.0
ID                   NDTRIAL
Build Level           gm1319.01
Build Date           5/14/13
Package               com.ibm.websphere.NDTRIAL.v85_8.5.5000.20130514_1044
Architecture         x86-64 (64 bit)
Installed Features   IBM 64-bit WebSphere SDK for Java
                     WebSphere Application Server Full Profile
                     EJBDeploy tool for pre-EJB 3.0 modules
                     Embeddable EJB container
                     Stand-alone thin clients and resource adapters 
--------------------------------------------------------------------------------
End Installation Status Report
--------------------------------------------------------------------------------
[[email protected] bin]#

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

  • -fixpacks:显示修订包信息
  • -long:显示所有修订包和ifix
  • -ifixes:显示ifixes信息

getHistoryReport.sh

如果你正在执行审核, 或者只想列出组件, 修订, 带有日期的更新包, 则可以运行此命令, 它将在当前工作目录(通常是bin文件夹)中生成historyReport.html。

getVersionReport.sh

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

清除缓存

清除缓存可能有多种原因, 最明显的原因是升级后。你应该考虑清除两个缓存1)JVM 2)OSGi。

clearClassCache.sh

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

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

osgiCfgInit.sh

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

[[email protected] bin]# ./osgiCfgInit.sh
OSGi profile cache successfully cleaned for /opt/IBM/WebSphere/AppServer/profiles/Dmgr01.
OSGi server cache successfully cleaned for /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/servers/dmgr.
[[email protected] bin]#

注意:不要忘记在清除缓存之前停止正在运行的进程。

管理个人资料

managesdk.sh

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

[[email protected] bin]# ./managesdk.sh -listAvailable
CWSDK1003I: Available SDKs :
CWSDK1005I: SDK name: 1.6_64
CWSDK1001I: Successfully performed the requested managesdk task.
[[email protected] bin]#

pmt.sh

PMT(概要文件管理工具)可用于以GUI模式创建WebSphere概要文件。使用PMT创建配置文件非常容易-你要做的就是创建所需级别的配置文件并按照向导进行操作。你一定要试试看!

syncNode.sh

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

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

[[email protected] bin]# ./syncNode.sh localhost 8879
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/syncNode.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU0401I: Begin syncNode operation for node localhostNode01 with Deployment
           Manager localhost: 8879
ADMU0016I: Synchronizing configuration between node and cell.
ADMU0402I: The configuration for node localhostNode01 has been synchronized
           with Deployment Manager localhost: 8879
[[email protected] bin]#
  • 本地主机= Deployment Manager主机名
  • 8879 = DMGR SOAP端口号

我希望以上脚本对你的日常工作有用。通过学习云计算, 将你的职业提升到一个新的水平。

赞(0)
未经允许不得转载:srcmini » 有用的WebSphere Application Server管理脚本

评论 抢沙发

评论前必须登录!