Search code examples
distributedorientdb

OrientDB: how to connect to multiple remote hosts in a distributed cluster?


Pretend I have 3 OrientDB hosts running in distributed mode together, at these addresses:

  • 192.168.10.4
  • 192.168.10.5
  • 192.168.10.6

Using the Java client, the typical way to fetch a reference to the database is to do this:

 this.graphFactory = new OrientGraphFactory(
            "remote:[host]/[database]",
            "username",
            "password")
            .setupPool([...], [...]);

In the connection string argument, how can I indicate that there are multiple hosts? My first instinct is to manually set up a TCP load balancer (i.e. HAProxy) on a separate IP and have it distribute it between my 3 hosts.

Is there a way to tell the API that there are multiple IPs to choose from, or should I set up a load balancer in front of my instances?


Solution

  • You could use all those addresses separated by a semicolon:

    remote:192.168.10.4/db;remote:192.168.10.5/db;remote:192.168.10.6/db
    

    OrientDB will try connecting to the first, but if it's unreachable, it will try the others in sequence.