Setting up Cluster with Two Masters with Shared Workers, One Is Read-only¶
What’s in this document?
Prerequisites¶
A valid license for each of your worker nodes;
GraphDB EE distribution unzipped on all cluster machines;
GraphDB EE installed and configured on each of your cluster machines.
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¶
Master1, repository: m1 (SPARQL endpoint URL: http://master-ip:7201/repositories/m1)
Master2, repository: m1 (SPARQL endpoint URL: http://master-ip:7202/repositories/m1) (second master can have same repository name)
Worker1, repository: w1 (SPARQL endpoint URL: http://worker-ip:7301/repositories/w1)
Worker2, repository: w1 (SPARQL endpoint URL: http://worker-ip:7302/repositories/w1)
Worker3, repository: w1 (SPARQL endpoint URL: http://worker-ip:7303/repositories/w1)
General procedure¶
Note
To benefit from the two masters, you also need to use the Client Failover Utility, which will do the automatic read failover. If you do not use it, it makes little sense to configure a second master.
Create and configure Master1.
Create and configure Master2.
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
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/
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/
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/
Set Master2 as read only. (using second master’s SPARQL endpoint URL).
Jolokia:
http://master-ip:7202/jolokia/write/ReplicationCluster:name=ClusterInfo!/m1/ReadOnly/true
cURL:
curl -H 'content-type: application/json' \ -d "{\"type\":\"write\",\"mbean\":\"ReplicationCluster:name=ClusterInfo\/m1\",\"attribute\":\"ReadOnly\",\"value\":true}" \ http://master-ip:7202/jolokia/
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/
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/
Link the 1st worker to Master2 using the WorkerID SPARQL endpoint URL.
Jolokia:
http://master-ip:7202/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:7202/jolokia/
Link the 2nd worker to Master2 using the WorkerID SPARQL endpoint URL.
Jolokia:
http://master-ip:7202/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:7202/jolokia/
Link the 3rd worker to Master2 using the WorkerID SPARQL endpoint URL.
Jolokia:
http://master-ip:7202/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:7202/jolokia/
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/
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.