Обсуждение: BDR Across Distributed Nodes

Поиск
Список
Период
Сортировка

BDR Across Distributed Nodes

От
billythebomber
Дата:
I'm starting to test BDR, and I've followed the quickstart included in the documentation successfully.

The problem I'm encountering is when two servers are on different hosts, which is not covered in the documentation. Node1 is 10.0.0.1, node2 is 10.0.0.2, but when I try to connect from node2:

demo=# SELECT bdr.bdr_group_join(
      local_node_name := 'node2',
      node_external_dsn := 'port=5432 dbname=demo',                
      join_using_dsn := 'port=5432 dbname=demo host=10.0.0.1'

ERROR:  node identity for node_external_dsn does not match current node when connecting back via remote
DETAIL:  The dsn '' connects to a node with identity (6140654556124456820,1,16385) but the local node is (6140654709151998583,1,16385)
HINT:  The 'node_external_dsn' parameter must refer to the node you're running this function from, from the perspective of the node pointed to by join_using_dsn

If I add node2 host entry:

demo=# SELECT bdr.bdr_group_join(
      local_node_name := 'node2',
      node_external_dsn := 'port=5432 dbname=demo host=10.0.0.2',
      join_using_dsn := 'port=5432 dbname=demo host=10.0.0.1'
);
FATAL:  could not connect to the server in non-replication mode: could not connect to server: Connection refused
    Is the server running on host "10.0.0.2" and accepting
    TCP/IP connections on port 5432?

DETAIL:  dsn was: port=5432 dbname=demo host=10.0.0.2 fallback_application_name='bdr (6140654709151998583,1,16385,):bdrnodeinfo'

justgive=# select bdr.bdr_version();
       bdr_version       
--------------------------
 0.9.0-2015-03-24-f36ee65
(1 row)

Does anybody happen to have any examples of calling bdr.bdr_group_join when there are remote IPs involved?

                          - Billy


Re: BDR Across Distributed Nodes

От
Tomas Vondra
Дата:
Hi!

On 04/23/15 20:42, billythebomber wrote:
> I'm starting to test BDR, and I've followed the quickstart included in
> the documentation successfully.
>
> The problem I'm encountering is when two servers are on different hosts,
> which is not covered in the documentation. Node1 is 10.0.0.1, node2 is
> 10.0.0.2, but when I try to connect from node2:
>
> demo=# SELECT bdr.bdr_group_join(
>        local_node_name := 'node2',
>        node_external_dsn := 'port=5432 dbname=demo',
>        join_using_dsn := 'port=5432 dbname=demo host=10.0.0.1'
>
> ERROR:  node identity for node_external_dsn does not match current node
> when connecting back via remote
> DETAIL: The dsn '' connects to a node with identity
> (6140654556124456820,1,16385) but the local node is
> (6140654709151998583,1,16385)
> HINT:  The 'node_external_dsn' parameter must refer to the node you're
> running this function from, from the perspective of the node pointed to
> by join_using_dsn

The problem apparently is that 'node2' connects to 'node1', using the
join_using_dsn and passes it the node_external_dsn. node1 takes that,
and attempts to connect to that. Sadly, the DSN does not contain any
host, so node1 uses localhost and connects to itself. And finds that the
identity does not match the expected one (because it expects *583,
assigned to node2, but gets *820, which is probably node1).

>
> If I add node2 host entry:
>
> demo=# SELECT bdr.bdr_group_join(
>        local_node_name := 'node2',
>        node_external_dsn := 'port=5432 dbname=demo host=10.0.0.2',
>        join_using_dsn := 'port=5432 dbname=demo host=10.0.0.1'
> );
> FATAL:  could not connect to the server in non-replication mode: could
> not connect to server: Connection refused
>      Is the server running on host "10.0.0.2" and accepting
>      TCP/IP connections on port 5432?

This seems correct, but apparantly node1 can't connect to node2, using
the external_dsn. Try connecting using psql from 10.0.0.1 to 10.0.0.2
and then from 10.0.0.2 to 10.0.0.1. So something like this:

# from 10.0.0.1
psql -h 10.0.0.2 -p 5432 demo

# from 10.0.0.2
psql -h 10.0.0.1 -p 5432 demo

If that does not work, you probably need to investigate - firewall
settings, pg_hba.conf and postgresql.conf (maybe it's not listening on
this address)?

regards

--
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services