In this article I'll show you how to set up in your laptop, very quickly, a cluster of IRIS nodes in sharding. It's not the goal of this article neither to talk about sharding in detail nor define a deployment of a production ready architecture, but to show how to set up quickly, in your own machine, a cluster of IRIS instances configured as shard nodes, with which you'll able to play and test this functionality. If you're insterested in knowing more about sharding in IRIS, take a look at the documentation clicking here.
First and foremost, I want to remark that IRIS sharding will allow us 2 things:
- Define, load and query shard tables, which data will be distributed transparently between the cluster's nodes
- Define federated tables, which offer a global and composed view of data belonging to different tables that will be physically stored in different distributed nodes
So, as I said, we let for other article playing with shard or federated tables, and just focus now in the previous step, that is, setting up the cluster of shard nodes.
Well, for our example we're going to use Docker Desktop (for Windows or MacOS) and we will make use of an IRIS feature: CPF Merge; which allow us to use a plain text file within which we'll include IRIS sections/configuration properties that we want to apply to update the default configuration of an IRIS instance. Basically this file overwrites some parts of the iris.cpf
file that defines the default configuration of the instance.
This merging is "triggered" automatically when we add the environment variable: ISC_CPF_MERGE_FILE
and it's set with a valid path to a file that contains those sections of the cpf file that we want to change. When IRIS starts, it checks if there is a merge file to apply (basically, if it exists that environment variable and points to a valid file). If so, do the merge and starts.
I won't ramble on, here is the file docker-compose.yml
that'll do the magic:
Here you have also an example of CSP.conf and CSP.ini files:
In this example, we're instantiating 3 services:
- irisnode1 - First node of the cluster, it has a special role, that's the reason we named it as
node1
- irisnode2 - Data node, an aditional node to the cluster, which role is
data
(we can have as many as we want of these) - webgateway - Webserver preconfigured to access the IRIS instances (Apache + Webgateway)
To build the image shardnode:latest
, I've used the dockerfile below:
Within the dockerfile we call this generic iris.script
that would allow us to run ObjectScript code, to setup, import & compile code, etc.., in the IRIS image we're building:
The files used for the CPF merge for nodo1
and the other IRIS cluster data
nodes are:
We could have more nodes of type
data
as part of the cluster only adding additional services with the same definition that we have foririsnode2
(changing the name of course)
One more thing, in order to make our routing definition in the webserver to work properly, and so being able to access the System Management Portals for each instance, we have to change the parameter CSPConfigName in each one of them, and we do that with scripts in the files: configure_first_data-node.sh
y configure_data-node.sh
; for this example both are equal, but I've leave them as separated files because, at some point, we could want to execute different actions for each IRIS instance during start time, depending on if it's a cluster node of type nodo1
or type data
.
And that's basically it.
You could define the nodes using the available API in
%SYSTEM.Cluster
class, but the truth is that the possibility of introducing actions altogether with the CPF Merge feature simplifies the task a lot. I recomend you to take a look at here, in particular at the part referred to the section [Actions].
To build the images and deploy the cluster, we could build our image sharnode:latest
and launch our docker-compose from VS Code. Alternately we could do it in our command line, from within the folder in which we have the file: docker-compose.yml
, executing these commands:
docker compose build
docker compose up
Shell SessionShell Session
It'll take a bit the first time because the instance tagged as node1
has to start before whatever other data
node in the cluster starts. But everything should be ready and working in 1 minute or less.
If everything went right, you should be able to access to the SMPs of each instance with the URLs below:
SMP cluster node data : http://localhost:7772/irishost2/csp/sys/UtilHome.csp
Access to WebGateway: http://localhost:7772/csp/bin/Systems/Module.cxw
And, done! From here, the limits regarding DDBB storage and tables size it's determined by your hardware. You would have and IRIS cluster with sharding enabled to define your shard and/or federated tables.
Hope it's useful for you!! See you around...
Added
iris.script, CSP.conf and CSP.ini
code to the article. Thanks @Steve Lubars for pointing out.