DEV Community

Franck Pachot for YugabyteDB

Posted on • Updated on

YugabyteDB in a Micro VM with no network

In a previous post I mentioned how to start YugabyteDB fast for a quick short-life lab. This can run on Micro VM (like firecracker) and in some cases you have no network interfaces with it. You don't need it if you connect with ysqlsh from the MicroVM but you may encounter name resolution issues. Note that you can reproduce it with docker run --network none.

This post is about the following errors and their resolution:

ysqlsh: FATAL:  Timed out: OpenTable RPC (request call id 2) to timed out after 120.000s
Enter fullscreen mode Exit fullscreen mode

or, in the yb-tserver.ERROR:

E0830 11:32:44.518383    66] Failed to initialize client: Network error (yb/util/net/ Could not determine local host names: Unable to lookup FQDN (699cdfc74424), getaddrinfo returned -11 (EAI_SYSTEM): Connection refused (system error 111)
Enter fullscreen mode Exit fullscreen mode

This has to do with name resolution. YugabyteDB is a distributed SQL database and must have a matching hostname and IP address to identify the nodes. The last message is explicit: YugabyteDB calls the Linux getaddrinfo() system call to get the IP of 699cdfc74424 which is my container hostname

Basically, it does the same as:

sh-4.2# getent ahosts  $(hostname)       STREAM 699cdfc74424       DGRAM       RAW
::1             STREAM
::1             DGRAM
::1             RAW
Enter fullscreen mode Exit fullscreen mode

But why I'm trying to start YugabyteDB on which is the only interface I have on my no-network container:

/home/yugabyte/bin/yb-master --fs_data_dirs=/var/tmp --master_addresses= --replication_factor=1 --default_memory_limit_to_ram_ratio=0.30 &
/home/yugabyte/bin/yb-tserver --fs_data_dirs=/var/tmp --tserver_master_addrs= --default_memory_limit_to_ram_ratio=0.30 &

Enter fullscreen mode Exit fullscreen mode

The reason is in /etc/nsswitch.conf:

sh-4.2# grep hosts: /etc/nsswitch.conf

#hosts:     db files nisplus nis dns
hosts:      files dns myhostname
Enter fullscreen mode Exit fullscreen mode

The host name resolution goes first to files, which in this case is /etc/hosts:

sh-4.2# cat /etc/hosts       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Enter fullscreen mode Exit fullscreen mode

My hostname is unknown there.

Then it goes to dns but I've no DNS in my no-network container (reason for the Connection refused error I guess)

Then it goes to myhostname which resolves the hostname, but to It is used to avoid patching the /etc/hosts but in my case cannot be used because is not known.
I tried to start yb-master --master_addresses= but it fails with None of the local addresses are present in master_addresses

Then, my solution is simply to add the hostname to the /etc/hosts:

echo " localhost $(hostname)"  > /etc/hosts
Enter fullscreen mode Exit fullscreen mode

With this before starting yb-master--fs_data_dirs=/var/tmp --master_addresses= --replication_factor=1 and yb-tserver --fs_data_dirs=/var/tmp --master_addresses= --replication_factor=1 you should be able to connect with a simple ysqlsh which connects by default to localhost

Of course, a distributed SQL database with no network makes no sense except for a small container used for continuous integration for example.

Top comments (0)