6.3. 连接在 OpenShift 上运行的 Hot Rod 客户端


使用在与 Data Grid 集群相同的 OpenShift 集群上运行的 Hot Rod 客户端访问远程缓存。

先决条件

  • 检索网络服务详细信息。

流程

  1. 在客户端配置中为您的 Data Grid 集群指定内部网络服务详情。

    在以下配置示例中,$SERVICE_HOSTNAME:$PORT 表示允许访问您的 Data Grid 集群的主机名和端口。

  2. 指定您的凭证,以便客户端可以通过 Data Grid 进行身份验证。
  3. 如果需要,配置客户端智能。

    在 OpenShift 上运行的热 Rod 客户端可以使用任何客户端智能功能,因为它们可以访问 Data Grid Pod 的内部 IP 地址。
    建议使用默认智能 HASH_DISTRIBUTION_AWARE,因为它允许客户端将请求路由到主要所有者,从而提高性能。

Programmatic 配置

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.SaslQop;
import org.infinispan.client.hotrod.impl.ConfigurationProperties;
...

ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.addServer()
               .host("$SERVICE_HOSTNAME")
               .port(ConfigurationProperties.DEFAULT_HOTROD_PORT)
             .security().authentication()
               .username("username")
               .password("changeme")
               .realm("default")
               .saslQop(SaslQop.AUTH)
               .saslMechanism("SCRAM-SHA-512");

热 Rod 客户端属性

# Connection
infinispan.client.hotrod.server_list=$SERVICE_HOSTNAME:$PORT

# Authentication
infinispan.client.hotrod.use_auth=true
infinispan.client.hotrod.auth_username=developer
infinispan.client.hotrod.auth_password=$PASSWORD
infinispan.client.hotrod.auth_server_name=$CLUSTER_NAME
infinispan.client.hotrod.sasl_properties.javax.security.sasl.qop=auth
infinispan.client.hotrod.sasl_mechanism=SCRAM-SHA-512

6.3.1. 获取所有 Data Grid pod 的 IP 地址

您可以检索用于运行 Data Grid pod 的所有 IP 地址列表。

重要

流程

使用以下命令为正在运行的 Data Grid pod 获取所有 IP 地址:

  • 使用 OpenShift API:

    • 访问 ${APISERVER}/api/v1/namespaces/<chart-namespace>/endpoints/<helm-release-name&gt;,以检索与 < helm-release-name > 服务关联的 端点 OpenShift 资源。
  • 使用 OpenShift DNS 服务:

    • 查询 DNS 服务名称 &lt ;helm-release-name>-ping 以获取集群中所有节点的 IP。
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部