Home > database >  ShardingSphere-Proxy DistSQL, Invalid data source: Communications link failure
ShardingSphere-Proxy DistSQL, Invalid data source: Communications link failure

Time:01-16

I am trying to connect to the existing tables in mysql databases db0 and db1 by registering them as storage units using distsql on a container running ShardingSphere-Proxy using the following command:

REGISTER STORAGE UNIT ds_0 (
    HOST="127.0.0.1",
    PORT=3306,
    DB="db0",
    USER="root",
    PASSWORD="blah"
),ds_1 (
    HOST="127.0.0.1",
    PORT=3306,
    DB="db1",
    USER="root",
    PASSWORD="blah"
);

When I try to connect to the mysql instance info above via terminal, it works, but through the ShardingSphere-Proxy that runs in a docker, it shows the error as shown.

ERROR 19000 (44000): Can not process invalid storage units, error message is: [Invalid data source ds_0, error message is: Communications link failure, Invalid data source ds_1, error message is: Communications link failure]

Steps to reproduce

On my local DB:

mysql -h 127.0.0.1 --user=root --password=blah
mysql>create database db0;
mysql>create database db1;

Create & Connect to ShardingSphere-Proxy,

docker run -d -v /Users/pavankrn/Documents/tech/sspheredock/pgsphere/apache-shardingsphere-5.3.1-shardingsphere-proxy-bin/conf:/opt/shardingsphere-proxy/conf -v /Users/pavankrn/Documents/tech/sspheredock/pgsphere/apache-shardingsphere-5.3.1-shardingsphere-proxy-bin/ext-lib:/opt/shardingsphere-proxy/ext-lib -e PORT=3308 -p13308:3308 apache/shardingsphere-proxy:latest

mysql --host=127.0.0.1 --user=root -p --port=13308 sharding_db

On ShardingSphere-Proxy's mysql terminal

use sharding_db;
REGISTER STORAGE UNIT ds_0 (
    HOST="127.0.0.1",
    PORT=3306,
    DB="db0",
    USER="root",
    PASSWORD="blah"
),ds_1 (
    HOST="127.0.0.1",
    PORT=3306,
    DB="db1",
    USER="root",
    PASSWORD="blah"
);

CodePudding user response:

As I've been using mac, I replaced HOST="127.0.0.1", with HOST="host.docker.internal", in the register storage dist sql command.

For other workarounds refer to the thread here.

  • Related