【发布时间】:2012-01-16 09:33:34
【问题描述】:
有什么简单的方法可以查看 Jboss AS 中部署了哪些战争并取消部署其中一些?我想从命令行执行此操作。
我尝试使用 jmx,但我不断收到异常提示“org.jboss.util.NestedRuntimeException:jmx 未绑定;”我宁愿以一种我不必停止和启动应用程序服务器的方式来完成它。
【问题讨论】:
标签: jboss
有什么简单的方法可以查看 Jboss AS 中部署了哪些战争并取消部署其中一些?我想从命令行执行此操作。
我尝试使用 jmx,但我不断收到异常提示“org.jboss.util.NestedRuntimeException:jmx 未绑定;”我宁愿以一种我不必停止和启动应用程序服务器的方式来完成它。
【问题讨论】:
标签: jboss
您可以在JBoss Application Server 7 中通过三种方式解决此问题:
作为一个 GUI,管理控制台是三者中最直观的,您可以在部署窗口下看到已部署应用程序的列表。您可以选择禁用和删除此处列出的已部署应用程序。此屏幕截图来自 AS7.0.2,一些窗口已经并且会随着选项卡的添加而改变,但一般功能保持不变。
管理命令行界面是 AS7 的新增功能。 CLI 暴露了很多底层功能,一旦你熟悉了命令和操作,它就是一个强大的工具。如您所料,您可以运行help 来显示命令,或者运行<commandname> --help 以获取有关特定命令的更多信息。两个有用的命令是deploy和undeploy,那么我们来看看它们的帮助信息。我将给出 Linux 示例,但您可以根据需要插入您喜欢的操作系统。
这里是deploy:
[standalone@localhost:9999 /] deploy --help
SYNOPSIS
deploy (file_path [--name=deployment_name] [--runtime_name=deployment_runtime_name] [--force] | --name=deployment_name) [--server-groups=group_name (,group_name)* | --all-server-groups]
DESCRIPTION
Deploys the application designated by the file_path or enables an already existing
but disabled in the repository deployment designated by the name argument.
If executed w/o arguments, will list all the existing deployments.
ARGUMENTS
file_path - the path to the application to deploy. Required in case the deployment
doesn't exist in the repository.
The path can be either absolute or relative to the current directory.
--name - the unique name of the deployment. If the file path argument is specified
the name argument is optional with the file name been the default value.
If the file path argument isn't specified then the command is supposed to
enable an already existing but disabled deployment, and in this case the
name argument is required.
--runtime_name - optional, the runtime name for the deployment.
--force - if the deployment with the specified name already exists, by default,
deploy will be aborted and the corresponding message will printed.
Switch --force (or -f) will force the replacement of the existing deployment
with the one specified in the command arguments.
--server-groups - comma separated list of server group names the deploy command should apply to.
Either server-groups or all-server-groups is required in the domain mode.
This argument is not applicable in the standalone mode.
--all-server-groups - indicates that deploy should apply to all the available server groups.
Either server-groups or all-server-groups is required in domain mode.
This argument is not applicable in the standalone mode.
-l - in case none of the required arguments is specified the command will
print all of the existing deployments in the repository. The presence of the -l switch
will make the existing deployments printed one deployment per line, instead of
in columns (the default).
这里是undeploy:
[standalone@localhost:9999 /] undeploy --help
SYNOPSIS
undeploy name [--server-groups=group_name (,group_name)* | --all-relevant-server-groups] [--keep-content]
DESCRIPTION
Undeploys the deployment with the given name and, depending on the arguments, removes
its content from the repository.
If the deployment name isn't specified, prints the list of all the existing deployments.
ARGUMENTS
name - the name of the deployment to undeploy.
--server-groups - comma separated list of server group names the undeploy command should apply to.
Either server-groups or all-relevant-server-groups is required in the domain mode.
This argument is not applicable in the standalone mode.
--all-relevant-server-groups - indicates that undeploy should apply to all the server groups
in which the deployment is enabled.
Either server-groups or all-relevant-server-groups is required in domain mode.
This argument is not applicable in the standalone mode.
--keep-content - by default undeploy, besides disabling the deployment, also removes its
content from the repository. The presence of --keep-content will only disable
the deployment w/o removing its content from the repository.
This argument can be used in both standalone and domain modes.
-l - in case the deployment name isn't specified, the presence of the -l switch
will make the existing deployments printed one deployment per line, instead of
in columns (the default).
运行不带任何参数的deploy 或undeploy 命令将列出所有可用的应用程序。因此,您登录 CLI 和取消部署应用程序的工作流程将如下所示(简化):
将目录从 EAP_HOME 更改为 bin 文件夹:
[user@home EAP_HOME]$ cd bin
运行 CLI 登录脚本:
[user@host bin]$ ./jboss-admin.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
指示 API 进行连接(这也可以在运行时作为 ./jboss-admin.sh --connect 传递)。
[disconnected /] connect
Connected to standalone controller at localhost:9999
运行 undeploy 命令以显示可用的应用程序。
[standalone@localhost:9999 /] undeploy
test.ear
运行 undeploy 命令以取消部署应用程序。在这种情况下,test.ear。
[standalone@localhost:9999 /] undeploy test.ear
Successfully undeployed test.ear.
如果您将 AS7 实例作为开发工具运行,并且正在使用部署文件夹,则可以简单地删除应用程序。您会注意到创建了一个标记文件,例如test.ear.failed,以表示应用程序部署的状态。
【讨论】:
jboss-admin.sh 脚本现在在更高版本的 AS 7 和 EAP 6 中重命名为 jboss-cli.sh。
使用 JBoss 应用服务器,可以通过 deploy 目录中的 wars/ears 上的纯文件操作来处理部署。
只需ls 枚举,delete 取消部署,copy 部署,touch 重新部署。无需重启服务器。
对于最新版本的 JBoss Application Server 7,您可以使用CLI。
【讨论】:
您也可以尝试 CLI GUI。 Deployments-->Undeploy 菜单选项提供了一个部署选择列表。点击几下就完成了。
见https://community.jboss.org/wiki/AGUIForTheCommandLineInterface
【讨论】:
如果您删除了 WAR 并且 EAR 应用程序被取消部署,您不必重新启动 JBOSS 服务器。
文章 (http://docs.jboss.org/jbossas/docs/Clustering_Guide/4/html/clustering-intro-farm.html) 完美解释了它的工作原理。
如果您对此有任何疑问,请告诉所有人。
我们一直在 DEV、QA 和 Prod 环境中以同样的方式在 Jboss 上进行开发,到目前为止还没有遇到任何问题。
【讨论】: