领先一步
VMware 提供培训和认证,助您加速进步。
了解更多dm Server 有一个新的命令行 shell。它目前与现有的 Equinox shell 一起提供,并将取代它用于 2.0 版本。Equinox shell 的改进包括基本的 Tab 补全和命令历史记录。
dm Shell 在本地和通过 SSH 远程都可用。当通过 './startup.sh -shell' 选项启动服务器在本地使用时,一旦 dm 内核启动,它将接管控制台输出。控制台输出仍然可以在事件日志中查看。无论哪种方式,首先出现的是一个 ASCII 艺术启动画面,然后是命令提示符 ':> '。
[13:36:54 ~]: ssh -p 2402 admin@localhost
admin@localhost's password:
@@@ ***
@@@ ***** .__. .__. .__. .__.
@@@@ ****** __| | _____ _____.| |__ ____ | | | |
@@@@@@ **** / __ | / \ / ___/| | \ ./ __ \ | | | |
@@@@@ *** / /_/ || Y Y \ \___ \ | Y \\ ___/ | |__| |__
@@@ *** \______||__|_|__/ /_____/ |___|__/ \____/ |____/|____/
Type 'help' to see the available commands.
:>
远程访问 dm Shell 需要密码,安全性由 JAAS 认证提供,与 dm Console 的 ID/密码相同。默认是 'admin/springsource'。这可以通过 'config' 目录中的 'com.springsource.kernel.users.properties' 文件进行配置。
进入 shell 后,输入 'help' 以查看可用命令列表。当命令输入到一半时,只需按 'TAB' 即可查看该命令可能的补全列表,而无需返回并再次输入 'help'。
从 'bundles' 命令开始,这将显示系统中的 用户区域 捆绑包。显示了它们的状态、名称、版本以及它们是否由 Spring 提供支持。除了少数用于管理用户区域的内核捆绑包及其服务之外,内核的任何部分都对用户安装的工件不可见。这使得它更清晰,因为可见的系统捆绑包和服务要少得多。
:> bundles
Id State Name-Version
0 Active org.eclipse.osgi-3.5.1.R35x_v20090827
1 Active com.springsource.region.user-0.0.0
2 Resolved org.springframework.aop-3.0.0.CI-395
3 Resolved org.springframework.asm-3.0.0.CI-395
....
46 Active S com.springsource.server.admin.web-2.0.0.M5
47 Active com.springsource.javax.servlet.jsp.jstl-1.1.2
48 Active com.springsource.org.apache.taglibs.standard-1.1.2
49 Active org.springframework.context.support-3.0.0.CI-395
50 Active org.springframework.jdbc-3.0.0.CI-395
51 Active org.springframework.js-2.0.8.RELEASE
52 Active org.springframework.transaction-3.0.0.CI-395
53 Active org.springframework.web.servlet-3.0.0.CI-395
54 Active S com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted.core-2.0.0.M5
55 Active com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted.web-2.0.0.M5
56 Active com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted-synthetic.context-2.0.0.M5
57 Active com.springsource.server.splash-2.0.0.M5
执行操作也很容易,例如安装捆绑包。输入 'install file:/path.to.bundle.jar'。
:> install file:/Users/chrisfrost/Desktop/com.bar.import-1.0.0.jar
60 Installed com.bar.importer-1.0.0
捆绑包已安装,但当我们尝试 'start' 它时出现错误。尝试启动捆绑包时,显示了捆绑包缺少必需的依赖项。
:> start 60
Error occured while starting bundle '[60] com.bar.importer-1.0.0' : The bundle could not be resolved. Reason: Missing Constraint: Import-Package: com.foo; version="[1.0.0,2.0.0)"
:>
使用 'diag' 命令可以随时轻松获取此信息。显示的信息将与尝试启动捆绑包时日志文件中显示的信息相同。
:> diag 60
Resolution report for bundel 60 Installed com.bar.importer-1.0.0
Cannot resolve: com.bar.importer
Resolver report:
An Import-Package could not be resolved. Caused missing constraint <Import-Package: com.foo; version="[1.0.0,2.0.0)"> in bundle <com.bar.importer_1.0.0>
:>
我们可以安装一个满足依赖项的捆绑包,然后再次 'start' 我们的原始捆绑包,这次一切顺利。
这是一个非常简单的捆绑包,可以通过输入 'bundle 60' 来详细查看。请记住有 Tab 补全功能,所以只需 'bu TAB 60' 即可完成命令。这里显示了此捆绑包导入和导出的所有包。捆绑包名称前的 'S' 表示该捆绑包具有 Spring 上下文。
:> bundle 60
Bundle report for 60 Active S com.bar.importer-1.0.0
Imported packages:
com.foo-[1.0.0, 2.0.0)
Exported packages:
:> bundle 61
Bundle report for 61 Resolved com.foo.exporter-1.0.0
Imported packages:
Exported packages:
com.foo-1.0.0
:>
我们可以看到它现在导入了之前导致错误的包。显示的第二个捆绑包是导出该包的捆绑包。
其他一些可用命令包括 'config' 和 'configs',它们将显示已安装的配置及其属性。
:> configs
Pid
com.springsource.kernel
com.springsource.repository
com.springsource.server.repository.hosted
com.springsource.osgi.medic
com.springsource.kernel.users
com.springsource.kernel.jmxremote.access
:> config com.springsource.osgi.medic
Pid = com.springsource.osgi.medic
Factory pid = null
Bundle location = null
dump.root.directory = serviceability/dump
log.wrapSysErr = true
log.wrapSysOut = true
service.pid = com.springsource.osgi.medic
:>
显示的是可用配置列表和 medic 配置的属性。完成 dm Shell 后,有两种方法可以退出。'exit' 将简单地退出 shell,而 'shutdown' 将调用服务器上的关闭命令,并且 shell 会话将作为关闭的一部分终止。
:> exit
Goodbye.
Connection to localhost closed.
[14:24:03 ~]:
在 2.0 版本发布之前,我们正在对 shell 进行更多的工作,届时将有一个完整的用户指南,我猜还会有另一篇博客或截屏视频。所以,如果您想看到一些杀手级功能,请大声说出来。