如何在通过公网IP部署集群时,确保实例间使用私有IP进行通信?

【遇到的问题:问题现象及影响】
我正在尝试配置一个topology,用于通过我的本地机器部署一个集群。这个拓扑应该通过公网IP地址指向一些SSH服务器。到目前为止一切正常,但问题出现在尝试启动已部署的instance时。问题发生的原因是,在instance之间,它试图通过相同的公网IP地址进行通信,但每个SSH服务器我都配置的是通过私有IP地址与其他SSH服务器通信。

以下是我尝试设置的示例,但未成功:

目前的设置是,我的计算机上的 /etc/hosts 配置了服务器的 IP 地址,以便能够执行部署。然后,在每个服务器内,/etc/hosts 设置为让它们通过私有 IP 地址相互通信。

但是没有设置服务器同时拥有两个 IP 地址,因为我不希望服务器之间通过公网 IP 地址进行通信。我理解可以覆盖 gRPC 用来实例间通信的 URL,因此我尝试用私有 IP 地址进行覆盖,但部署过程中仍然使用了公网 IP 地址。

global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/tidb-new/deploy"
  data_dir: "/tidb-new/data"

pd_servers:
  - host: node1 # uses /etc/hosts ip address from local machine, which is setup as public ip address
    name: pd-node1
    config:
      client-urls: "http://0.0.0.0:2379"
      peer-urls: "http://0.0.0.0:2380"
      advertise-client-urls: "http://10.0.0.4:2379" # this is where I am trying to map the gRPC communication with the private ip address
      advertise-peer-urls: "http://10.0.0.4:2380"  # this is where I am trying to map the gRPC communication with the private ip address

tikv_servers:
  - host: node2    # uses /etc/hosts ip address from local machine, which is setup as public ip address
    ssh_port: 22
    config:
      server.addr: "0.0.0.0:20160"
      server.advertise-addr: "10.0.0.2:20160"  # this is where I am trying to map the gRPC communication with the private ip address

tidb_servers:
  - host: node3  # uses /etc/hosts ip address from local machine, which is setup as public ip address
    ssh_port: 22
    config:
      advertise-address: "10.0.0.3"

唯一成功的情况是,我实际上创建了一个管理节点,该节点会直接通过每个其他节点的私有 IP 地址进行通信,所以公网 IP 地址仅用于从本地机器通过 SSH 连接到管理节点,最终我们采用了这种方式。

想问问各位大佬有没有能够使它在直接从本地机器部署的情况下正常工作,并解决我遇到的问题的办法?

没太看明白,比如一台机器有一个内网地址192.168.0.1,有一个基础网络IP 10.0.0.1 ,那topology里都用192.168的内网地址来部署就行了,这样集群内部通讯使用独立的交换机性能更好,10的地址是用来人工登录服务器的,现在问题是什么呢

大佬目前的问题是这样配置失败了。

global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/tidb-new/deploy"
  data_dir: "/tidb-new/data"

pd_servers:
  - host: node1 # uses /etc/hosts ip address from local machine, which is setup as public ip address
    name: pd-node1
    config:
      client-urls: "http://0.0.0.0:2379"
      peer-urls: "http://0.0.0.0:2380"
      advertise-client-urls: "http://10.0.0.4:2379" # this is where I am trying to map the gRPC communication with the private ip address
      advertise-peer-urls: "http://10.0.0.4:2380"  # this is where I am trying to map the gRPC communication with the private ip address

tikv_servers:
  - host: node2    # uses /etc/hosts ip address from local machine, which is setup as public ip address
    ssh_port: 22
    config:
      server.addr: "0.0.0.0:20160"
      server.advertise-addr: "10.0.0.2:20160"  # this is where I am trying to map the gRPC communication with the private ip address

tidb_servers:
  - host: node3  # uses /etc/hosts ip address from local machine, which is setup as public ip address
    ssh_port: 22
    config:
      advertise-address: "10.0.0.3"

要不先单ip参考官方文档部署成功后,在添加其它类(公网)IP地址?

  • host: node3 这里用ip可以吗,必须要用域名吗

tidb server 默认是监听在机器所有 IP 的端口的,你用私网 IP 部署就好了,配置文件中都要用私网的 IP 地址

2 个赞

使用私网部署了,然后公网对外映射出去了

这里都写内网地址不行吗?应该就会通过内网地址访问啊。。。

大佬说的是指里面写的都改成内网地址吗?

对啊,host写上内网地址,
client-urls: “http://0.0.0.0:2379
peer-urls: “http://0.0.0.0:2380
advertise-client-urls: “http://10.0.0.4:2379” # this is where I am trying to map the gRPC communication with the private ip address
advertise-peer-urls: “http://10.0.0.4:2380
这些也没必要,它默认是会绑定到所有网卡,只要你的云策略不要把这些端口开放到外网就没有上面风险。

此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。