當您將成員伺服器加入至群體時,您可以使用群體 join 指令的 genDeployVariables 選項,來配置部署變數(埠)。
genDeployVariables 選項會將部署變數登錄到群體儲存庫,並將部署變數產生到成員的 $WLP_USER_DIR/servers/server_name/configDropins/overrides/deployVariables.xml 檔。
程序
- 在群體控制器 server.xml 檔中指定部署變數。
針對您想配置的每一個埠,將 deployVariable 元素新增至控制器 server.xml 檔。deployVariable
通常會指定部署變數的名稱、起始埠值,以及埠值的增量。
<featureManager>
<feature>servlet-3.0</feature>
<feature>collectiveController-1.0</feature>
</featureManager>
<deployVariable name="PortBase1" value="7000" increment="20"/>
<deployVariable name="PortBase2" value="8000" increment="20"/>
- 針對您想加入至群體成為成員的伺服器,在其 server.xml 檔中,指定使用部署變數的埠值。
下列 defaultHttpEndpoint 元素顯示範例埠值,這些埠值會使用要加入至群體之伺服器 server.xml 檔中的部署變數:
<defaultHttpEndpoint id="httpEndpoint"
host="*"
httpPort="${PortBase1}"
httpsPort="${PortBase1}+1"
httpPort="${PortBase2}"
httpsPort="${PortBase2}+1" />
- 執行含有 genDeployVariables 選項的群體 join 指令。
wlp/bin/collective join memberName --host=controllerHost --port=controllerHTTPSPort
--user=controllerAdminUser --password=controllerAdminUserPassword
--keystorePassword=memberKeystorePassword --genDeployVariables
結果
這個指令會將伺服器加入至群體成為成員,將部署變數登錄到群體儲存庫,以及將部署變數產生到成員的
$WLP_USER_DIR/servers/serverName/configDropins/overrides/deployVariables.xml 檔中。產生的檔案含有範例值的下列部署變數:
<server>
<variable name="PortBase1" value="7000"/>
<variable name="PortBase2" value="8000"/>
</server>