Setting up Cluster with Multiple Masters with Dedicated Workers

left to right direction
actor clientapi1
actor clientapi2

node "Master 1" as M1
node "Master 2 (muted)" as M2
node "Worker 1" as W1
node "Worker 2" as W2
node "Worker 3" as W3
node "Worker 4" as W4
node "Worker 5" as W5
M1 --> W1
M1 --> W2
M1 --> W3
M2 --> W4
M2 --> W5
M1 -right-> M2 : peered
M2 -left-> M1

clientapi1 ==> M1
clientapi2 ==> M1
clientapi1 ==> M2
clientapi2 ==> M2

Prerequisites

Hint

All worker nodes that will be included in the cluster (will be connected to the same master) must be configured identically (apart from the repository name and label). A worker configuration template file, worker.ttl, is included in the GraphDB EE distribution.

Tip

GraphDB does not impose any requirements on naming the master and the worker repositories that will be used in the same cluster. For production environment, where each master or worker repository is hosted in a separate GraphDB installation, we recommend using a common name as it will facilitate the automated deployment and configuration of the GraphDB cluster. For other setups, we recommend using distinct names for each repository, e.g., master1, master2, worker1, worker2, worker3, and so on. This will help you identify the particular master or worker when you look at the logs or when you manage your repositories through the GraphDB Workbench.

Initial GraphDB nodes list

General Procedure

Note

To benefit from the two master you also need to use the Client Failover Utility, which will do the automatic read fail-over. If you do not use it, it makes little sense to configure a second master.

  1. Create and configure Master1.

  2. Create and configure Master2.

  3. Create and configure Worker1, Worker2, Worker3, Worker4 and Worker5.

  4. If the machine where each repository is installed does not have a GraphDB Workbench deployed, or if you are not using the RDF4J console for initialization, you have to initialize the repository yourself by executing the command:

    curl http://master-ip:7201/repositories/m1/size
    curl http://master-ip:7202/repositories/m1/size
    curl http://master-ip:7301/repositories/w1/size
    curl http://master-ip:7302/repositories/w1/size
    curl http://master-ip:7303/repositories/w1/size
    curl http://master-ip:7304/repositories/w1/size
    curl http://master-ip:7305/repositories/w1/size
    
  5. Link the 1st worker to Master1 using the WorkerID SPARQL endpoint URL.

    Jolokia:

    http://master-ip:7201/jolokia/exec/ReplicationCluster:name=ClusterInfo!/m1/addClusterNode/http:!/!/worker-ip:7301!/repositories!/w1/0/true
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"exec\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"operation\":\"addClusterNode\",\"arguments\":[\"http://worker-ip:7301/repositories/w1\",0,true]}" \
      http://master-ip:7201/jolokia/
    
  6. Link the 2nd worker to Master1 using the WorkerID SPARQL endpoint URL.

    Jolokia:

    http://master-ip:7201/jolokia/exec/ReplicationCluster:name=ClusterInfo!/m1/addClusterNode/http:!/!/worker-ip:7302!/repositories!/w1/0/true
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"exec\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"operation\":\"addClusterNode\",\"arguments\":[\"http://worker-ip:7302/repositories/w1\",0,true]}" \
      http://master-ip:7201/jolokia/
    
  7. Link the 3rd worker to Master1 using the WorkerID SPARQL endpoint URL.

    Jolokia:

    http://master-ip:7201/jolokia/exec/ReplicationCluster:name=ClusterInfo!/m1/addClusterNode/http:!/!/worker-ip:7303!/repositories!/w1/0/true
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"exec\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"operation\":\"addClusterNode\",\"arguments\":[\"http://worker-ip:7303/repositories/w1\",0,true]}" \
      http://master-ip:7201/jolokia/
    
  8. Link the 4rd worker to Master2 using the WorkerID SPARQL endpoint URL.

    Jolokia:

    http://master-ip:7202/jolokia/exec/ReplicationCluster:name=ClusterInfo!/m1/addClusterNode/http:!/!/worker-ip:7304!/repositories!/w1/0/true
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"exec\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"operation\":\"addClusterNode\",\"arguments\":[\"http://worker-ip:7304/repositories/w1\",0,true]}" \
      http://master-ip:7202/jolokia/
    
  9. Link the 5rd worker to Master2 using the WorkerID SPARQL endpoint URL.

    Jolokia:

    http://master-ip:7202/jolokia/exec/ReplicationCluster:name=ClusterInfo!/m1/addClusterNode/http:!/!/worker-ip:7305!/repositories!/w1/0/true
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"exec\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"operation\":\"addClusterNode\",\"arguments\":[\"http://worker-ip:7305/repositories/w1\",0,true]}" \
      http://master-ip:7201/jolokia/
    
  10. Set Master2 in a Mute mode.

    Jolokia:

    http://master-ip:7202/jolokia/write/ReplicationCluster:name=ClusterInfo!/m1/Mode/mute
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"write\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"attribute\":\"Mode\",\"value\":\"MUTE\"}" \
      http://master-ip:7202/jolokia/
    
  11. Add Master2 as a sync peer to Master1. (using second master’s SPARQL endpoint URL).

    Jolokia:

    http://master-ip:7201/jolokia/exec/ReplicationCluster:name=ClusterInfo!/m1/addSyncPeer/master-ip:7202/http:!/!/master-ip:7202!/repositories!/m1
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"exec\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"operation\":\"addSyncPeer\",\"arguments\":[\"http://master-ip:7202/repositories/m1\",\"http://master-ip:7202/repositories/m1\"]}" \
      http://master-ip:7201/jolokia/
    
  12. Add Master1 as a sync peer to Master2. (Never forget this!).

    Jolokia:

    http://master-ip:7202/jolokia/exec/ReplicationCluster:name=ClusterInfo!/m1/addSyncPeer/master-ip:7201/http:!/!/master-ip:7201!/repositories!/m1
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"exec\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"operation\":\"addSyncPeer\",\"arguments\":[\"http://master-ip:7201/repositories/m1\",\"http://master-ip:7201/repositories/m1\"]}" \
      http://master-ip:7202/jolokia/
    
  13. Check the workers nodes state using the JMX attribute NodeStatus. The result list should contain all linked nodes and their state should be: ON.

    Jolokia:

    http://master-ip:7201/jolokia/read/ReplicationCluster:name=ClusterInfo!/m1/NodeStatus
    
    http://master-ip:7202/jolokia/read/ReplicationCluster:name=ClusterInfo!/m1/NodeStatus
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"read\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"attribute\":\"NodeStatus\"}" \
      http://master-ip:7201/jolokia/
    
    curl -H 'content-type: application/json' \
      -d "{\"type\":\"read\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"attribute\":\"NodeStatus\"}" \
      http://master-ip:7202/jolokia/
    
  14. Check the SyncPeers list. It should contain the two peered masters.

    Jolokia:

    http://master-ip:7201/jolokia/read/ReplicationCluster:name=ClusterInfo!/m1/SyncPeers
    

    cURL:

    curl -H 'content-type: application/json' \
      -d "{\"type\":\"read\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"attribute\":\"SyncPeers\"}" \
      http://master-ip:7201/jolokia/
    

Warning

If running on localhost, the masters must still be specified by their IP. Using “localhost” will lead to “Received status from unknown peer” error messages and the cluster will not be functional.

Note

Use the “!” symbol for escaping characters when necessary in Jolokia requests.

Note

Using basic HTTP authentication may be required for accessing the HTTP-JMX bridge.