--- title: "远程集群节点属性筛选配置" date: 2026-03-08 lastmod: 2026-03-08 description: "cluster.remote.node.attr 配置项用于筛选远程集群中应该连接的节点,实现专用的跨集群网关。" tags: ["远程集群", "节点属性", "跨集群搜索", "网关"] summary: "配置项作用 # cluster.remote.node.attr 配置项用于指定远程集群中应该连接的节点的属性名称。 通过此配置,可以选择远程集群中具有特定属性的节点作为跨集群连接的网关节点,实现更精细的连接控制。 配置项属性 # 配置路径: cluster.remote.node.attr 数据类型: string 默认值: 无(空字符串) 是否可选: 是 作用域: 节点级别(NodeScope) 配置项详解 # 工作机制 # 此配置需要在本地集群和远程集群两处配合使用: 远程集群配置 本地集群配置 ──────────────────────────────────────────────── node.attr.gateway: true cluster.remote.node.attr: gateway │ │ │ │ ├── 节点1 (gateway=true) ─────────┼──→ ✅ 会被连接 │ │ ├── 节点2 (gateway=true) ─────────┼──→ ✅ 会被连接 │ │ ├── 节点3 (gateway=false) ─────────┼──→ ❌ 不会被连接 │ │ └── 节点4 (无此属性) ─────────┼──→ ❌ 不会被连接 配置步骤 # 远程集群节点设置属性: 在远程集群的节点上设置节点属性 本地集群配置筛选: 在本地集群配置要筛选的属性名称 连接建立: 本地集群只连接到具有该属性的节点 节点筛选逻辑 # // 简化的筛选逻辑 if (配置了 node." --- ## 配置项作用 `cluster.remote.node.attr` 配置项用于指定远程集群中应该连接的节点的属性名称。 通过此配置,可以选择远程集群中具有特定属性的节点作为跨集群连接的网关节点,实现更精细的连接控制。 ## 配置项属性 - **配置路径**: `cluster.remote.node.attr` - **数据类型**: `string` - **默认值**: 无(空字符串) - **是否可选**: 是 - **作用域**: 节点级别(NodeScope) ## 配置项详解 ## 工作机制 此配置需要在**本地集群**和**远程集群**两处配合使用: ``` 远程集群配置 本地集群配置 ──────────────────────────────────────────────── node.attr.gateway: true cluster.remote.node.attr: gateway │ │ │ │ ├── 节点1 (gateway=true) ─────────┼──→ ✅ 会被连接 │ │ ├── 节点2 (gateway=true) ─────────┼──→ ✅ 会被连接 │ │ ├── 节点3 (gateway=false) ─────────┼──→ ❌ 不会被连接 │ │ └── 节点4 (无此属性) ─────────┼──→ ❌ 不会被连接 ``` ## 配置步骤 1. **远程集群节点设置属性**: 在远程集群的节点上设置节点属性 2. **本地集群配置筛选**: 在本地集群配置要筛选的属性名称 3. **连接建立**: 本地集群只连接到具有该属性的节点 ## 节点筛选逻辑 ```java // 简化的筛选逻辑 if (配置了 node.attr) { 连接节点,当 node.attributes[配置的属性名] == "true" } else { 连接所有可用节点 } ``` ## 配置建议 ## 使用专用网关节点 ```yaml # 远程集群节点配置(easysearch.yml) node.attr.gateway: true ``` ```yaml # 本地集群配置(easysearch.yml) cluster.remote.node.attr: gateway ``` **建议**: 这种配置方式适用于需要专用网关节点的场景,可以: - 控制跨集群访问的入口 - 集中监控和管理跨集群流量 - 减少对远程集群普通节点的压力 ## 不使用筛选(默认) ```yaml # 不配置 cluster.remote.node.attr # 或者不设置 ``` **建议**: 保持默认行为,连接所有可用节点,提供更好的负载均衡和冗余。 ## 代码示例 ## 基础配置 **远程集群节点配置**: ```yaml # easysearch.yml node.attr.remote_gateway: true ``` **本地集群配置**: ```yaml cluster: remote: production: seeds: ["prod-node1:9300"] node_attr: remote_gateway ``` ## 多种网关类型 **远程集群节点配置**: ```yaml # 数据中心 A 的节点 node.attr.dc: "dc-a" node.attr.gateway: "true" # 数据中心 B 的节点 node.attr.dc: "dc-b" node.attr.gateway: "true" ``` **本地集群配置**: ```yaml cluster: remote: production: seeds: ["prod-seed:9300"] # 只连接 dc-a 的网关节点 node_attr: dc ``` ## 环境隔离配置 **远程集群节点配置**: ```yaml # 生产环境节点 node.attr.env: production node.attr.cross_cluster_enabled: true # 测试环境节点 node.attr.env: test ``` **本地集群配置**: ```yaml cluster: remote: production: seeds: ["prod-seed:9300"] node_attr: cross_cluster_enabled ``` ## 使用场景 ## 专用网关架构 ``` 本地集群 远程集群 │ │ │ (只连接网关节点) │ │ │ └──────────┬─────────────→ 网关节点1 (gateway=true) │ │ └─────────────────→ 网关节点2 (gateway=true) │ 普通数据节点 (gateway=false) 不接受跨集群连接 ``` **优点**: - 集中管理跨集群访问 - 便于监控和审计 - 减少对数据节点的干扰 ## 多数据中心部署 ``` 本地集群 远程集群(多数据中心) │ │ ├─────────────────────→ DC1 网关 (dc=dc1) │ │ └─────────────────────→ DC2 网关 (dc=dc2) │ DC3 节点 (dc=dc3,不连接) ``` **用途**: 根据网络拓扑选择最优的网关节点。 ## 相关配置 | 配置项 | 作用 | 默认值 | |--------|------|--------| | `cluster.remote.connections_per_cluster` | 每个集群的连接数 | 3 | | `cluster.remote..seeds` | 远程集群种子节点列表 | - | | `node.attr.` | 节点自定义属性 | - | ## 属性值说明 | 属性值 | 效果 | |--------|------| | `true` | 节点会被连接 | | `false` 或未设置 | 节点不会被连接 | | 其他值 | 被解析为布尔值(`false`) | ## 注意事项 1. **两端配置**: 需要在远程集群节点和本地集群两处配置才能生效。 2. **布尔值判断**: 属性值必须是字符串 `"true"`(小写)才会被识别为可连接节点。 3. **连接数限制**: 筛选后的节点数量仍受 `connections_per_cluster` 限制。 4. **动态配置**: 节点属性修改后需要重启节点才能生效。 5. **种子节点**: 种子节点不需要满足属性筛选条件,但从种子节点发现的其他节点会经过筛选。 6. **默认行为**: 不配置此属性时,会连接所有可用的数据节点。 7. **调试**: 可以通过 `GET _remote/info` API 查看实际的连接节点信息。