目前的设置是,我的计算机上的 /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 连接到管理节点,最终我们采用了这种方式。
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"