How to bind two network interface through --host flag

I need configure a solution for cross datacenters, one datacenter is based on Ali cloud, another datacenter is based on Amazon Cloud. I hope all the servers inside Alicloud, their connections should use internal IP addresses, because it should not be charged any fees. The connections between the two datacenter should use public IP addresses. Is it possible to implement this solution by now? Thanks!

Hey @levifan,

CRDB doesn’t currently have any particular support for cloud-aware network routing or such. You can probably get what you want by having nodes connect to each other using hostnames, and configuring the DNS servers in the two data centers suitably.

dns servers maybe a good choice, I will try it. Thanks!

hi @andrei,
I tried to bind through hostnames, but I met some issues,

  1. run start node with --advertise-host but without --host, then telnet the two ip addresses plus 26257 port is ok. but the cockroach console doesn’t work.
  2. run start node with --advertise-host and --host together, then telnet the public ip address plus 26257 port is ok, but can’t telnet private network IP. The cockroach console works well.

What do you mean by “cockroach console”? The web admin UI, or connecting the SQL client?

Sorry, this is generally bit outside what I can answer; I’d have to see your exact setup.
I can only say generalities:

  • the CRDB admin UI will be served on the 8080 port of the network interface specified in --host (or all the interfaces if --host is not specified)
  • --advertise-host doesn’t change anything about the network interfaces on which anything is served (that’s always --host); --advertise-host provides the hostname that other nodes will connect to (so it needs to resolve to a network interface that crdb is serving on). You probably want to only specify --advertise-host and not --host .

Thanks @andrei, cockroach console means web admin UI. I resolved this issue after I added the server name string into cockroach cert create-node command.

good news, @levifan - some work around these issues has made it to our roadmap - https://github.com/cockroachdb/cockroach/issues/25636

@levifan, the freshly released v2.1.0-beta.20180827 has a --locality-advertise-addr flag which should help you.

It is great! Thanks, @andrei