将 RESP 协议端点与 Data Grid 一起使用


Red Hat Data Grid 8.5

使用 Data Grid RESP 端点与远程缓存交互

Red Hat Customer Content Services

摘要

RESP 端点允许 Redis 客户端连接到支持 RESP 服务器的一个或多个 Data Grid,并执行缓存操作。

Red Hat Data Grid

Data Grid 是一个高性能分布式内存数据存储。

无架构数据结构
将不同对象存储为键值对的灵活性。
基于网格的数据存储
旨在在集群中分发和复制数据。
弹性扩展
动态调整节点数量,以便在不中断服务的情况下满足需求。
数据互操作性
从不同端点在网格中存储、检索和查询数据。

Data Grid 文档

红帽客户门户网站中提供了 Data Grid 的文档。

Data Grid 下载

访问红帽客户门户上的 Data Grid 软件下载

注意

您必须有一个红帽帐户才能访问和下载数据中心软件。

使开源包含更多

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。我们从这四个术语开始:master、slave、黑名单和白名单。由于此项工作十分艰巨,这些更改将在即将推出的几个发行版本中逐步实施。详情请查看 CTO Chris Wright 的信息

1. Data Grid RESP 端点

默认情况下,RESP 端点在单端口端点上启用。Redis 客户端连接会自动检测到并路由到内部连接器。RESP 端点可以正常工作:

  • 独立数据网格服务器部署(与独立的 Redis 一样,每个服务器实例相互独立运行)。
  • 集群数据网格服务器部署,其中服务器实例在彼此之间复制或分发数据。集群部署为客户端提供故障转移功能。

先决条件

  • 安装 Data Grid Server。

流程

  1. 创建用户

验证

当您启动 Data Grid Server 检查时,以下日志消息:

[org.infinispan.SERVER] ISPN080018: Started connector Resp (internal)
Copy to Clipboard Toggle word wrap

现在,您可以使用 Redis 客户端连接到 RESP 端点。例如,通过 Redis CLI,您可以执行以下操作在缓存中添加一个条目:

redis-cli -p 11222 --user username --pass password
Copy to Clipboard Toggle word wrap
127.0.0.1:11222> SET k v
OK
127.0.0.1:11222> GET k
"v"
127.0.0.1:11222> quit
Copy to Clipboard Toggle word wrap

1.1. 为 RESP 端点配置缓存

RESP 端点会自动配置并启动 respCache 缓存。这个缓存有以下配置:

  • local-cachedistributed-cache,具体取决于 Data Grid Server 集群模式。
  • 键和值的应用程序/octet-stream 编码。
  • RESPHashFunctionPartitioner hash partitioner,它支持 Redis 客户端使用的 CRC16 哈希
明确缓存的配置

可为缓存提供自定义配置,只要它不违反 RESP 连接器的要求,在这种情况下,服务器会引发异常且不会启动。主要限制是:

  • 哈希分区功能必须是 org.infinispan.distribution.ch.impl.RESPHashFunctionPartitioner
  • 密钥编码必须是 application/octet-stream

明确缓存配置示例如下:

XML

<distributed-cache name="respCache" aliases="0" owners="2"
                   key-partitioner="org.infinispan.distribution.ch.impl.RESPHashFunctionPartitioner"
                   mode="SYNC" remote-timeout="17500" statistics="true">
	<encoding media-type="application/octet-stream"/>
</distributed-cache>
Copy to Clipboard Toggle word wrap

JSON

{
   "respCache": {
     "distributed-cache": {
       "aliases": ["0"],
       "owners": "2",
       "key-partitioner": "org.infinispan.distribution.ch.impl.RESPHashFunctionPartitioner",
       "mode": "SYNC",
       "statistics": true,
       "encoding": {
         "media-type": "application/octet-stream"
       }
     }
   }
 }
Copy to Clipboard Toggle word wrap

YAML

respCache:
  distributedCache:
    aliases:
      - "0"
    owners: "2"
    keyPartitioner: "org.infinispan.distribution.ch.impl.RESPHashFunctionPartitioner"
    mode: "SYNC"
    statistics: "true"
    encoding:
      mediaType: "application/octet-stream"
Copy to Clipboard Toggle word wrap

提示

如果要在 Data Grid Console 中查看缓存条目(值为media-type="application/x-protostream"),请使用 Protobuf 编码配置缓存值编码。

显式 RESP 端点配置

如果单端口端点使用的隐式配置不适合您的需要,可以使用显式配置。

XML

<endpoints>
  <endpoint socket-binding="default" security-realm="default">
    <resp-connector cache="mycache" />
    <hotrod-connector />
    <rest-connector/>
  </endpoint>
</endpoints>
Copy to Clipboard Toggle word wrap

JSON

{
  "server": {
    "endpoints": {
      "endpoint": {
        "socket-binding": "default",
        "security-realm": "default",
        "resp-connector": {
          "cache": "mycache"
        },
        "hotrod-connector": {},
        "rest-connector": {}
      }
    }
  }
}
Copy to Clipboard Toggle word wrap

YAML

server:
  endpoints:
    endpoint:
      socketBinding: "default"
      securityRealm: "default"
      respConnector:
        cache: "mycache"
      hotrodConnector: ~
      restConnector: ~
Copy to Clipboard Toggle word wrap

2. 将缓存映射到 Redis 逻辑数据库

使用缓存 别名 配置属性将缓存映射到 Redis 逻辑数据库。默认 respCache 映射到逻辑数据库 0。

提示

在集群模式中,数据网格也可以使用多个逻辑数据库,这与在使用 Redis 集群时只支持数据库 0 的 Redis 不同。

3. Redis 命令

Data Grid RESP 端点实现以下 Redis 命令:

法律通告

Copyright © 2024 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat