配置 Liberty 集合体
可以将 Liberty 服务器组织成集合体以支持对多个 Liberty 服务器执行建立集群、管理及其他操作。通过使用集合体,可以高效而准确地为应用程序提供应用程序服务。
开始之前
使用管理功能部件安装 Liberty。有关安装指示信息,请参阅使用集合体来为 Liberty 设置服务器管理环境的“准备工作”部分。Liberty 管理功能部件提供用于集合体、集群、缩放、动态路由选择和管理中心的多服务器管理功能部件。
collectiveController-1.0 功能部件及其功能仅在 WebSphere® Application Server Network Deployment Liberty 和 WebSphere Application Server for z/OS® Liberty 中可用。该功能部件在 WebSphere Application Server
Liberty 或 WebSphere Application Server Liberty Core 中不可用。如果已安装 WebSphere Application Server Network Deployment Liberty,那么可使用其 collectiveController-1.0 功能部件处理 WebSphere Application Server
Liberty 或 WebSphere Application Server Liberty Core 安装中的集合体成员。
关于此任务
Liberty 集合体是一组 Liberty 服务器,配置为同一个管理与运营域的一部分。
有关 Liberty 集合体的配置和状态数据保存在活动的运作存储库中。
Liberty 集合体中的成员资格可选。Liberty 服务器通过向集合体控制器注册成为成员,从而加入集合体。成员通过控制器的运作存储库来共享有关它们自己的信息。
- Liberty 服务器只能是一个集合体的成员。
- 同一个主机上的不同 Liberty 服务器可以位于不同集合体中。
- 同一个主机上作为集合体成员的 Liberty 服务器可与不是集合体成员的 Liberty 服务器共存。
- 集合体的所有成员必须位于相同数据中心中。一个集合体不得跨多个数据中心。
观看:
视频:创建集合体的简介演示了此过程。WASdev Web 站点上提供了此视频和有关集合体的其他信息。[抄本]
过程
- 创建和配置控制器。
- 创建要用作集合体控制器的服务器。
wlp/bin/server create myController
- 创建集合体控制器配置。
集合体控制器配置主要由用来在控制器和成员之间进行安全通信的管理域安全性配置组成。
wlp/bin/collective create myController --keystorePassword=controllerKSPassword
缺省情况下,此 collective 命令将所有输出写至控制台屏幕。在下一步中,将配置输出复制到 server.xml。要将配置写入文件而不是控制台屏幕,请指定 --createConfigFile=outputFilePath 参数,例如:
运行 create 命令后,将显示要使用的 include 语句。要在集合体配置中包含所输出文件,请将 include 语句添加至 server.xml 文件,如以下示例中所示:wlp/bin/collective create myController --keystorePassword=controllerKSPassword --createConfigFile=c:/wlp/usr/servers/myController/collective-create-include.xml
<include location="c:\wlp\usr\servers\myController\collective-create-include.xml" />
- 更新集合体控制器的 server.xml 文件。
- 复制并粘贴输出。
如果此命令将输出写至控制台屏幕,请继续执行以下步骤。
- 将 collective 命令的输出复制并粘贴到 server.xml 文件中。
- 对集合体指定管理用户标识和密码值。例如,将
更改为:<quickStartSecurity userName="" userPassword="" />
<quickStartSecurity userName="adminUser" userPassword="adminPassword" />
集合体控制器 server.xml 文件的缺省路径为 ${wlp.install.dir}/usr/servers/myController/server.xml,如果在 server.env 文件或命令窗口中设置了 $WLP_USER_DIR 变量,那么缺省路径为 $WLP_USER_DIR/servers/myController/server.xml。编辑后,文件类似以下示例:<server description="controller server"> <!-- Enable features --> <featureManager> <feature>jsp-2.2</feature> </featureManager> <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443" /> <featureManager> <feature>collectiveController-1.0</feature> </featureManager> <!-- Define the host name for use by the collective. If the host name needs to be changed, the server should be removed from the collective and re-joined or re-replicated. --> <variable name="defaultHostName" value="controllerHostname" /> <!-- TODO: Set the security configuration for Administrative access --> <quickStartSecurity userName="adminUser" userPassword="adminPassword" /> <!-- clientAuthenticationSupported set to enable bidirectional trust --> <ssl id="defaultSSLConfig" keyStoreRef="defaultKeyStore" trustStoreRef="defaultTrustStore" clientAuthenticationSupported="true" /> <!-- inbound (HTTPS) keystore --> <keyStore id="defaultKeyStore" password="yourPassword" location="${server.config.dir}/resources/security/key.jks" /> <!-- inbound (HTTPS) truststore --> <keyStore id="defaultTrustStore" password="yourPassword" location="${server.config.dir}/resources/security/trust.jks" /> <!-- server identity keystore --> <keyStore id="serverIdentity" password="yourPassword" location="${server.config.dir}/resources/collective/serverIdentity.jks" /> <!-- collective trust keystore --> <keyStore id="collectiveTrust" password="yourPassword" location="${server.config.dir}/resources/collective/collectiveTrust.jks" /> <!-- collective root signers keystore --> <keyStore id="collectiveRootKeys" password="yourPassword" location="${server.config.dir}/resources/collective/rootKeys.jks" /> </server>
- 添加 include 语句。如果已使用 --createConfigFile=outputFilePath 参数将输出写至文件,请将 include 语句添加至 $WLP_USER_DIR/servers/myController/server.xml 以在集合体配置中包含所输出文件。编辑后,文件的内容类似以下示例:
<server description="controller server"> <!-- Enable features --> <featureManager> <feature>jsp-2.2</feature> </featureManager> <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443" /> <include location="c:\wlp\usr\servers\myController\collective-create-include.xml" /> </server>
确保所输出文件对集合体设置了管理用户标识和密码值,如以下示例中所示:<quickStartSecurity userName="adminUser" userPassword="adminPassword" />
- 复制并粘贴输出。
- 启动集合体控制器服务器。
wlp/bin/server start myController
图 1. 集合体 1 - 验证集合体控制器服务器是否正确启动及其是否准备好接收成员。
- 使用编辑器打开集合体控制器消息日志 $WLP_USER_DIR/servers/myController/logs/messages.log。
- 查找以下消息:
CWWKX9003I: CollectiveRegistration MBean 可用。
- 创建要用作集合体控制器的服务器。
- 创建并配置成员以加入集合体。
控制器和成员可以在不同主机上。在此示例中,控制器和成员在相同主机上。
- 创建成员服务器。
wlp/bin/server create myMember
- 加入该成员。
运行 collective join 命令以使该服务器加入集合体成为其成员。在成员主机上从 Liberty 安装运行 join 命令。
join 命令需要与集合体控制器的网络连接及管理用户标识和密码以对控制器执行 MBean 操作。查看集合体控制器的 server.xml 文件,以查找 --host、--port、--user 和 --password 参数的值。对于 --keystorePassword,设置要用于成员密钥库密码的值,例如,memberKSPassword。可对加入集合体的每个服务器指定不同 --keystorePassword 值。
wlp/bin/collective join myMember --host=controllerHostname --port=9443 --user=adminUser --password=adminPassword --keystorePassword=memberKSPassword
可选参数 --hostname 指定要用于系统的主机名。仅当系统具有多个主机名或未配置主机名时,才设置 --hostname。如果设置此项,那么值必须与 server.xml 文件中定义的 defaultHostName 变量匹配。
要减少所需的选项数目,请使用 --controller 选项,而不是 --user、--password、--host 和 --port。
wlp/bin/collective join myMember --controller=user[:password]@host:HttpsPort --keystorePassword=memberKSPassword
您可以通过使用可选参数 genDeployVariable 指定部署变量。有关更多信息,请参阅使成员服务器加入集合体时生成部署变量。
要将此集合体命令的输出写至文件,而不是控制台屏幕,请指定可选 --createConfigFile=outputFilePath 参数。然后,通过将 include 语句添加至成员 server.xml 文件以在集合体配置中包含所输出文件:<include location=outputFilePath />
缺省情况下,join 操作保留远程过程调用 (RPC) 凭证为未定义状态。必须对 rpcUser 和 rpcUserPassword 指定值,并对成员服务器所在的主机指定操作系统登录用户和密码。 如果成员主机已向集合体控制器注册并且成员主机不支持 SSH,请指定可选 --useHostCredentials 参数以使该成员能够从它在控制器上的主机注册继承 RPC 凭证。通常,Linux 主机支持 SSH,而 Windows 主机不支持 SSH;因此,--useHostCredentials 参数对 Windows 成员主机很有用。指定 --useHostCredentials 会将 <hostAuthInfo useHostCredentials="true" /> 添加至成员 server.xml 文件。然后,您可在不指定 RPC 凭证的情况下运行集合体成员服务器命令(例如,start 或 stop),因为成员从其主机继承凭证。有关 hostAuthInfo、--useHostCredentials 参数及将集合体控制器连接至服务器的信息,请参阅覆盖 Liberty 服务器主机信息。请参阅设置 RXA 以执行 Liberty 集合体操作,以获取有关在主机上启用 SSH 的信息。
要获取有关这些必需参数和其他可选参数的信息,请在命令行运行 collective help join。
- 如果系统提示您接受证书链,请输入 y(是)。
- 更新成员 server.xml 文件。
- 复制并粘贴输出。
如果此命令将输出写至控制台屏幕,请继续执行以下步骤:
- 从集合体命令复制输出并将其粘贴至成员 server.xml 文件。
- 修改端口,以便服务器可以打开其 HTTP 端口。确保成员 server.xml 在其主机上设置独有 HTTP 端口号。例如,如果该成员与集合体控制器在同一主机上,请更改 HTTP 端口号:
(可选)要从远程客户机访问成员服务器,也应在 httpEndpoint 元素中设置 host="*"。<httpEndpoint id="defaultHttpEndpoint" httpPort="9081" httpsPort="9444" />
编辑后,文件 $WLP_USER_DIR/servers/myMember/server.xml 类似以下示例:<server description="member server"> <!-- Enable features --> <featureManager> <feature>jsp-2.2</feature> </featureManager> <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9081" httpsPort="9444" /> <featureManager> <feature>collectiveMember-1.0</feature> </featureManager> <!-- Define the host name for use by the collective. If the host name needs to be changed, the server should be removed from the collective and re-joined or re-replicated. --> <variable name="defaultHostName" value="memberHostname" /> <!-- Remote host authentication configuration --> <hostAuthInfo rpcUser="admin_user_id" rpcUserPassword="admin_user_password" /> <!-- Connection to the collective controller --> <collectiveMember controllerHost="controllerHostname" controllerPort="9443" /> <!-- clientAuthenticationSupported set to enable bidirectional trust --> <ssl id="defaultSSLConfig" keyStoreRef="defaultKeyStore" trustStoreRef="defaultTrustStore" clientAuthenticationSupported="true" /> <!-- inbound (HTTPS) keystore --> <keyStore id="defaultKeyStore" password="yourPassword" location="${server.config.dir}/resources/security/key.jks" /> <!-- inbound (HTTPS) truststore --> <keyStore id="defaultTrustStore" password="yourPassword" location="${server.config.dir}/resources/security/trust.jks" /> <!-- server identity keystore --> <keyStore id="serverIdentity" password="yourPassword" location="${server.config.dir}/resources/collective/serverIdentity.jks" /> <!-- collective truststore --> <keyStore id="collectiveTrust" password="yourPassword" location="${server.config.dir}/resources/collective/collectiveTrust.jks" /> </server>
- 添加 include 语句。如果已使用 --createConfigFile=outputFilePath 参数将输出写至文件,请将 include 语句添加至 $WLP_USER_DIR/servers/myMember/server.xml 以包含所输出文件,如以下示例中所示:
<server description="member server"> <!-- Enable features --> <featureManager> <feature>jsp-2.2</feature> </featureManager> <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9081" httpsPort="9444" /> <include location="c:\wlp\usr\servers\myMember\collective-join-include.xml" /> </server>
- 复制并粘贴输出。
- 如果未在 join 命令中指定 --useHostCredentials 并且成员主机不支持 SSH,请在成员 server.xml 文件或所输出文件中对 hostAuthInfo 设置 RPC 凭证。 可通过下列两者中的任何一种方式对成员服务器设置 RPC 凭证:
- 设置 hostAuthInfo RPC 用户和密码值。将 rpcUser 设置为在成员服务器所在的主机的操作系统登录用户标识,并将 rpcUserPassword 设置为该用户标识的操作系统登录密码。例如,如果使用用户
test1 和密码 test1pwd 登录成员计算机,请将 hostAuthInfo 元素更改为以下内容:
<hostAuthInfo rpcUser="test1" rpcUserPassword="test1pwd" />
- 如果已向集合体控制器注册成员主机,请将 hostAuthInfo useHostCredentials 设置为 true 以便该成员服务器从其主机继承 RPC 凭证。
<hostAuthInfo useHostCredentials="true" />
有关 hostAuthInfo 设置的信息及说明如何注册成员主机并运行带 --useHostCredentials 的 join 命令的示例,请参阅覆盖 Liberty 服务器主机信息。
- 设置 hostAuthInfo RPC 用户和密码值。将 rpcUser 设置为在成员服务器所在的主机的操作系统登录用户标识,并将 rpcUserPassword 设置为该用户标识的操作系统登录密码。例如,如果使用用户
test1 和密码 test1pwd 登录成员计算机,请将 hostAuthInfo 元素更改为以下内容:
(仅限 z/OS)发出 updateHost 命令,以指定控制器的成员 JAVA_HOME 目录。
wlp/bin/collective updateHost controllerHostname --host=controllerHostname --port=9443 --user=adminUser --password=adminPassword --hostWritePath=/dir1 --rpcUser=rpcUser --rpcUserPassword=rpcUserPassword --hostJavaHome=JAVA_HOME
要减少所需的选项数目,请使用 --controller 选项,而不是 --user、--password、--host 和 --port:
wlp/bin/collective updateHost controllerHostname --controller=adminUser:adminPassword@controllerHostname:9443 --hostWritePath=/dir1 --rpcUser=rpcUser --rpcUserPassword=rpcUserPassword --hostJavaHome=JAVA_HOME
hostWritePath 参数指定集合体控制器可写入的目录。此参数所指定的路径还是可读的。
hostWritePathhostJavaHome 参数指定系统上 JVM 的绝对路径(成员服务器在此路径中运行),例如 /usr/lpp/java/java_1.7_64。
有关指定 JAVA_HOME 的更多信息,请参阅为 Liberty 集合体成员和控制器设置 JAVA_HOME 变量。
- 启动成员服务器。
wlp/bin/server start myMember
图 2. 简单集合体 - 请验证成员服务器是否已正确启动并正向控制器发布信息。
- 使用编辑器打开成员消息日志 $WLP_USER_DIR/servers/myMember/logs/messages.log。
- 按任意顺序查找以下消息:
CWWKX8112I: 服务器的主机信息已成功发布至集合体存储库。CWWKX8114I: 服务器的路径已成功发布至集合体存储库。CWWKX8116I: 服务器已启动状态已成功发布至集合体存储库。
- 可选:
使用 testConnection 命令验证连接。 此命令将验证控制器与成员所在的主机之间的 RXA 连接。另外,它还验证集合体控制器与集合体成员之间的 JMX 安全连接。
其中,hostName,usrDirPath,serverName 是用于描述刚刚加入的成员服务器的元组,hostName 是集合体成员所在的主机的名称。userDirPath 是集合体成员的 usr 目录。serverName 是集合体成员的名称。wlp/bin/collective testConnection hostName,usrDirPath,serverName --host=controllerHost --port=controllerHTTPSPort --user=controllerAdmin --password=controllerAdminPassword--autoAcceptCertificates
或者,可使用简化的 --controller 选项来提供特定于控制器的信息。
wlp/bin/collective testConnection hostName,usrDirPath,serverName --controller=user[:password]@host:HttpsPort --autoAcceptCertificates
- 创建成员服务器。
子主题
- 使用开发者工具配置 Liberty 集合体
通过使用开发者工具中 Liberty 的实用程序菜单,可以创建集合体控制器或加入集合体。 - 使成员服务器加入集合体时生成部署变量
使成员服务器加入集合体时,您可以使用 collective join 命令的 genDeployVariables 选项来分配部署变量(端口)。

文件名:tagt_wlp_configure_collective.html