Following the YugabyteDB Voyager database migration steps (https://docs.yugabyte.com/preview/migrate/migrate-steps/) going from PostgreSQL to YugabyteDB on a local Kubernetes, on Docker Desktop, on WSL2, on Windows. Using Ubuntu 22.04 on WSL2 to run yb-voyager, I get an error on the Import Data step:
import of data in "postgres" database started
Target YugabyteDB version: 11.2-YB-2.15.2.1-b0
Error Resolving name=yb-tserver-1.yb-tservers.yb-demo.svc.cluster.local: lookup yb-tserver-1.yb-tservers.yb-demo.svc.cluster.local: no such host
The Import Schema step worked correctly (from using pgAdmin connected to the YugabyteDB), so I know that the database can be connected to. Command used:
yb-voyager import schema --export-dir ${EXPORT_DIR} --target-db-host ${TARGET_DB_HOST} --target-db-user ${TARGET_DB_USER} --target-db-password ${TARGET_DB_PASSWORD} --target-db-name ${TARGET_DB_NAME}
The command used to import the data, which fails:
yb-voyager import data --export-dir ${EXPORT_DIR} --target-db-host ${TARGET_DB_HOST} --target-db-user ${TARGET_DB_USER} --target-db-password ${TARGET_DB_PASSWORD} --target-db-name ${TARGET_DB_NAME}
ENV variables:
EXPORT_DIR=/home/abc/db-export
TARGET_DB_HOST=127.0.0.1
TARGET_DB_USER=ybvoyager
TARGET_DB_PASSWORD=password
TARGET_DB_NAME=postgres
Why does the import data fail when the import schema works connecting to the same database?
Putting solution here in case anybody runs into this issue. If there is a Load Balancer is present and YugabyteDB server's IP is not resolvable from the voyager machine, then import data command is erroring out. Ideally it should use the load balancer for importing the data.
Use --target-endpoints=LB_HOST:LB_PORT
to force the server address.
See tickets:
Import data 'Error Resolving name' on local kubernetes #553
Import Data failed if LB is present and cluster servers host is not resolvable #585