スクリプトを使用したサーバー・ライフサイクルの管理
Pre-General Availability: 2024-10-11
The following legal notice applies to Oracle pre-GA releases.著作権およびその他の適用される法律に関する情報は、Oracleの法律上の注意点を参照してください。
Pre-General Availability Draft Documentation Notice
このドキュメントはPre-General Availability (一般提供前)版であり、デモおよび暫定使用のみを目的としたものです。このソフトウェアを使用するハードウェアに限定するものではありません。Oracle Corporationおよびその関連会社は、このドキュメントに関して一切の責任を負わず、いかなる保証もいたしません。また、このドキュメントを使用したことによって損失、費用、あるいは損害が発生しても、一切の責任を負いかねます。
ドメインでノード・マネージャを使用してサーバーを起動および停止しない場合は、WebLogicからデフォルトのサーバー起動/停止スクリプトを使用するか、ラッパー・スクリプトを使用してWebLogic Scripting Tool (WLST)を起動できます。
カスタム・スクリプトを使用するためのベスト・プラクティス
必要に応じてカスタム・スクリプトを使用しないでください。ただし、カスタム・スクリプトを使用してサーバー制御のライフサイクルを管理する必要がある場合は、次の推奨プラクティスを確認してください。
stdin
またはスクリプト・パラメータから入力を読み取らないでください。WebLogic管理者は管理対象サーバー・スクリプトのサーバー名を送信しますが、管理サーバーには何も送信されません。- 各ステップでエラー条件を処理します。これにより、WebLogic管理で障害を効率的に処理できます。
startWebLogic.sh
などのスクリプトは、適切な終了基準なしで起動しないでください。このようなスクリプトをコールしてもコール元は終了しません。startWebLogic.sh
スクリプトはサーバーを起動し、サーバー・プロセスが停止するまで戻りません。これにより、WebLogic管理プラグインがレスポンスの待機中にハングします。WebLogic管理は、スクリプトの起動による待機を回避しますが、常にカスタム・スクリプトを正常に終了することをお薦めします。- ドメインでノード・マネージャを使用する場合は、WLSTを使用して操作を実行し、シェル・スクリプト(Linux)またはバッチ・ファイル(Windows)からWLSTスクリプトを起動します。
- 管理サーバーの所要時間が5分を超える場合は、
/usr/libexec/oracle-cloud-agent/plugins/oci-wlms/_internal/wls_actions/wlst/properties.json
のプロパティを調整して、環境に最適な値を指定します。たとえば:"wls_max_retries": 10, (The number of times to poll for the admin server to check if the admin port is opened) "wls_sleep_interval": 30 (The polling interval)
WebLogicからのデフォルトのサーバー起動/停止スクリプトの使用
管理サーバーにはstartWebLogic.sh/cmd
およびstopWebLogic.sh/cmd
を使用し、管理対象サーバーにはstartManagedWebLogic.sh/cmd
およびstopManagedWebLogic.sh/cmd
を使用します。これらのスクリプトを使用するように、WebLogic管理でドメイン設定を構成します。「パッチ適用およびサーバー制御の構成」を参照してください。
構成後、WebLogic管理は、サーバー名をパラメータとして渡すことで、パラメータおよびstop/start ManagedWebLogic.sh
スクリプトなしでstopWebLogic.sh
を起動します。
これらのスクリプトを使用する場合、WebLogic管理では、管理対象サーバーの起動または停止のステータスをモニターまたはポーリングしません。これにより、サーバーが正常に停止または起動されていなくても、ライフサイクル操作が正常にレポートされる可能性があります。
ラッパー・スクリプトを使用したWLSTの起動
WLSTを使用して管理サーバーに接続し、管理サーバー接続を使用してサーバーを管理します。WLSTスクリプトは、WebLogic管理の起動および停止スクリプト設定で使用されるラッパー・シェル・スクリプトによって起動されます。次に、サンプル・ラッパー・スクリプトを示します。
管理サーバーの停止:
# stop Admin script
import sys
wls_user = <weblogic-admin-user-name>
wls_password = <weblogic-admin-password>
admin_url = <admin_url>
try:
connect(wls_user, wls_password, admin_url)
except Exception, e:
# Handle exception here and identify if the server is running
if "Error getting the initial context. There is no server running at" in str(e):
# This error means, there is no server running. So nothing to stop
sys.exit(0)
else:
sys.exit(1)
# We are connected. now shutdown the server
try:
shutdown()
sys.exit(0)
except:
# Failed to shutdown. Exit with non-zero
sys.exit(3)
管理停止操作を起動するシェル・スクリプト:
#!/bin/bash
# $MW_HOME - The path to the MW_HOME
$MW_HOME/oracle_common/common/bin/wlst.sh <stop-admin-python script>
管理サーバーを起動するには、
startWebLogic.sh
スクリプトをポートのWebLogic管理ポーリングとして指定して、管理サーバーが正常に起動されたかどうかを判断します。管理対象サーバーの起動:
# start managed server
import sys
managed_server_name = sys.argv[1]
wls_user = <weblogic-admin-user-name>
wls_password = <weblogic-admin-password>
admin_url = <admin_url>
# connect to the admin server and then start the managed server
try:
connect(wls_user, wls_password, admin_url)
except Exception, e:
# We cannot connect to admin and hence we cannot start the managed server
sys.exit(1)
# We are connected. now start the server
try:
start(managed_server_name)
sys.exit(0)
except:
# Failed to start server. Exit with non-zero
sys.exit(2)
管理対象サーバーの起動/停止操作を呼び出すスクリプト:
#!/bin/bash
# $MW_HOME - The path to the MW_HOME
SERVER_NAME=$1
$MW_HOME/oracle_common/common/bin/wlst.sh <stop/start-managedserver-python script> $SERVER_NAME