この章では、サーバー・テンプレートについて説明します。
この章には次の項が含まれます:
サーバー・テンプレートを使用すると、様々なサーバー・インスタンスに適用できる共通の非デフォルト属性を定義できます。サーバー・テンプレートには共通の属性が含まれているため、1箇所で属性の変更を行えば、その変更がサーバー・テンプレートを使用するすべてのサーバー・インスタンスに反映されます。サーバー・インスタンスに共通の属性セットがある異機種間サーバー環境でサーバー・テンプレートを使用しますが、サーバー固有の属性セットはサーバー・インスタンスごとに一意である必要があります。
サーバー・テンプレートは、主に、動的クラスタの作成に使用されます。『Oracle WebLogic Serverクラスタの管理』の動的クラスタの作成に関する項を参照してください。
この項では、サーバー・テンプレートの構成方法について説明します。内容は次のとおりです。
管理コンソールを使用したサーバー・テンプレートの作成については、Oracle WebLogic Server管理コンソール・オンライン・ヘルプのサーバー・テンプレートの作成に関する項を参照してください。
サーバー・テンプレートを定義する場合は、サーバー・インスタンスのグループに対して共通属性を指定します。サーバー・インスタンスごとに、サーバー構成の基準となるサーバー・テンプレートを指定します。必要に応じて、サーバー・テンプレートで定義した属性値をサーバー・インスタンスに直接オーバーライドできます。
WebLogic Serverでは、次のように属性値を決定します。
テンプレートまたは個々のサーバー構成のいずれかでオーバーライドされないかぎり、構成要素属性のデフォルト値が返されます。
テンプレートに設定された値により、デフォルト値がオーバーライドされます。そのため、サーバー・テンプレートに値が設定されている場合は、その値が返されます。
個々のサーバー構成で設定された値により、デフォルト値とテンプレートに設定された値がオーバーライドされます。個々のサーバー構成要素に値が設定されている場合は、その値が返されます。
注意: 個々のサーバー・レベルで値を設定した後は、テンプレート値の設定に戻しても、この値をオーバーライドできなくなります。ただし、 |
サーバー・テンプレート内のどの文字列属性に対してもマクロを定義できます。マクロは、整数値、または他の構成要素の参照には使用できません。サーバー・テンプレートで使用可能な有効なマクロは次のとおりです。
${id}
: 動的に作成されたサーバーのインスタンスID。このIDは1から始まります。
${serverName}
: この要素が属するサーバー名。
${clusterName}
: この要素が属するクラスタ名。
${domainName}
: この要素が属するドメイン名。
${system-property-name}
: これが、前述の事前定義済マクロ名ではない場合、システム・プロパティとして評価され、その値が返されます。システム・プロパティが存在しない場合は、空の文字列が代入されます。
この項では、共通属性を持つ2つのサーバー・インスタンスをサーバー・テンプレートを使用して作成する方法について説明します。
サーバー・テンプレートを作成して、my-cluster-server-template
という名前を付けます。
my-cluster-server-template
のすべての共通属性を設定します。
サーバー・インスタンスmy-server1
およびmy-server2
を作成し、各インスタンスにmy-cluster-server-template
を割り当てます。
サーバー固有の属性を設定します。
次に、WLSTを使用して、サーバー・テンプレートで2つのサーバー・インスタンスを作成する例を示します。この例にはインライン・コメントが含まれています。
# # This example demonstrates the WLST commands needed to create a server template # (my-cluster-server-template) and server instances (my-server-1, my-server-2) # that utilize that server template. The creation of the cluster (my-cluster) and # machines (PrimaryMachine, SecondaryMachine) are not included in this example - # they must have been created before running this script. To keep this example # simple, error handling has been omitted. # connect() edit() startEdit() # # create the server template and set the common attributes that are used in all # servers. Attributes such as Accept Backlog, Auto Restart, etc. are the same # across all cluster members. # serverTemplate=cmo.createServerTemplate("my-cluster-server-template") serverTemplate.setAcceptBacklog(2000) serverTemplate.setAutoRestart(true) serverTemplate.setRestartMax(10) serverTemplate.setReverseDNSAllowed(true) serverTemplate.setStagingMode("external_stage") serverTemplate.setStartupTimeout(600) myCluster=cmo.lookupCluster("my-cluster") serverTemplate.setCluster(myCluster) # # create the individual server instances, set the server specific attributes, and # set the template so the server uses the common attributes from the template. # Attributes such as cluster weight, listen port, and machine are server specific # so they are not included in the server template. # server1=cmo.createServer("my-server-1") server1.setClusterWeight(70) server1.setListenPort(7010) primary=cmo.lookupMachine("PrimaryMachine") server1.setMachine(primary) server1.setServerTemplate(serverTemplate) # server2=cmo.createServer("my-server-2") server2.setClusterWeight(90) server2.setListenPort(7020) secondary=cmo.lookupMachine("SecondaryMachine") server2.setMachine(secondary) server2.setServerTemplate(serverTemplate) # # activate the changes # activate()
作成したconfig.xml
は次のとおりです。
<server> <name>my-server-1</name> <cluster-weight>70</cluster-weight> <listen-port>7010</listen-port> <machine>PrimaryMachine</machine> <server-template>my-cluster-server-template</server-template> </server> <server> <name>my-server-2</name> <cluster-weight>90</cluster-weight> <listen-port>7020</listen-port> <machine>SecondaryMachine</machine> <server-template>my-cluster-server-template</server-template> </server> <server-template> <name>my-cluster-server-template</name> <accept-backlog>2000</accept-backlog> <auto-restart>true</auto-restart> <cluster>my-cluster</cluster> <restart-max>10</restart-max> <reverse-dns-allowed>true</reverse-dns-allowed> <staging-mode>external_stage</staging-mode> <startup-timeout>600</startup-timeout> </server-template>