[Windows][Linux]

WASService 命令

WASService 命令行工具使您可以在 Linux 和 Windows 操作系统上创建产品 Java™ 进程的服务。

您可以为 WebSphere® Application Server Java 进程创建服务。可能存在的服务包括下列服务器进程:
  • 应用程序服务器节点上的缺省 server1 进程
  • 您在应用程序服务器节点上创建的应用程序服务器进程

当安装向导创建服务时,卸载程序可以移除服务。如果使用 WASService 命令自已创建一个服务,那么当该服务不再有效时,您必须除去它。卸载程序不会除去您使用 WASService 命令创建的服务。

避免故障 避免故障: 您可以使用 WASServiceHelper 实用程序来替代 WASService 命令,此实用程序对 WASService 命令进行补充并减少可能的配置错误。有关更多信息,请参阅有关使用 WASServiceHelper 来创建 Windows 服务的文档。gotcha
[Windows]要在 Microsoft Windows 操作系统上设置和运行此功能,用户必须属于管理员组并具有以下高级用户权限:
  • 以操作系统方式操作
  • 作为服务登录

命令文件的位置

[Linux]wasservice.sh 命令文件位于 app_server_root\bin 目录中。

[Windows]WASService.exe 命令文件位于 app_server_root\bin 目录中。

命令语法

用于启动现有服务的命令语法

命令语法如下所示:

[Linux]
wasservice.sh -start service_name [optional startServer.bat parameters] 
[Windows]
WASService.exe -start service_name [optional startServer.bat parameters] 

用于创建服务或更新现有服务的命令语法

命令语法如下所示:

[Linux]
wasservice.sh -add service_name
   -serverName server_name
   -profilePath server_profile_directory
   [-wasHome app_server_root]
   [-startArgs additional_start_arguments]
   [-stopArgs additional_stop_arguments]
   [-userid user_id -password password]
        
[Linux]注: 对于 WebSphere Application Server V7.0 和更高版本,当指定 wasservice.sh 时,请勿在用户标识中将“@”符号用作前缀。将“@”符号用作 wasservice.sh 的用户标识前缀仅适用于 WebSphere Application Server V6.1。

不应在 V7.0 和更高版本中使用 -userid @myuser 指定 wasservice.sh。

[Windows]
WASService.exe -add service_name
   -serverName server_name
   -profilePath server_profile_directory
   [-wasHome app_server_root]
   [-configRoot configuration_repository_directory]
   [-startArgs additional_start_arguments]
   [-stopArgs additional_stop_arguments]
   [-userid user_id -password password]
   [-logFile service_log_file]
   [-logRoot server_log_directory]
   [-restart true | false]
   [-startType automatic | manual | disabled]
      
避免故障 避免故障: 虽然 -logroot 参数是可选的,但建议包括此可选参数。在某些情况下,如果您未指定此可选参数,那么可能会在事件日志中看到一个错误,表明应用程序服务器正尝试使用 -logroot 参数创建服务。gotcha

用于删除服务的命令语法

命令语法如下所示:

[Linux]
wasservice.sh -remove service_name
[Windows]
WASService.exe -remove service_name

用于停止正在运行的服务的命令语法

命令语法如下所示:

[Linux]
wasservice.sh -stop service_name [optional stopServer.bat parameters]
[Windows]
WASService.exe -stop service_name [optional stopServer.bat parameters]

用于检索服务状态的命令语法

命令语法如下所示:

[Linux]
wasservice.sh -status service_name
[Windows]
WASService.exe -status service_name

必需参数

以下是此命令的必需参数:

-profilePath server_profile_directory
使用此选项可指定定义服务器进程的概要文件的目录路径。
-serverName server_name
使用此选项可标识服务所控制的服务器。

可选参数

以下是此命令的可选参数:

