ODL中的Karaf命令使用

  • Post author:
  • Post category:其他




一、部分命令详解




log:display

日志列表,键入该命令,屏幕输出karaf容器的所有日志,可以简写为

ld

opendaylight-user@root>log:display
09:15:13.642 INFO [Start Level: Equinox Container: 44e635a4-5577-4629-8cb1-562329e23efe] 
Blueprint bundle org.opendaylight.netconf.mdsal-netconf-yang-library/1.7.2 
is waiting for dependencies 
[(objectClass=org.opendaylight.mdsal.binding.api.DataBroker)]
...
opendaylight-user@root>ld
09:15:13.642 INFO [Start Level: Equinox Container: 44e635a4-5577-4629-8cb1-562329e23efe] 
Blueprint bundle org.opendaylight.netconf.mdsal-netconf-yang-library/1.7.2 
is waiting for dependencies 
[(objectClass=org.opendaylight.mdsal.binding.api.DataBroker)]
...

可以使用管道符命令进行过滤,例

ld|grep test

opendaylight-user@root>ld|grep test
09:15:17.650 INFO [Blueprint Extender: 3] testMq start -------




log:exception-display

异常显示,键入该命令,屏幕输出异常信息,可以简写为

lde

opendaylight-user@root>log:exception-display
akka.pattern.AskTimeoutException: 
Ask timed out on 
[Actor[akka://opendaylight-cluster-data/user/akka.tcp:opendaylight-cluster-data@127.0.0.1:2550_hclink/$b#652767463]] 
after [5000 ms]. Message of type [org.opendaylight.netconf.topol
ogy.singleton.messages.transactions.CancelRequest]. 
A typical reason for `AskTimeoutException` is that the recipient actor didn't send a reply.
        at akka.pattern.PromiseActorRef$.$anonfun$defaultOnTimeout$1(AskSupport.scala:648) ~[43:com.typesafe.akka.actor:2.5.26]
        ...

opendaylight-user@root>lde
akka.pattern.AskTimeoutException: 
Ask timed out on 
[Actor[akka://opendaylight-cluster-data/user/akka.tcp:opendaylight-cluster-data@127.0.0.1:2550_hclink/$b#652767463]] 
after [5000 ms]. Message of type [org.opendaylight.netconf.topol
ogy.singleton.messages.transactions.CancelRequest]. 
A typical reason for `AskTimeoutException` is that the recipient actor didn't send a reply.
        at akka.pattern.PromiseActorRef$.$anonfun$defaultOnTimeout$1(AskSupport.scala:648) ~[43:com.typesafe.akka.actor:2.5.26]
        ...




service:list

服务列表,键入该命令,屏幕输出karaf容器的所有服务,可以简写为

ls

opendaylight-user@root>service:list
[hctel.ncmount.persistence.service.MybatisServices]
---------------------------------------------------
 service.id = 227
 osgi.service.blueprint.compname = provider
 service.bundleid = 304
 service.scope = bundle
 type = default
Provided by :
 ncmount-persistence (304)
Used by:
 ncmount-accmodels (300)

opendaylight-user@root>
opendaylight-user@root>ls
[hctel.ncmount.persistence.service.MybatisServices]
---------------------------------------------------
 service.id = 227
 osgi.service.blueprint.compname = provider
 service.bundleid = 304
 service.scope = bundle
 type = default
Provided by :
 ncmount-persistence (304)
Used by:
 ncmount-accmodels (300)




config:list

配置信息列表,键入该命令,屏幕输出karaf容器的所有配置信息

opendaylight-user@root>config:list
----------------------------------------------------------------
Pid:            jmx.acl
BundleLocation: ?
Properties:
   * = admin
   felix.fileinstall.filename = file:/E:/CTCC_2021_OTN_Test/example/ncmount/karaf/target/assembly/etc/jmx.acl.cfg
   get* = viewer
   is* = viewer
   list* = viewer
   service.pid = jmx.acl
   set* = admin
----------------------------------------------------------------




feature:list

feature信息,键入该命令,屏幕输出karaf容器的所有feature信息

opendaylight-user@root>feature:list
Name                       │ Version    │ Required │ State    │ Repository                 │ Description
───────────────────────────┼────────────┼──────────┼──────────┼────────────────────────────┼────────────────────────────────
odl-message-bus-collector  │ 1.10.2     │          │ Started  │ odl-message-bus-collector  │ odl-message-bus-collector
odl-netconf-util           │ 1.7.2      │          │ Started  │ odl-netconf-1.7.2          │ odl-netconf-util
odl-netconf-all            │ 1.7.2      │          │ Started  │ odl-netconf-all            │ OpenDaylight :: Netconf :: All

加入-i参数,键入

feature:list -i

查看仅安装的所有feature信息



也就是仅显示状态为Started的feature信息




feature:repo-list

显示所有功能库列表,键入该命令,屏幕输出karaf容器的所有功能库列表

opendaylight-user@root>feature:repo-list
Repository         │ URL
───────────────────┼────────────────────────────────────────────────────────────────
odl-netconf-1.7.2  │ mvn:org.opendaylight.netconf/odl-netconf-util/1.7.2/xml/features
odl-netconf-all    │ mvn:org.opendaylight.netconf/odl-netconf-all/1.7.2/xml/features




bundle:list

显示所有bundle,键入该命令,屏幕输出karaf容器的所有bundle信息,可以简写为

la




可以看到包的状态,处于Active状态即为正常

opendaylight-user@root>bundle:list
START LEVEL 100 , List Threshold: 50
 ID │ State    │ Lvl │ Version          │ Name
────┼──────────┼─────┼──────────────────┼─────────────────────────────────────────
 17 │ Active   │  801.9.2.1          │ Apache ServiceMix :: Bundles :: jasypt
 18 │ Active   │  801.3.5            │ OPS4J Pax JDBC Generic Driver Extender
 19 │ Active   │  801.3.5            │ OPS4J Pax JDBC Config
 20 │ Active   │  801.3.5            │ OPS4J Pax JDBC Pooling Support Base

opendaylight-user@root>la
START LEVEL 100 , List Threshold: 0
 ID │ State    │ Lvl │ Version          │ Name
────┼──────────┼─────┼──────────────────┼─────────────────────────────────────────
 17 │ Active   │  801.9.2.1          │ Apache ServiceMix :: Bundles :: jasypt
 18 │ Active   │  801.3.5            │ OPS4J Pax JDBC Generic Driver Extender
 19 │ Active   │  801.3.5            │ OPS4J Pax JDBC Config
 20 │ Active   │  801.3.5            │ OPS4J Pax JDBC Pooling Support Base




list-devices

连接设备列表,键入该命令,屏幕输出karaf容器的所有设置南向设备的信息

opendaylight-user@root>list-devices
NETCONF ID │ NETCONF IP    │ NETCONF Port │ Status
───────────┼───────────────┼──────────────┼──────────
hclink     │ 192.168.1.101 │ 830          │ connected




http:list

部署servlet等http列表,键入该命令,屏幕输出karaf容器的所有部署的http信息

opendaylight-user@root>http:list
ID  │ Servlet              │ Servlet-Name                     │ State       │ Alias               │ Url
────┼──────────────────────┼──────────────────────────────────┼─────────────┼─────────────────────┼────────────────────────────────────────────────────────────────────────
189 │ JolokiaServlet       │ ServletModel-2                   │ Deployed    │ /jolokia            │ [/jolokia/*]
205 │ MoonTokenEndpoint    │ ServletModel-5                   │ Deployed    │ /moon               │ [/moon/*]
336 │ WebSocketInitializer │ WebSocketInitializer             │ Deployed    │                     │ [/rests/data-change-event-subscription/*, /rests/notification-stream/*]
338 │ ResourceServlet      │ /apidoc/18/explorer:/18/explorer │ Deployed    │ /apidoc/18/explorer │ [/apidoc/18/explorer/*]
338 │ ResourceServlet      │ /apidoc/explorer:/explorer       │ Deployed    │ /apidoc/explorer    │ [/apidoc/explorer/*]
338 │ ServletContainer     │ ServletContainer                 │ Deployed    │                     │ [/apidoc/apis/*, /apidoc/18/apis/*]




instance:list

实例列表,键入该命令,屏幕输出karaf容器的instance信息

opendaylight-user@root>instance:list
SSH Port │ SSH Host │ RMI Registry │ RMI Registry Host │ RMI Server │ RMI Server Host │ State   │ PID   │ Name
─────────┼──────────┼──────────────┼───────────────────┼────────────┼─────────────────┼─────────┼───────┼─────
    81010.0.0.0 │         1099127.0.0.1 │      44444127.0.0.1 │ Started │ 11880 │ root




shell:info

脚本信息,键入该命令,屏幕输出该电脑配置Karaf相关的脚本信息

opendaylight-user@root>shell:info
Karaf
  Karaf version               4.2.6
  Karaf home                  E:\CTCC_2021_OTN_Test\example\ncmount\karaf\target\assembly
  Karaf base                  E:\CTCC_2021_OTN_Test\example\ncmount\karaf\target\assembly
  OSGi Framework              org.eclipse.osgi-3.12.100.v20180210-1608

JVM
  Java Virtual Machine        Java HotSpot(TM) 64-Bit Server VM version 25.271-b09
  Version                     1.8.0_271
  Vendor                      Oracle Corporation
  Pid                         15616
  Uptime                      36 minutes
  Process CPU time            2 minutes
  Process CPU load            0.00
  System CPU load             1.00
  Open file descriptors       -1
  Max file descriptors        -1
  Total compile time          52.389 seconds
Threads
  Live threads                140
  Daemon threads              75
  Peak                        178
  Total started               518
Memory
  Current heap size           409,846 kbytes
  Maximum heap size           1,864,192 kbytes
  Committed heap size         879,104 kbytes
  Pending objects             0
  Garbage collector           Name = 'PS Scavenge', Collections = 20, Time = 0.572 seconds
  Garbage collector           Name = 'PS MarkSweep', Collections = 4, Time = 0.771 seconds
Classes
  Current classes loaded      24,647
  Total classes loaded        24,649
  Total classes unloaded      2
Operating system
  Name                        Windows 10 version 10.0
  Architecture                amd64
  Processors                  4




env

环境配置、缓存、脚本命令信息的简单显示,键入该命令,屏幕输出该电脑配置Karaf相关的以下信息

opendaylight-user@root>env
ConsoleSessionI #COLUMNS        org.apache.karaf.shell.impl.console.ConsoleSe...
ConsoleSessionI #LINES          org.apache.karaf.shell.impl.console.ConsoleSe...
String          APPLICATION     root
String          SCOPE           shell:bundle:*
String          SSH_AUTH_SOCK   local:karaf
Closure         cl              config:list "(service.pid=$args)"
String          com.sun.management.jmxremote
Closure         edit            shell:nano $args
Closure         env             shell:set $args
Closure         halt            system:shutdown -h -f $args
Closure         help            *:help $args | more
WindowsPath     history-file    C:\Users\hct\.karaf\karaf41.history
String          java.awt.graphicsenv sun.awt.Win32GraphicsEnvironment
String          java.awt.printerjob sun.awt.windows.WPrinterJob
String          java.class.path .;D:\Program Files\Java\jdk1.8.0_271\lib;D:\P...
String          java.home       D:\Program Files\Java\jdk1.8.0_271\jre

String          karaf.version   4.2.6
Closure         la              bundle:list -t 0 $args
Closure         ld              log:display $args
Closure         lde             log:exception-display $args
String          line.separator
Closure         log:list        log:get ALL
Closure         ls              service:list $args
Closure         man             help $args
Integer         max_colors      256
Closure         more            shell:less -F $args
String          os.arch         amd64
String          os.name         Windows 10
String          os.version      10.0
String          path.separator  ;
String          pid             15616
String          prompt          opendaylight-user@${APP...
Closure         service:get     $.context getService ($.context getServiceRef...
String          sun.arch.data.model 64





注:所有查看命令都可以使用unix管道过滤信息,例 la|grep xxx




二、命令详情大全

*:add the scope of the command, usually project name
shell:while
service:get
dev
shell:getopt
scr:info
shell:throw
scr
shell:tac
shell:keymap
unsetopt
shell:sleep
cm:getConfiguration
shell:echo
bg
sleep
ttop
cd
shell:addCommand
shell:each
jobs
shell:fg
cl
cm
halt
throw
config
shell:if
shell:grep
shell:tmux
add the scope of the command, usually project name:test-command
shell:continue
eval
shell
cm:getFactoryConfiguration
scr:config
http
fg
shell:nano
shell:clear
listConfigurations
shell:until
test-command
shell:cat
shell:__directories
env
service
addCommand
setopt
__set_unset_arguments
if
__get_scr_components
exit
system
shell:ls
getFactoryConfiguration
man
bundle
break
__option_not_present
shell:widget
la
disable
ld
complete
instance
ls
while
shell:pwd
shell:head
createFactoryConfiguration
new
sort
less
scr:disable
try
cm:createFactoryConfiguration
removeCommand
head
shell:less
getConfiguration
kar
shell:sort
cm:listConfigurations
scr:list
lde
shell:not
until
echo
shell:jobs
getopt
shell:try
shell:ttop
shell:history
each
shell:tail
shell:unsetopt
shell:new
shell:__files
shell:removeCommand
shell:wc
shell:__usage_completion
nano
continue
__usage_completion
keymap
shell:eval
jdbc
__load_class
wc
not
add the scope of the command, usually project name
grep
tmux
log:list
type
enable
shell:setopt
shell:type
pwd
widget
feature
web
more
shell:complete
shell:break
help
__directories
shell:set
date
tac
shell:format
jaas
netconf
scr:enable
package
format
history
shell:cd
__files
shell:date
cat
shell:bg
feature:info                                                                                                 (Shows information about selected feature)
feature:repo-refresh repo-refresh                                                                                       (Refresh a features repository)
bundle:watch                                                                                                              (Watches and updates bundles)
ssh:sshd sshd                                                                                                                    (Creates a SSH server)
http:list                                                                                                                  (Lists details for servlets)
exports package:exports                                                                      (Lists exported packages and the bundles that export them)
group-role-delete jaas:group-role-delete                                                                                   (Remove a role from a group)
destroy instance:destroy                                                                                      (Destroys an existing container instance)
connect-device netconf:connect-device                                                                                     (Connect to a netconf device)
feature:list                                                                      (Lists all existing features available from the defined repositories)
web:uninstall                                                                                                             (Uninstall a web application)
group-list jaas:group-list                                                                                                     (List groups in a realm)
feature:requirement-add requirement-add                                                                                 (Add provisioning requirements)
group-add jaas:group-add                                                                                                  (Make a user part of a group)
config:property-set property-set                                                                (Sets a property in the currently edited configuration)
kar:list                                                                                                                 (List the installed KAR files)
connect instance:connect                                                                                   (Connects to an existing container instance)
kar:install                                                                                                                       (Installs a KAR file)
feature:install                                                                                (Installs a feature with the specified name and version)
bundle:refresh refresh                                                                                                                (Refresh bundles)
info shell:info                                                                                                             (Prints system information)
instance:rename rename                                                                                          (Rename an existing container instance)
jdbc:tables tables                                                                                         (List the tables on a given JDBC datasource)
instance:status                                                                                               (Check the current status of an instance)
bundle:tree-show tree-show                                                                  (Shows the tree of bundles based on the wiring information)
jdbc:query query                                                                                             (Execute a SQL query on a JDBC datasource)
bundle:classes classes                                                                   (Displays a list of classes/resources contained in the bundle)
config:property-append property-append      (Appends the given value to an existing property or creates the property with the specified name and value)
dev:dump-create dump-create                                                                                  (Creates zip archive with diagnostic info)
ssh ssh:ssh                                                                                                           (Connects to a remote SSH server)
completion shell:completion                                                      (Display or change the completion mode on the current console session)
jaas:user-list user-list                                                                       (List the users of the selected JAAS realm/login module)
http:proxy-remove proxy-remove                                                                                          (Remove an existing HTTP proxy)
kar:uninstall                                                                                                                    (Uninstall a KAR file)
ds-list jdbc:ds-list                                                                                                        (List the JDBC datasources)
shell:watch watch                                                                                         (Watches & refreshes the output of a command)
name system:name                                                                                                   (Show or change Karaf instance name)
java shell:java                                                                                                  (Executes a Java standard application)
instance:ssh-host-change ssh-host-change                                              (Changes the secure shell host of an existing container instance)
jaas:su su                                                                                                                   (Substitute user identity)
ds-delete jdbc:ds-delete                                                                                                     (Delete a JDBC datasource)
bundle:diag diag                                                                           (Displays diagnostic information why a bundle is not Active)
bundle:stop stop                                                                                                                         (Stop bundles)
export-bundles feature:export-bundles                    (Export all of the bundles that make up a specified feature to a directory on the file system)
config:edit edit                                                                                                     (Creates or edits a configuration)
bundle:start-level start-level                                                                               (Gets or sets the start level of a bundle)
netconf:update-device update-device                                                                                  (Update netconf device attributes)
clear log:clear                                                                                                                     (Clear log entries)
log:load-test                                                                                                                           (Load test log)
bundle:resolve resolve                                                                                                                (Resolve bundles)
ds-create jdbc:ds-create                                                 (Create a JDBC datasource config for pax-jdbc-config from a DataSourceFactory)
jaas:role-delete role-delete                                                                                                (Delete a role from a user)
framework system:framework                                                                                                     (OSGi Framework options)
ds-info jdbc:ds-info                                                                                          (Display details about a JDBC datasource)
cancel config:cancel                                                                            (Cancels the changes to the configuration being edited)
instance:rmi-server-port-change rmi-server-port-change                 (Changes the RMI server port (used by management layer) of an existing instance)
group-role-add jaas:group-role-add                                                                                              (Add a role to a group)
config:property-list property-list                                                           (Lists properties from the currently edited configuration)
bundle:dynamic-import dynamic-import                                                               (Enables/disables dynamic-import for a given bundle)
property system:property                                                                                                 (Get or set a system property)
config:property-get property-get                                                   (Gets the value of a property in the currently edited configuration)
jaas:role-add role-add                                                                                                           (Add a role to a user)
bundle:load-test load-test                                                                                                 (Load test bundle lifecycle)
feature:repo-add repo-add                                                                                                   (Add a features repository)
feature:repo-list repo-list                                                                               (Displays a list of all defined repositories)
bundle:install install                                                                                                   (Installs one or more bundles)
web:stop                                                                                                        (Stop the web context of given bundles)
jaas:cancel                                                                                                   (Cancel the modification of a JAAS realm)
shutdown system:shutdown                                                                                                 (Shutdown the Karaf container)
group-create jaas:group-create                                                                                              (Create a group in a realm)
netconf:show-device show-device                                                                                       (Shows netconf device attributes)
feature:stop                                                                                        (Stop features with the specified name and version)
bundle:uninstall uninstall                                                                                                          (Uninstall bundles)
clone instance:clone                                                                                            (Clones an existing container instance)
bundle:info                                                                                          (Displays detailed information of a given bundles)
jaas:realm-manage realm-manage                                                                                 (Manage users and roles of a JAAS Realm)
config:update                                                                        (Saves and propagates changes from the configuration being edited)
bundle:find-class find-class                                                                         (Locates a specified class in any deployed bundle)
group-delete jaas:group-delete                                                                                             (Remove a user from a group)
web:list                                                                                                                (Lists details for war bundles)
launch web:launch                                                                       (Start the web application in a browser of the given bundle ID)
feature:requirement-list requirement-list                                                                              (List provisioning requirements)
system:version version                                                                                                   (Display the instance version)
feature:repo-remove repo-remove                                                                     (Removes the specified repository features service)
log log:log                                                                                                                             (Log a message)
feature:regions regions                                                                                       (Prints information about region digraph)
instance:restart                                                                                               (Restart an existing container instance)
get log:get                                                                                                         (Shows the currently set log level)
shell:source source                                                                                                                      (Run a script)
log:tail tail                                                                       (Continuously display log entries. Use ctrl-c to quit this command)
bundle:list list                                                                                                          (Lists all installed bundles)
bundle:services services                                                                                               (Lists OSGi services per Bundle)
feature:version-list version-list                                 (Lists all versions of a feature available from the currently available repositories)
create instance:create                                                                                               (Creates a new container instance)
jaas:realm-list realm-list                                                                                                           (List JAAS realms)
service:wait wait                                                                                                       (Wait for a given OSGi service)
feature:refresh                                                           (Reloads features processing instructions and reprovisions existing features)
kar:create                                                                                              (Create a kar file for a list of feature repos)
display log:display                                                                                                              (Displays log entries)
instance:ssh-port-change ssh-port-change                                              (Changes the secure shell port of an existing container instance)
printf shell:printf                                                                                                      (Formats and prints arguments)
config:property-delete property-delete                                                         (Deletes a property from the configuration being edited)
exception-display log:exception-display                                                             (Displays the last occurred exception from the log)
config:install                                                                                             (Install a cfg file in the Karaf etc folder)
bundle:requirements requirements                                                                        (Displays OSGi requirements of a given bundles)
imports package:imports                                                                      (Lists imported packages and the bundles that import them)
jaas:update                                                                                       (Apply pending modification on the edited JAAS Realm)
http:proxies proxies                                                                                                            (List the HTTP proxies)
bundle:restart restart                                                                                                               (Restarts bundles)
web:start                                                                                                      (Start the web context of given bundles)
config:list                                                                                                             (Lists existing configurations)
config:meta meta                                                                                                          (Lists meta type information)
jaas:pending-list pending-list                                                    (List the pending modification on the active JAAS Realm/Login Module)
bundle:update update                                                                                                                    (Update bundle)
config:delete delete                                                                                                           (Delete a configuration)
config:exists exists                                                                                                  (Check if a configuration exists)
feature:start                                                                                      (Start features with the specified name and version)
service:list                                                                                                                      (Lists OSGi services)
bundle:id id                                                                                                                       (Gets the bundle ID)
ds-factories jdbc:ds-factories                                                                                      (List the JDBC DataSourceFactories)
jaas:user-add user-add                                                                                                                     (Add a user)
bundle:status status                                                                                                    (Get the bundle current status)
bundle:start start                                                                                                                     (Starts bundles)
bundle:headers headers                                                                                       (Displays OSGi headers of a given bundles)
jaas:sudo sudo                                                                                                      (Execute a command as another user)
web:install                                                                                                                 (Install a web application)
bundle:capabilities capabilities                                                                        (Displays OSGi capabilities of a given bundles)
system:start-level                                                                                                (Gets or sets the system start level)
execute jdbc:execute                                                                                 (Execute a SQL command on a given JDBC datasource)
instance:rmi-registry-port-change rmi-registry-port-change (Changes the RMI registry port (used by management layer) of an existing container instance)
log:set set                                                                                                                        (Sets the log level)
shell:threads threads                                                                        (Prints the current threads (optionally with stacktraces))
instance:opts-change opts-change                                                           (Changes the Java options of an existing container instance)
disconnect-device netconf:disconnect-device                                                                                 (Disconnect netconf device)
exec shell:exec                                                                                                             (Executes system processes)
instance:start                                                                                                   (Start an existing container instance)
shell:stack-traces-print stack-traces-print            (Prints the full stack trace in the console when the execution of a command throws an exception)
list-devices netconf:list-devices                                                                            (List all netconf devices in the topology)
instance:stop                                                                                                     (Stop an existing container instance)
jaas:user-delete user-delete                                                                                                            (Delete a user)
http:proxy-add proxy-add                                                                                                         (Add a new HTTP proxy)
instance:list                                                                                                  (Lists all existing container instances)
jaas:whoami whoami                                                                                 (List currently active principals according to JAAS)
logout shell:logout                                                                                            (Disconnects shell from current session)
feature:provided provided                                                                         (List the features provided by a features repository)
feature:requirement-remove requirement-remove                                                                        (Remove provisioning requirements)
opendaylight-user@root>                                                                      (Uninstalls a feature with the specified name and version)



暂学习至此,还有更多指令慢慢学习上传



版权声明:本文为lxcw_sir原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。