You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node应用未写入指定GridDB集群问题排查求助

问题解决方案

核心原因

两个GridDB集群使用了相同的clusterName(myCluster),同时虚拟机内GridDB节点返回的内部地址无法被WSL识别,导致应用自动 fallback 到本地可访问的同名集群。停止虚拟机服务后,应用连不上指定的通知节点,因此无法写入。


解决步骤

1. 修改两个集群的集群名称(必须操作)

GridDB会通过集群名自动发现同网络内的节点,同名集群会导致节点混淆:

  • WSL Ubuntu集群:修改GridDB配置文件(通常路径/var/lib/griddb/conf/gs_cluster.json)中的clusterName为wslGridCluster
  • CentOS虚拟机集群:修改同路径配置文件中的clusterName为centosGridCluster
  • 分别重启两个集群的服务:
    # WSL中执行
    sudo systemctl restart griddb
    
    # CentOS虚拟机中执行
    sudo systemctl restart griddb
    

2. 调整CentOS虚拟机内GridDB的地址配置

确保虚拟机集群返回给应用的地址是WSL可访问的映射地址:

  • 打开CentOS的gs_cluster.json,修改以下字段:
    {
      "clusterName": "centosGridCluster",
      "notificationAddress": "0.0.0.0",
      "clusterAddress": "0.0.0.0",
      "notificationPort": 30001,
      "clusterPort": 10002
    }
    
    • 0.0.0.0允许节点监听所有网卡,确保端口转发能生效
    • 同时在GridDB的gs_node.json中,设置advertiseAddress为127.0.0.1(因为端口转发到Windows本地,WSL可直接访问这个地址)

3. 完善VirtualBox端口转发规则

除了通知端口30001,还要转发GridDB的核心数据端口(默认10002):

  • 打开VirtualBox虚拟机设置 -> 网络 -> 高级 -> 端口转发
  • 添加两条规则:
    • 名称:GridDB-Notify,主机IP:127.0.0.1,主机端口:30001,子系统IP:虚拟机内网IP(比如10.0.2.15),子系统端口:30001
    • 名称:GridDB-Data,主机IP:127.0.0.1,主机端口:30002,子系统IP:虚拟机内网IP,子系统端口:10002

4. 更新应用配置

修改应用代码中的集群名称,匹配虚拟机集群的新名称:

const factory = griddb.StoreFactory.getInstance();
const store = factory.getStore({
    "notificationMember": '127.0.0.1:30001',
    "clusterName": "centosGridCluster", // 改为虚拟机集群的新名称
    "username": <username>,
    "password": <password>
});

5. 验证

  • 在WSL中测试端口连通性:
    telnet 127.0.0.1 30001
    telnet 127.0.0.1 30002
    
  • 启动应用写入数据,登录CentOS虚拟机查看GridDB数据是否存在
  • 停止WSL的GridDB服务,确认应用仍能正常写入虚拟机集群

内容的提问来源于stack exchange,提问作者Jonathan Pitter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 05:55:19