JBossEAP6、管理CLIメモ
管理CLIはコマンドライン形式でJBoss EAP6の管理リソースを制御できるツール。
Linuxを利用しているようにオペレーションできる。
ここではWindows7とJBoss EAP6.1で試した結果。
管理CLIの操作においてはWindowsでもLinuxでも関係なく同じ操作でいける。
管理ツールとしては他に
- 管理コンソール(Management Console)
- JConsole
がある。
管理CLIの実行方法(対話モード)
「[JBOSS_HOME]/bin」の「jboss-cli.sh / jboss-cli.bat」を使用する。
JBossEAPを起動済みであること。
起動&接続&停止
C:\Program Files\EAP-6.1.0\jboss-eap-6.1\bin>jboss-cli.bat You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported command. [disconnected /]
これはシェル(ばっち?)を起動しただけなので、EAPへ接続する。
「connect」と打てばよい。
[disconnected /] connect [standalone@localhost:9999 /]
これで起動&接続完了。
これで「Linuxを利用しているようにオペレーションできる」状態になっている。
続いて停止。
「quit」を入力する。
[standalone@localhost:9999 /] quit 続行するには何かキーを押してください . . . C:\Program Files\EAP-6.1.0\jboss-eap-6.1\bin>
基本的なコマンドによる操作
さあ困った。
「help」してみるとUSAGEがでるが、まずは「ls」と打ってみよう。
[standalone@localhost:9999 /] ls core-service system-property product-name=EAP deployment launch-type=STANDALONE product-version=6.1.0.GA deployment-overlay management-major-version=1 release-codename=Janus extension management-micro-version=0 release-version=7.2.0.Final-redhat-8 interface management-minor-version=4 running-mode=NORMAL path name=noa-tanakakns schema-locations=[] socket-binding-group namespaces=[] server-state=running subsystem process-type=Server
管理CLIではJBossEAPの設定項目およびその値がLinuxのディレクトリ構造で表現される。
上記を見てみると「xxx」形式の「xxx=yyy」形式(イコールが入っている)の2種類ある。
前者(「xxx」形式)は設定項目がグルーピングされたものであり、管理CLI上ではディレクトリとなっている。
例えばデプロイされたアプリが見たければ
[standalone@localhost:9999 /] cd deployment [standalone@localhost:9999 deployment] ls sample-app1.war sample-app2.war
ディレクトリを移動してls。(実際にファイルシステムでこのディレクトリ構造ではなく、あくまで管理CLI上での見え方)
Linuxコマンドと同様
[standalone@localhost:9999 deployment] cd .. [standalone@localhost:9999 /]
で上の階層に戻れる。
サブシステム(JavaEEコンテナ関連等の設定)が見たければ
[standalone@localhost:9999 /] cd subsystem [standalone@localhost:9999 subsystem] ls datasources infinispan jpa naming sar web deployment-scanner jca jsf pojo security webse ee jdr logging remoting threads weld ejb3 jmx mail resource-adapters transactions
基本的なコマンドの一覧は下記。(helpで見れる)
コマンド | 説明 |
---|---|
cn (or cd) | ノード(ディレクトリ)のパスを変更 |
connect | サーバのインスタンスへ接続 |
deploy | アプリケーションをデプロイ |
help (or h) | ヘルプ情報を表示 |
history | 履歴の表示と「有効/無効/クリア」の設定 |
ls | 現ノード(ディレクトリ)を一覧表示 |
pwn (or pwd) | 現ノード(ディレクトリ)までのパスを表示 |
quit (or q) | CLI停止 |
undeploy | アプリケーションをアンデプロイ |
version | バージョンおよび環境情報を表示 |
後者(「xxx=yyy」形式)はそのノード(ディレクトリ)で管理しているリソース。
「xxx=yyy」形式の「xxx」の部分をリソースと呼ぶ。設定対象・項目そのもの。
lsした際に見れる「product-version=6.1.0.GA」は、このJBossEAPのバージョンが「6.1.0.GA」であることを表している。
管理CLIオペレーション
管理CLIには専用のオペレーションがあり「read-operation」で一覧を表示できる。
[standalone@localhost:9999 /] read-operation add-namespace read-children-types remove-schema-location upload-deployment-bytes add-schema-location read-config-as-xml replace-deployment upload-deployment-stream delete-snapshot read-operation-description resolve-expression upload-deployment-url full-replace-deployment read-operation-names resolve-internet-address validate-address list-snapshots read-resource server-set-restart-required validate-operation read-attribute read-resource-description shutdown whoami read-children-names reload take-snapshot write-attribute read-children-resources remove-namespace undefine-attribute
オペレーションを実行する際は、頭に「:」をつけて実行する。
[standalone@localhost:9999 /] :read-resource { "outcome" => "success", "result" => { "deployment-overlay" => undefined, "management-major-version" => 1, "management-micro-version" => 0, "management-minor-version" => 4, "name" => "noa-tanakakns", "namespaces" => [], "product-name" => "EAP", "product-version" => "6.1.0.GA", "release-codename" => "Janus", "release-version" => "7.2.0.Final-redhat-8", "schema-locations" => [], "system-property" => undefined, "core-service" => { "management" => undefined, "service-container" => undefined, "module-loading" => undefined, "server-environment" => undefined, "platform-mbean" => undefined }, "deployment" => { "Spring3HelloWorldJerseyJSON.war" => undefined, "sample-app.war" => undefined }, "extension" => { "org.jboss.as.clustering.infinispan" => undefined, "org.jboss.as.connector" => undefined, "org.jboss.as.deployment-scanner" => undefined, "org.jboss.as.ee" => undefined, "org.jboss.as.ejb3" => undefined, "org.jboss.as.jdr" => undefined, "org.jboss.as.jmx" => undefined, "org.jboss.as.jpa" => undefined, "org.jboss.as.jsf" => undefined, "org.jboss.as.logging" => undefined, "org.jboss.as.mail" => undefined, "org.jboss.as.naming" => undefined, "org.jboss.as.pojo" => undefined, "org.jboss.as.remoting" => undefined, "org.jboss.as.sar" => undefined, "org.jboss.as.security" => undefined, "org.jboss.as.threads" => undefined, "org.jboss.as.transactions" => undefined, "org.jboss.as.web" => undefined, "org.jboss.as.webservices" => undefined, "org.jboss.as.weld" => undefined }, "interface" => { "management" => undefined, "public" => undefined, "unsecure" => undefined }, "path" => { "jboss.server.temp.dir" => undefined, "user.home" => undefined, "jboss.server.base.dir" => undefined, "java.home" => undefined, "user.dir" => undefined, "jboss.server.data.dir" => undefined, "jboss.home.dir" => undefined, "jboss.server.log.dir" => undefined, "jboss.server.config.dir" => undefined, "jboss.controller.temp.dir" => undefined }, "socket-binding-group" => {"standard-sockets" => undefined}, "subsystem" => { "logging" => undefined, "datasources" => undefined, "deployment-scanner" => undefined, "ee" => undefined, "ejb3" => undefined, "infinispan" => undefined, "jca" => undefined, "jdr" => undefined, "jmx" => undefined, "jpa" => undefined, "jsf" => undefined, "mail" => undefined, "naming" => undefined, "pojo" => undefined, "remoting" => undefined, "resource-adapters" => undefined, "sar" => undefined, "security" => undefined, "threads" => undefined, "transactions" => undefined, "web" => undefined, "webservices" => undefined, "weld" => undefined } } }
オペレーションの結果はJSON形式で返される。
オペレーションには引数を指定して実行するものもある。
下記はオペレーションの説明を返すオペレーション。
[standalone@localhost:9999 /] :read-operation-description(name=read-resource) { "outcome" => "success", "result" => { "operation-name" => "read-resource", "description" => "子リソースに関する基本情報あるいは完全情報とともに、モデルリソースの属性値を読み込みます。", "request-properties" => { "recursive" => { "type" => BOOLEAN, "description" => "子リソースに関する完全情報を再帰的に含めるかどうか。ない場合は false がデフォルトです。", "expressions-allowed" => false, "required" => false, "nillable" => true, "default" => false }, "recursive-depth" => { "type" => INT, "description" => "子のリソースを含むべきかに関する情報の再帰処理の深さ", "expressions-allowed" => false, "required" => false, "nillable" => true, "default" => 0 }, "proxies" => { "type" => BOOLEAN, "description" => "再帰的なクエリにリモートのリソースを含めるかどうか (ドメイン root のクエリ内のホストレベルのリソース。ホストのクエリ内で稼動中のサーバーリソース)。ない場合は false がデフォルトです。", "expressions-allowed" => false, "required" => false, "nillable" => true, "default" => false }, "include-runtime" => { "type" => BOOLEAN, "description" => "ランタイム属性をレスポンスに含むかどうか (値が永続設定から来るもの)。ない場合は falseがデフォルトです。", "expressions-allowed" => false, "required" => false, "nillable" => true, "default" => false }, "include-defaults" => { "type" => BOOLEAN, "description" => "デフォルトの読み込みを有効化/無効化する Boolean。False に設定している場合は、ユーザーが設定した属性のみ返し、未定義の場合は無視します。", "expressions-allowed" => false, "required" => false, "nillable" => true, "default" => true }, "attributes-only" => { "type" => BOOLEAN, "description" => "指定リソースの属性のみを読み取るかどうか。'recursive' または 'recursive-depth' と共に使用できません。", "expressions-allowed" => false, "required" => false, "nillable" => true, "default" => false }, "include-aliases" => { "type" => BOOLEAN, "description" => "true で recursive の場合、エイリアスである子が含まれます。", "expressions-allowed" => false, "required" => false, "nillable" => true, "default" => false } }, "reply-properties" => { "type" => OBJECT, "description" => "子リソースに関する情報とリソースの属性値" }, "read-only" => true } }
引数の情報も表示してくれる。困ったらこれを使うのかな。
また、対象のリソースによって実行できるオペレーションは異なる。
例えば、subsystemノードのdatasourceに対しては下記のオペレーションを実行できる。
[standalone@localhost:9999 /] cd subsystem [standalone@localhost:9999 subsystem] cd datasources [standalone@localhost:9999 subsystem=datasources] :read-operation-names { "outcome" => "success", "result" => [ "add", "get-installed-driver", "installed-drivers-list", "read-attribute", "read-children-names", "read-children-resources", "read-children-types", "read-operation-description", "read-operation-names", "read-resource", "read-resource-description", "remove", "undefine-attribute", "whoami", "write-attribute" ] }
「:read-operation-names」は対象のリソースに対して実行できるオペレーションの名前を表示する。
ノードをcdで移動してオペレーションを実行するのは面倒だ!という人のために1行で実行する方法もある。
[standalone@localhost:9999 /] /subsystem=datasources:read-operation-names { "outcome" => "success", "result" => [ "add", "get-installed-driver", "installed-drivers-list", "read-attribute", "read-children-names", "read-children-resources", "read-children-types", "read-operation-description", "read-operation-names", "read-resource", "read-resource-description", "remove", "undefine-attribute", "whoami", "write-attribute" ] }
構文は
- 「[ノードのパス]:[オペレーション]」
となる。
また、ノードのパスは「/subsystem/datasources」ではなく「/subsystem=datasources」で表す。
区切りは「/」(スラッシュ)ではなく「=」(イコール)。
よく使うオペレーションは下記。
オペレーション | 説明 |
---|---|
read-operation-names | 指定のリソースに対する全操作の名前を取得 |
read-operation-description | 指定操作の詳細を取得 ex):read-operation-description(name=read-operation-names) |
read-resource | |
read-resource-description | |
read-attribute | |
write-attribute |
つづき何書くか忘れた。