WebLogic Scripting Tool ガイド
![]() |
![]() |
![]() |
![]() |
以下の節では、WLST を使用して MBean を移動、照会、および編集する方法について説明します。
WLST では、MBean に簡単にアクセスできます。weblogic.Admin
ユーティリティ (WebLogic Server のこのリリースでは非推奨) と WLST は、MBean と対話するためのインタフェースを提供しますが、MBean の取得方法が異なります。
weblogic.Admin
ユーティリティが提供する MBean 関連コマンドでは、対話する MBean のオブジェクト名を決定する必要があります。オブジェクト名はドキュメントに記載の規約に基づいて生成されますが、階層内のいくつかの層に渡って子 MBean のオブジェクト名を正確に指定することが困難な場合があります。
WLST では、MBean 取得の方法が異なります。オブジェクト名を指定するのではなく、ファイル システム内のファイルの階層を移動するのと同様なやり方で、MBean の階層を移動します。
WebLogic Server は、MBean を階層データ モデルにまとめます。WLST ファイル システムでは、MBean 階層はドライブに、MBean タイプとインスタンスはディレクトリに、MBean 属性とオペレーションはファイルに相当します。UNIX または Windows コマンド シェルでファイル システムを移動するときと同じように、WLST は cd
、ls
、pwd
などのコマンドを使用して、MBean の階層構造を移動します。MBean インスタンスに移動したら、WLST コマンドを使用して MBean と対話します。
注意 : WLST オフラインでアクセスおよび更新できるのは、コンフィグレーション ファイル内にあるコンフィグレーション オブジェクトのみなので、XML 要素としてコンフィグレーション ファイル内に既に永続化されていないコンフィグレーション オブジェクトの属性値を表示したり変更したりするには、まずコンフィグレーション オブジェクトを作成する必要があります。
コンフィグレーション階層において、ルート ディレクトリは DomainMBean
(
『WebLogic Server® MBean リファレンス』の「DomainMBean」を参照)、MBean タイプはルート ディレクトリの下位ディレクトリ、MBean の名前 (MBean インスタンス) は MBean タイプ ディレクトリの下位ディレクトリ、MBean 属性およびオペレーションは MBean ディレクトリの下のノード (ファイル等) です。各 MBean インスタンスは、MBean タイプの下位ディレクトリです。ほとんどの場合、1 つのタイプに複数のインスタンスが存在可能です。
WLST はまず、サーバのコンフィグレーション MBean のルートの WebLogic Server インスタンスに接続します。これは、ルートを DomainMBean
とした単一の階層です。WLST コマンドでは、サーバの実行時 MBean、ドメイン全体のサービスのための MBean、ドメイン内のすべてのコンフィグレーション MBean の編集可能なコピーなど、ドメイン内のすべての WebLogic Server MBean 階層にアクセスできます。詳細については、「ツリー コマンド」を参照してください。
MBean 階層の詳細については、『JMX によるカスタム管理ユーティリティの開発』の「WebLogic Server MBean のデータ モデル」を参照してください。
WLST が初めて WebLogic Server のインスタンスに接続すると、変数 cmo
(現在の管理オブジェクト) がすべてのコンフィグレーション管理オブジェクトのルート DomainMBean
に初期化されます。MBean タイプに移動すると、cmo
の値は親 MBean を反映したものになります。MBean インスタンスに移動すると、WLST はコード リスト 4-1 に示すとおり、cmo
の値を現在の MBean インスタンスになるよう変更します。
WLST 変数の詳細については、「WLST 変数リファレンス」を参照してください。
C:\> java weblogic.WLST
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to Weblogic Server Administration Scripting Shell
...
wls:/(offline)> connect('username','password')
Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ...
Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'.
Warning: An insecure protocol was used to connect to the server.
To ensure on-the-wire security, the SSL port or Admin port should be used instead.
wls:/mydomain/serverConfig> cmo
[MBeanServerInvocationHandler]mydomain:Name=mydomain,Type=Domain
wls:/mydomain/serverConfig> cd('Servers')
wls:/mydomain/serverConfig/Servers> cmo
[MBeanServerInvocationHandler]mydomain:Name=mydomain,Type=Domain
wls:/mydomain/serverConfig/Servers> cd('myserver')
wls:/mydomain/serverConfig/Servers/myserver> cmo
[MBeanServerInvocationHandler]mydomain:Name=myserver,Type=Server
ServerMBean
のインスタンスに移動後、WLST は cmo
の値を DomainMBean
から ServerMBean
に変更します。
コード リスト 4-2 のコマンドは、管理サーバのインスタンスに接続してから移動し、DomainMBean
に MBean を表示するよう WLST に指示します。引数を指定しない場合は、ls
コマンドによりすべての子 MBean と属性が表示されます。
コード リスト 4-2 コンフィグレーション MBean の移動と表示
C:\> java weblogic.WLST
wls:/offline> connect('username','password')
wls:/mydomain/serverConfig> ls()
dr-- AppDeployments
dr-- BridgeDestinations
dr-- Clusters
dr-- DeploymentConfiguration
dr-- Deployments
dr-- EmbeddedLDAP
...
-r-- AdminServerName myserver
-r-- AdministrationMBeanAuditingEnabled false
-r-- AdministrationPort 9002
-r-- AdministrationPortEnabled false
-r-- AdministrationProtocol t3s
-r-- ArchiveConfigurationCount 5
...
wls:/mydomain/serverConfig> cd('Servers')
wls:/mydomain/serverConfig/Servers> ls()
dr-- managed1
dr-- myserver
wls:/mydomain/serverConfig/Servers> cd('myserver')
wls:/mydomain/serverConfig/Servers/myserver> ls()
dr-- COM
dr-- CandidateMachines
dr-- Cluster
dr-- DefaultFileStore
dr-- ExecutiveQueues
dr-- IIOP
dr-- JTAMigrateableTarget
dr-- Log
dr-- Machine
dr-- NetworkAccessPoints
dr-- OverloadProtection
dr-- SSL
...
-r-- AcceptBacklog 50
-r-- AdminReconnectIntervalSeconds 10
-r-- AdministrationPort 0
-r-- AdministrationPortAfterOverride 9002
-r-- AdministrationPortEnabled false
-r-- AdministrationProtocol t3s
-r-- AutoKillIfFailed false
-r-- AutoRestart true
....
wls:/mydomain/serverConfig/Servers/myserver> cd('Log/myserver')
wls:/mydomain/serverConfig/Servers/myserver/Log/myserver> ls()
dr-- DomainLogBroadcastFilter
dr-- LogFileFilter
dr-- MemoryBufferFilter
dr-- StdoutFilter
-r-- DomainLogBroadcastFilter null
-r-- DomainLogBroadcastSeverity Warning
-r-- DomainLogBroadcasterBufferSize 0
-r-- FileCount 7
-r-- FileMinSize 500
-r-- FileName myserver.log
-r-- FileTimeSpan 24
-r-- Log4jLoggingEnabled false
-r-- LogFileFilter null
-r-- LogFileRotationDir null
-r-- LogFileSeverity Debug
-r-- MemoryBufferFilter null
-r-- MemoryBufferSeverity Debug
-r-- MemoryBufferSize 500
-r-- Name myserver
-r-- Notes null
-r-- NumberOfFilesLimited false
-r-- RedirectStderrToServerLogEnabled false
-r-- RedirectStdoutToServerLogEnabled false
-r-- RotateLogOnStartup true
-r-- RotationTime 00:00
-r-- RotationType bySize
-r-- StdoutFilter null
-r-- StdoutSeverity Warning
-r-- Type Log
-r-x isSet Boolean : String(propertyName)
-r-x unSet Void : String(propertyName)
ls
コマンドの出力情報において、d
は cd
コマンドを使用できる MBean (ファイル システムのディレクトリに類似) を示し、r
は読み取り可能なプロパティを示し、w
は書き込み可能なプロパティを示し、x
は実行可能なオペレーションを示します。
注意 : ls
コマンド プロパティ情報は、MBeanInfo
に基づいており、ユーザ パーミッションは反映されていません。
親 MBean に戻るには、cd('..')
コマンドを入力します。
wls:/mydomain/serverConfig/Servers/myserver/Log/myserver> cmo
[MBeanServerInvocationHandler]mydomain:Name=myserver,Server=myserver,Type=Log
wls:/mydomain/serverConfig/Servers/myserver/Log/myserver> cd('..')
wls:/mydomain/serverConfig/Servers/myserver/Log>
wls:/mydomain/serverConfig/Servers/myserver/Log> cmo
[MBeanServerInvocationHandler]mydomain:Name=myserver,Type=Server
親 MBean タイプに戻った後、WLST は cmo
を LogMBean
から ServerMBean
に変更します。
階層の深くにある MBean に移動した後でルート MBean に戻るには、cd('/')
コマンドを入力します。
コンフィグレーション情報と同様に、WebLogic Server 実行時 MBean は階層データ構造として配列されています。管理サーバに接続されているとき、serverRuntime
または domainRuntime
コマンドを入力して、実行時 MBean 階層にアクセスします。serverRuntime
コマンドにより、WLST はサーバの実行時管理オブジェクトのルート ServerRuntimeMBean
に置かれ、domainRuntime
コマンドは、ドメイン全体の実行時管理オブジェクトのルート DomainRuntimeMBean
に置かれます。管理対象サーバに接続されているとき、実行時 MBean のルートは ServerRuntimeMBean
です。ドメイン実行時 MBean 階層は、管理サーバ上のみに存在します。管理対象サーバに接続されているときに domainRuntime
コマンドは使用できません。
詳細については、『WebLogic Server® MBean リファレンス』の「ServerRuntimeMBean」および「DomainRuntimeMBean」を参照してください。
cd
コマンドの使用により、WLST は任意の実行時子 MBean に移動できます。実行時 MBean のナビゲーション モデルは、コンフィグレーション MBean のナビゲーション モデルと同じです。ただし、実行時 MBean は基底となる管理対象リソース (管理サーバ上のドメイン全体の実行時 MBean を除く) と同じサーバ インスタンスにのみ存在し、すべて編集不可です。
コード リスト 4-3 のコマンドは、管理サーバのインスタンスに接続してから移動し、サーバおよびドメイン実行時 MBean を表示するよう WLST に指示します。
wls:/(offline) > connect('username','password')
wls:/mydomain/serverConfig> serverRuntime()
Location changed to serverRuntime tree.This is a read-only tree with ServerRuntimeMBean as the root.
For more help, use help('serverRuntime')
wls:/mydomain/serverRuntime> ls()
dr-- ApplicationRuntimes
dr-- ClusterRuntime
dr-- ConnectorServiceRuntime
...
dr-- JDBCServiceRuntime
dr-- JMSRuntime
dr-- JTARuntime
dr-- JVMRuntime
dr-- LibraryRuntimes
dr-- MailSessionRuntimes
dr-- RequestClassRuntimes
dr-- ServerChannelRuntimes
dr-- ServerSecurityRuntime
dr-- ServerServices
dr-- ThreadPoolRuntime
dr-- WLDFAccessRuntime
dr-- WLDFRuntime
dr-- WTCRuntime
dr-- WorkManagerRuntimes
-r-- ActivationTime 1093958848908
-r-- AdminServer true
-r-- AdminServerHost
-r-- AdminServerListenPort 7001
-r-- AdminServerListenPortSecure false
-r-- AdministrationPort 9002
-r-- AdministrationPortEnabled false
...
wls:/mydomain/serverRuntime> domainRuntime()
Location changed to domainRuntime tree.This is a read-only tree with DomainRuntimeMBean as the root.
For more help, use help('domainRuntime')
wls:/mydomain/domainRuntime> ls()
dr-- DeployerRuntime
...
dr-- ServerLifecycleRuntimes
dr-- ServerRuntimes
-r-- ActivationTime Tue Aug 31 09:27:22 EDT 2004
-r-- Clusters null
-rw- CurrentClusterDeploymentTarget null
-rw- CurrentClusterDeploymentTimeout 0
-rw- Name mydomain
-rw- Parent null
-r-- Type DomainRuntime
-r-x lookupServerLifecycleRuntime javax.management.ObjectName
: java.lang.String
wls:/mydomain/domainRuntime>
コード リスト 4-4 のコマンドは、管理対象サーバ インスタンス上の実行時 MBean の移動と表示を WLST に指示します。
コード リスト 4-4 管理対象サーバ上の実行時 MBean の移動と表示
wls:/offline> connect('username','password',`t3://localhost:7701')
Connecting to weblogic server instance running at t3://localhost:7701 as username weblogic ...
Successfully connected to managed Server 'managed1' that belongs to domain 'mydomain'.
Warning: An insecure protocol was used to connect to the server.
To ensure on-the-wire security, the SSL port or Admin port should be used instead.
wls:/mydomain/serverConfig> serverRuntime()
wls:/mydomain/serverRuntime> ls()
dr-- ApplicationRuntimes
dr-- ClusterRuntime
...
dr-- JMSRuntime
dr-- JTARuntime
dr-- JVMRuntime
dr-- LibraryRuntimes
dr-- MailSessionRuntimes
dr-- RequestClassRuntimes
dr-- ServerChannelRuntimes
dr-- ServerSecurityRuntime
dr-- ThreadPoolRuntime
dr-- WLDFAccessRuntime
dr-- WLDFRuntime
dr-- WTCRuntime
dr-- WorkManagerRuntimes
-r-- ActivationTime 1093980388931
-r-- AdminServer false
-r-- AdminServerHost localhost
-r-- AdminServerListenPort 7001
-r-- AdminServerListenPortSecure false
-r-- AdministrationPort 9002
-r-- AdministrationPortEnabled false
...
wls:/mydomain/serverRuntime>
実行時階層からコンフィグレーション MBean に移動するには、serverConfig
または domainConfig
(管理サーバのみに接続している場合) コマンドを入力します。これにより、WLST は serverRuntime
または domainRuntime
コマンドを入力する直前の移動先のコンフィグレーション MBean に置かれます。
次のサンプルのコマンドでは、実行時 MBean 階層からコンフィグレーション MBean 階層に移動し、また戻ってくるよう WLST に指示しています。
wls:/mydomain/serverRuntime/JVMRuntime/managed1> serverConfig()
Location changed to serverConfig tree.This is a read-only tree with DomainMBean as the root.
For more help, use help('serverConfig')
wls:/mydomain/serverConfig> cd ('Servers/managed1')
wls:/mydomain/serverConfig/Servers/managed1> cd('Log/managed1')
wls:/mydomain/serverConfig/Servers/managed1/Log/managed1> serverRuntime()
wls:/mydomain/serverRuntime/JVMRuntime/managed1>
実行時 MBean 階層から再び serverConfig
コマンドを入力することで、WLST は直前の移動先のコンフィグレーション MBean に置かれます。
wls:/mydomain/serverRuntime/JVMRuntime/managed1> serverConfig()
wls:/mydomain/serverConfig/Servers/managed1/Log/managed1>
詳細については、「ツリー コマンド」を参照してください。
また、currentTree
コマンドを使用して現在の MBean 階層の場所を保存し、そこから別の場所に移動した後、再びそこに戻ることもできます。「currentTree」を参照してください。
wls:/mydomain/serverConfig/Servers/managed1/Log/managed1> myLocation = currentTree()
wls:/mydomain/serverConfig/Servers/managed1/Log/managed1> serverRuntime()
wls:/mydomain/serverRuntime> cd(`JVMRuntime/managed1')
wls:/mydomain/serverRuntime/JVMRuntime/managed1>myLocation()
wls:/mydomain/serverConfig/Servers/managed1/Log/managed1>
特定の MBean および属性を探すには、find
コマンドを使用します。WLST は、属性およびその値を格納する MBean へのパス名を返します。パスで指定された MBean に戻るには、getMBean
コマンドを使用します。詳細については、「find」および「getMBean」を参照してください。
wls:/mydomain/edit !>
find('logfilename')
/ApplicationRuntimes/myserver_wlnav.war/WebAppComponentRuntime/myserver_myserver_wlnav.war_wlnav_/wlnavLogFilename null
/Servers/myserver JDBCLogFileName jdbc.log
/Servers/myserver/WebServer/myserver LogFileName access.log
wls:/mydomain/edit !>
bean=getMBean('Servers/myserver/WebServer/myserver')
wls:/mydomain/edit !>
print bean
[MBeanServerInvocationHandler]mydomain:Name=myserver,Type=WebServer,Server=myserver
wls:/mydomain/edit !>
注意 : インスタンスが見つからない場合、getMBean
は例外を送出しません。
別の方法としては、getPath
コマンドが、指定した MBean インスタンスの MBean パス、または現在の MBean 階層内の MBean のための ObjectName
を返します。「getPath」を参照してください。
wls:/mydomain/serverConfig>
path=getPath('com.bea:Name=myserver,Type=Server')
wls:/mydomain/serverConfig>
print path
Servers/myserver
WebLogic Server には数百もの MBean が用意されており、それらの多くは、EJB、Web アプリケーション、およびその他のデプロイ可能な J2EE モジュールのコンフィグレーションとモニタに使用されます。アプリケーションまたはリソースのコンフィグレーションに追加の MBean を使用する場合は、管理サーバ上の MBean サーバのサブシステム内で、独自の MBean を作成して登録できます。
カスタム MBean の詳細については、『JMX によるカスタム管理ユーティリティの開発』の「カスタム MBean のインスツルメントと登録」を参照してください。
カスタム MBean を移動するには、WLST が管理サーバまたは管理対象サーバ インスタンスに接続されているときに、custom
コマンドを入力します。WebLogic Integration または WebLogic Portal サーバに接続されている場合、WLST はすべての WebLogic Integration または WebLogic Portal Server MBean と対話できます。WebLogic Server MBean 以外のものは、カスタム MBean として表示されます。
WLST は、コンフィグレーション MBean の場合と同様に、カスタム MBean を移動および照会してから編集します。ただし、カスタム MBean ではスタブが使用できないため、cmo
変数が使用できません。
カスタム MBean は編集できますが、WebLogic Server の変更管理プロセスの対象にはなりません。MBean の get および set メソッドを使用し、先に startEdit
コマンドを入力しなくても、それらに対してメソッドの呼び出し、作成、および削除を行えます。「コンフィグレーション MBean の編集」を参照してください。
カスタム MBean は、次の例に示すように、ドメインごとにリスト表示されます。
wls:/mydomain/serverConfig> custom()
Location changed to custom tree.This is a writable tree with No root.For more help, use help('custom')
wls:/mydomain/custom> ls()
drw- domain1
drw- domain2
drw- domain3
drw- domain4
wls:/mydomain/custom> cd("domain2")
wls:/mydomain/custom/domain2> ls()
drw- domain2:y1=x
drw- domain2:y2=x
wls:/mydomain/custom/domain2> cd("domain2:y1=x")
wls:/mydomain/custom/domain2/domain2:y1=x> ls()
-rw- MyAttribute 10
wls:/mydomain/custom/domain2/domain2:y1=x>
管理サーバ内では、ルートが DomainMBean
である単一の編集可能な階層内に、一連のコンフィグレーション MBean があります。この階層は、ドメイン内のすべてのコンフィグレーション MBean の編集可能なコピーが置かれており、変更管理プロセスの一部としてのみ使用されています。変更管理プロセスは、ドメイン内にコンフィグレーションの変更を配布するための制御された手順で、大まかにはデータベース トランザクションに似た変更プロセスです。
編集プロセスを開始するには、編集可能なコンフィグレーション階層でロックを取得して、他のユーザが変更を行えないようにします。変更が済んだら、変更内容を保存して、ドメイン内のすべてのサーバ インスタンスに配布します。変更が配布されると、各サーバでは、その変更を適用できるかどうかを判断します。すべてのサーバが変更を適用できる場合は、各サーバが動作中のコンフィグレーション MBean 階層を更新して、変更が完了します。
注意 : コンフィグレーション ロックでは、2 つのプロセスが同一ユーザ ID 下で編集セッションを開始することは回避できません。コンフィグレーション ロックの使用はお勧めしません。なぜなら、セッションの 1 つが変更をアクティブ化すると、そのセッションはロックを解放し、その他のセッションが、変更の保存またはアクティブ化を行えなくなるからです。
たとえば、WLST から編集セッションを開始し、同じユーザ名の下で Administration Console から同時に実行される別の編集セッションを開始した場合、WLST を使用して変更を保存およびアクティブ化すると、Administration Console で行っている編集内容が失われます。
コンフィグレーション変更の実行および管理に関する詳細については、『ドメインのコンフィグレーションについて』の「コンフィグレーションの変更管理のプロセス」および『JMX によるカスタム管理ユーティリティの開発』の「JMX を使用したドメインのコンフィグレーションの管理」を参照してください。
以下の基本的な手順では、WLST オンラインを使用してのコンフィグレーション編集プロセスについて説明します。
edit
コマンドを入力します。「edit」を参照してください。startEdit
コマンドは、save
コマンドを入力するまでリポジトリにコミットされない、バッチ変更の一部として扱われる変更を開始します。
startEdit
コマンドは、ドメイン コンフィグレーションを変更するコマンドを呼び出す前に、呼び出す必要があります。ただし、おそらくは Administration Console または別の WLST セッションを通じて開始された、同じユーザによる編集セッションが既に進行中であると WLST が検出した場合は、編集セッションが続行され、startEdit
コマンドを入力する必要はありません。startEdit
コマンドの引数の詳細については、「startEdit」を参照してください。
コンフィグレーションが無期限にロックされてしまう可能性をなくすため、タイムアウト期間を指定できます。または、管理者が cancelEdit
コマンドを入力して編集セッションを取り消し、ロックを解放することもできます。「cancelEdit」を参照してください。
コンフィグレーションの変更が進行中であることを示すため、WLST コマンド プロンプトの最後に感嘆符 (!) が表示されます。
validate
コマンドを使用して、変更を保存する前に、その内容が有効であることを確認します。「validate」を参照してください。
save
コマンドにより、変更が config.xml
ファイルの保留中のバージョンに保存されます。これによってロックが解放されることはありません。「save」を参照してください。
undo
コマンドは、保存されていない変更をすべて元に戻します。「undo」を参照してください。
activate
コマンドは、変更の配布を開始してロックを解放します。感嘆符はコマンド プロンプトから削除されます。「activate」を参照してください。
stopEdit
コマンドは、現在編集中のセッションを停止し、編集ロックを解放します。このコマンドを使うと、最後に save
コマンドを入力してからの変更がすべて破棄されます。「stopEdit」を参照してください。
cancelEdit
コマンドもまた、編集セッションを停止し、コンフィグレーション ロックを解放し、最後に save
を使ってからの変更を破棄します。しかし、このコマンドを入力するユーザは、現在の編集者である必要がありません。このため、管理者が編集セッションを取り消すことが可能です。「cancelEdit」を参照してください。
コード リスト 4-5の WLST オンライン スクリプトは、WLST を管理サーバに接続し、管理対象サーバを作成する編集セッションを開始してから変更を保存してアクティブ化します。さらに、別の編集セッションを開始してから起動クラスを作成し、新しく作成されたサーバにそれを対象指定します。
このスクリプトを実行する前に、WebLogic Server を起動します。「スクリプトの実行」を参照してください。
connect("username
","password
")
edit()
startEdit()
svr = cmo.createServer("managedServer")
svr.setListenPort(8001)
svr.setListenAddress("my-address")
save()
activate(block="true")
startEdit()
sc = cmo.createStartupClass("my-startupClass")
sc.setClassName("com.bea.foo.bar")
sc.setArguments("foo bar")
# サーバ MBean を取得して対象指定する
tBean = getMBean("Servers/managedServer")
if tBean != None:
print "Found our target"
sc.addTarget(tBean)
save()
activate(block="true")
disconnect()
exit()
先に edit
コマンドを入力することなく変更を加えようとすると、WLST は変更に対してコンフィグレーションをロックしていないことを示すメッセージを表示し、ユーザがコンフィグレーションをロックする機会を提供します。startEdit
コマンド入力後に save
を呼び出し忘れたまま、スクリプト シェルを終了しようとした場合は、未処理のコミットされていない変更に関して警告が発せられます。その時点で、コンフィグレーションに対して加えたすべての変更をコミットまたは破棄できます。
MBean 属性に加えた変更がサーバの再起動を必要とするかどうかを判断するには、isRestartRequired
コマンドを入力します。変更をアクティブ化する前に、編集セッション中にこのコマンドを入力すると、サーバの再起動を必要とする進行中の属性変更が表示されます。変更をアクティブ化した後にこのコマンドを入力すると、発生した属性変更でサーバの再起動を必要とするものが表示されます。「isRestartRequired」を参照してください。
WebLogic Server では、変更プロセスを管理するためのコンフィグレーション マネージャが用意されています。getConfigManager
関数は、ConfigurationManagerMBean
を返します (「getConfigManager」を参照)。ConfigurationManagerMBean
は、編集セッションの開始および停止、コンフィグレーションに対する変更の保存、取り消し、およびアクティブ化を行うためのメソッドを提供しています。ConfigurationManagerMBean
メソッドを使用して、ドメイン内のコンフィグレーションの変更を管理できます。詳細については、『WebLogic Server® MBean リファレンス』の「ConfigurationManagerMBean」を参照してください。
コード リスト 4-6 の WLST オンライン スクリプトは、管理者として WLST をサーバ インスタンスに接続し、現在編集を行っているのが特定のオペレータであるかどうかを確認し、その後コンフィグレーションの編集を取り消します。このスクリプトはまた、完了したすべてのアクティベーション タスクを削除します。
このスクリプトを実行する前に、WebLogic Server を起動します。「スクリプトの実行」を参照してください。
コード リスト 4-6 コンフィグレーション マネージャの使用
connect("theAdministrator","weblogic")
cmgr = getConfigManager()
user = cmgr.getCurrentEditor()
if user == "operatorSam":
cmgr.undo()
cmgr.cancelEdit()
cmgr.purgeCompletedActivationTasks()
WLST によって開始されたすべての変更について、showChanges
コマンドを使用できます。このコマンドは、サーバによって暗黙的に実行された MBean オペレーションを含めて、編集セッションの開始以降、現在のコンフィグレーショに対して行ったすべての変更を表示します。コード リスト 4-7 を参照してください。
このスクリプトを実行する前に、WebLogic Server を起動します。「スクリプトの実行」を参照してください。
wls:/offline> connect('username','password')
wls:/mydomain/serverConfig> edit()
wls:/mydomain/edit> startEdit()
Starting an edit session ...
wls:/mydomain/edit !> cmo.createServer('managed2')
[MBeanServerInvocationHandler]mydomain:Name=managed2,Type=Server
wls:/mydomain/edit !>cd('Servers/managed2')
wls:/mydomain/edit/Servers/managed2 !> cmo.setListenPort(7702)
wls:/mydomain/edit/Servers/managed2 !> showChanges()
Changes that are in memory and saved to disc but not yet activated are:
MBean Changed : mydomain:Name=mydomain,Type=Domain
Operation Invoked : add
Attribute Modified : Servers
Attributes Old Value : null
Attributes New Value : managed2
Server Restart Required : false
MBean Changed : mydomain:Name=managed2,Type=Server
Operation Invoked : modify
Attribute Modified : StagingDirectoryName
Attributes Old Value : null
Attributes New Value : .\managed2\stage
Server Restart Required : true
MBean Changed : mydomain:Name=managed2,Type=Server
Operation Invoked : modify
Attribute Modified : Name
Attributes Old Value : null
Attributes New Value : managed2
Server Restart Required : true
MBean Changed : mydomain:Name=managed2,Type=Server
Operation Invoked : modify
Attribute Modified : ListenPort
Attributes Old Value : null
Attributes New Value : 7702
Server Restart Required : false
wls:/mydomain/edit/Servers/managed2 !> save()
wls:/mydomain/edit !> activate()
Started the activation of all your changes.
The edit lock associated with this edit session is released once the activation is successful.
The Activation task for your changes is assigned to the variable 'activationTask'
You can call the getUser() or getStatusByServer() methods on this variable to determine the status of your activation
[MBeanServerInvocationHandler]mydomain:Type=ActivationTask
wls:/mydomain/edit/Servers/managed2>
getActivationTask
関数は、アクティブ化のリクエストに関する情報を提供し、ユーザが現在行っている、または最近行った変更の状態が反映された、最新の ActivationTaskMBean
を返します。このインタフェースが提供するメソッドを呼び出すことで、進行中または完了されたばかりの最新のアクティブ化タスクに関する情報が取得されます。詳細については、『WebLogic Server® MBean リファレンス』の「ActivationTaskMBean」を参照してください。
コード リスト 4-8 の WLST オンライン スクリプトは、管理者として WLST をサーバ インスタンスに接続し、アクティブ化タスクを取得し、そのタスクのユーザとステータスを出力します。また、行われたすべての変更も出力します。
このスクリプトを実行する前に、WebLogic Server を起動します。「スクリプトの実行」を参照してください。
connect("theAdministrator","weblogic")
at = getActivationTask()
print "The user for this Task "+at.getUser()+" and the state is "+at.getState()
changes = at.getChanges()
for i in changes:
i.toString()
![]() ![]() |
![]() |
![]() |