![[Windows]](../images/windows.gif)
![[Linux]](../images/linux.gif)
WASService 命令
WASService 命令行工具使您可以在 Linux 和 Windows 操作系统上创建产品 Java™ 进程的服务。
![[Windows]](../images/windows.gif)

![[Windows]](../images/windows.gif)
命令文件的位置
wasservice.sh 命令文件位于 app_server_root\bin 目录中。
WASService.exe 命令文件位于 app_server_root\bin 目录中。
命令语法
用于启动现有服务的命令语法
命令语法如下所示:
![[Linux]](../images/linux.gif)
wasservice.sh -start service_name [optional startServer.bat parameters]
![[Windows]](../images/windows.gif)
WASService.exe -start service_name [optional startServer.bat parameters]
用于创建服务或更新现有服务的命令语法
命令语法如下所示:
![[Linux]](../images/linux.gif)
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]](../images/linux.gif)
不应在 V7.0 和更高版本中使用 -userid @myuser 指定 wasservice.sh。
![[Windows]](../images/windows.gif)
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]

用于删除服务的命令语法
命令语法如下所示:
![[Linux]](../images/linux.gif)
wasservice.sh -remove service_name
![[Windows]](../images/windows.gif)
WASService.exe -remove service_name
用于停止正在运行的服务的命令语法
命令语法如下所示:
![[Linux]](../images/linux.gif)
wasservice.sh -stop service_name [optional stopServer.bat parameters]
![[Windows]](../images/windows.gif)
WASService.exe -stop service_name [optional stopServer.bat parameters]
用于检索服务状态的命令语法
命令语法如下所示:
![[Linux]](../images/linux.gif)
wasservice.sh -status service_name
![[Windows]](../images/windows.gif)
WASService.exe -status service_name
必需参数
以下是此命令的必需参数:
- 使用此选项可指定定义服务器进程的概要文件的目录路径。
- 使用此选项可标识服务所控制的服务器。
可选参数
以下是此命令的可选参数:
- -add service_name
- 使用此选项可创建名为 service_name 的服务或更新现有服务。对于这两种情况,语法是相同的。
- -configRoot configuration_repository_directory (仅限 Windows)
- 使用此选项可标识 WebSphere Application Server 产品的安装根目录的配置目录。
- -encodeParams service_name (仅限 Windows)
- 使用此选项可强制服务对 -startArgs 和 -stopArgs 进行编码,以便无法通过编辑注册表来确定参数。使用 -add 参数创建服务时,通过在命令行上添加不带参数的 -encodeParams 的方式使用该参数。
或者对现有服务的参数进行编码:
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
- 使用此选项可标识产品的安装根目录。
- -configRoot
- -encodeParams
- -logFile
- -logRoot
- -restart
- -startType
由向导创建的服务的缺省名称
- IBM WebSphere Application Server V9.x - node_name_of_the_deployment_manager_node
- IBM WebSphere Application Server V9.x - node_name_of_the_server1_node
- 在联合节点并创建应用程序服务器之后,可以创建名为 IBM WebSphere Application Server V9.x - node_name_of_the_managed_node 的服务。
创建定制概要文件后,您必须联合节点以在节点上创建 Node Agent 服务器。您还可以使用 Deployment Manager 的管理控制台在节点上创建应用程序服务器进程。您可以为节点代理服务器进程创建 Windows 服务。
也在将应用程序服务器节点添加到 Deployment Manager 单元后创建 Node Agent 服务器。稍后您可以为节点代理服务器进程创建服务。
查看服务面板
要查看服务,请打开控制面板并单击管理工具 > 服务。选择要查看它的信息的服务。右击该服务并单击属性。四个选项卡提供信息和功能。例如,选择常规选项卡上的设置类型字段,更改设置类型。
![[Windows]](../images/windows.gif)
示例
创建 Deployment Manager 服务
此示例创建名为 IBM® WebSphere Application Server V9.x - name_of_the_deployment_manager_service 的服务,该服务用于启动 dmgr 进程:
WASService -add name_of_the_deployment_manager_service
-servername deployment_manager_server_name
-profilePath profile_root
-wasHome app_server_root
-logFile WS_startManager.log
-logRoot profile_root\logs\deployment_manager_server_name
-restart true
其中:
输入命令后,命令窗口中会显示类似于以下示例中显示的消息的消息:
Adding Service: name_of_the_deployment_manager_service
Config Root: profile_root\config
Server Name: deployment_manager_server_name
Profile Path: profile_root
Was Home: app_server_root
Start Args:
Restart: 1
IBM WebSphere Application Server V9.x - name_of_the_deployment_manager_service service successfully added.
单击开始 > 设置 > 控制面板 > 管理工具 > 服务,以使用新服务。
创建 Node Agent 服务
此示例创建名为 IBM WebSphere Application Server V9.x - name_of_the_node_agent_service 的服务,该服务用于启动 Node Agent 服务器进程:
WASService -add name_of_the_node_agent_service
-servername node_agent_server_name
-profilePath profile_root
-wasHome app_server_root
-logFile WS_startNode.log
-logRoot profile_root\logs\node_agent_server_name
-restart true
其中:
输入命令后,命令窗口中会显示类似于以下示例中显示的消息的消息:
Adding Service: name_of_the_node_agent_service
Config Root: profile_root\config
Server Name: node_agent_server_name
Profile Path: profile_root
Was Home: app_server_root
Start Args:
Restart: 1
IBM WebSphere Application Server V9.x - name_of_the_node_agent_service service successfully added.
创建应用程序服务器服务
此示例创建名为 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
其中:
输入命令后,命令窗口中会显示类似于以下示例中显示的消息的消息:
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]](../images/windows.gif)
创建 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.
如果您在创建 nodeagent进程的 Windows 服务后发出 startNode 命令或 stopNode 命令,那么显示与下列示例类似的消息:
Because nodeagent is registered to run as a Windows Service, the
request to start or stop this server will be completed by
starting or stopping the associated Windows Service. Examine
the log files to view messages related to this command.
如果您在创建 Deployment Manager 的 Windows 服务后发出 startManager 命令或 stopManager 命令,那么显示与下列示例类似的消息:
Because dmgr is registered to run as a Windows Service, the
request to start or stop this server will be completed by
starting or stopping the associated Windows Service. Examine
the log files to view messages related to this command.