-add service_name
使用此选项可创建名为 service_name 的服务或更新现有服务。对于这两种情况,语法是相同的。
-configRoot configuration_repository_directory (仅限 Windows)
使用此选项可标识 WebSphere Application Server 产品的安装根目录的配置目录。
-encodeParams service_name (仅限 Windows)
使用此选项可强制服务对 -startArgs 和 -stopArgs 进行编码,以便无法通过编辑注册表来确定参数。使用 -add 参数创建服务时,通过在命令行上添加不带参数的 -encodeParams 的方式使用该参数。
[Windows]或者对现有服务的参数进行编码:
WASService -encodeParams service_name
-logFile service_log_file (仅限 Windows)
使用此选项可标识 WASService 命令用来记录其活动的日志文件。
避免故障 避免故障: 请务必将服务日志文件指定为具有唯一路径的标准名称。当系统有多个实例时,如果没有此限制,那么结果将不可预测,并且 WASService 将无法确定初始化何时完成。gotcha
-logRoot server_log_directory (仅限 Windows)
使用此选项可标识概要文件的服务器日志目录。WASService 命令查找名为 server_name.pid 的文件,以确定服务器是否在运行。
-remove service_name
使用此选项可删除指定的服务。
-restart true | false (仅限 Windows)
使用此参数可指定现有服务在失败时是否自动重新启动。如果您将值设置为 false,那么现有服务将不会自动重新启动。缺省情况下,重新启动行为设置为 true,这使得现有服务在失败时自动重新启动。
-start service_name [optional startServer.bat parameters]
使用此选项可启动现有服务。
-startArgs additional_start_arguments
使用此选项可标识附加参数。
-startType automatic | manual | disabled (仅限 Windows)
使用此选项可定义新服务的启动类型。automatic 启动类型在系统启动或第一次调用服务时自动启动。在操作系统可以装入 manual 服务并且让它可供使用之前,您必须先将它启动。您无法在更改 disabled 启动类型之前,启动该服务。缺省情况下,此参数的值设置为 manual。
-status service_name
使用此选项可返回服务的当前状态,这包括服务正在运行还是已停止。
-stop service_name [optional stopServer.bat parameters]
使用此选项可停止指定的服务。
-stopArgs additional_stop_arguments
使用此选项可指定附加参数。
-userid user_id -password password
使用此选项可标识 Windows 服务运行所使用的特权用户标识和密码。
-wasHome app_server_root
使用此选项可标识产品的安装根目录。
注: 下列参数是“仅限 Windows”参数:
  • -configRoot
  • -encodeParams
  • -logFile
  • -logRoot
  • -restart
  • -startType
在 Linux 中用于记录和抛出错误的替代方法是使用系统的标准 sysvinit 运行常规 startServer.sh 脚本。
警告:
忽略未识别的参数。

由向导创建的服务的缺省名称

由安装向导创建的服务的名称是 IBM® WebSphere Application Server V9.x - DefaultNode。

查看服务面板

要查看服务,请打开控制面板并单击管理工具 > 服务。选择要查看它的信息的服务。右击该服务并单击属性。四个选项卡提供信息和功能。例如,选择常规选项卡上的设置类型字段,更改设置类型。

[Windows]

示例

创建应用程序服务器服务

此示例创建名为 IBM WebSphere Application Server V9.x - name_of_the_application_server_service 的服务,该服务用于启动应用程序服务器进程:

WASService -add name_of_the_application_server_service
   -servername application_server_name
   -profilePath profile_root
   -wasHome app_server_root
   -logFile WS_startServer.log
   -logRoot profile_root\logs\application_server_name
   -restart true
其中:
  • name_of_the_application_server_service 是想要命名服务的名称
  • application_server_name 是服务器的名称

输入命令后,命令窗口中会显示类似于以下示例中显示的消息的消息:

Adding Service: name_of_the_application_server_service
  Config Root: profile_root\config
  Server Name: application_server_name
  Profile Path: profile_root
  Was Home: app_server_root
  Start Args:
  Restart: 1
IBM WebSphere Application Server V9.x - name_of_the_application_server_service service successfully added.

更新现有应用程序服务器服务

此示例适用于 Windows 操作系统,它使用其他停止参数、用户名和密码更新名为 IBM WebSphere Application Server V9.x - Server2 Service 的现有服务。 参数将自动传递到 Windows 服务关闭系统所使用的脚本中。

WASService -add "Server2 Service"
   -servername server2
   -profilePath profile_root
   -logRoot profile_root\logs\server2
   -stopArgs "-username user_name  -password password"
   -encodeParams
[Windows]

创建 Windows 服务后,开始和停止服务器进程

对于此 Windows 操作系统示例,如果您在创建 server1 的 Windows 服务后发出 startServer server1 命令或 stopServer server1 命令,那么显示与下列示例类似的消息:

Because server1 is registered to run as a Windows Service, the
request to start this server will be completed by starting the
associated Windows Service.
避免故障 避免故障: 在 Windows 中创建和除去 WebSphere 服务可能会让人感到困惑并且容易出错。要获取有关诊断任何错误的帮助,请参阅有关使用 WASServiceCmd 为 WebSphere Application Server 创建 Windows 服务的信息。gotcha

指示主题类型的图标 参考主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-base-dist&topic=rins_wasservice
文件名:rins_wasservice.html