Because Jelastic PaaS implements the cartridges packaging model, the list of supported servers has been significantly extended. In addition to the ability to prepare a package with any desired stack (either based on the already existing OpenShift’s one or one originally created by yourself), there are a number of ready-to-use cartridge templates available within our Templates repository. They can be easily installed to the Jelastic Cloud by an administrator, and OrientDB is one of these.
OrientDB is the first multi-model open-source NoSQL distributed database system, which combines the power of graphs and the flexibility of documents in one scalable and high-performance operational solution. Working with OrientDB, you receive the numerous features and possibilities due to its integrated blend of graphs relational behaviour and document-type storage. And in order to benefit even more, you are able to gain the improved reliability of your data due to its Multi-Master replication support.
It’s well known that replication is a basic security solution for any database server, aimed to increase its failover capabilities. With OrientDB, you can easily create a secure cluster with several replicated database servers in it and, in such a way, reduce the risks of downtime or data loss, increase accessibility, get a high level of performance and product confidence.
In this instruction, we’ll show you how to configure the replication between two OrientDB servers, where all of the records inside the same-named databases are replicated. However, your DB cluster may include any desired amount of nodes – just adjust every one of them based on the steps below (as Multi-Master replication mode means that all servers in a cluster are equal and able to write/read records of each other).
So, let’s get started!
1. Log in to your Jelastic account and Create a new environment with the corresponding button at the top left corner of your dashboard.
2. You’ll see the topology dialog window opened. Disable the automatically added application server (as you won’t need it for this tutorial) and pick the OrientDB server instead.
Increase the amount of OrientDB nodes using the + button in the central Horizontal scaling pane. Then, state the resource usage limits for this server with the help of cloudlet sliders, specify the desired environment name (for example, orientdb), and click Create to continue.
3. Once your environment is successfully created and has appeared at your dashboard, you can proceed to the next chapter of this guide.
Now let’s configure each of the nodes in your cluster in order to set up a replication between them.
1. Click the Config button for your database server.
2. In the appeared Configuration Manager tab, navigate to the hazelcast.xml file within the conf/config directory and edit the code in its group and network sections in the following way:
Note that you should substitute the values in the curly brackets with your data:
3. Then, add the tcp-ip code subsection to the same file just after the closing multicast tag inside the join section.
4. In order to save your time and not repeat the same operations for every node, use the Save for all instances option from the Save drop-down list above the editor.
In such a way, the performed configuration changes will be applied to all the nodes in your DB cluster.
5. After that, switch to the default-distributed-db-config.json file, located in the same folder, and set the preferred names (e.g. nodeN) for all of your replicated nodes within the servers parameter, substituting the default <NEW_NODE> string.
“servers” : [ “node1″, “node2″ ]
6. Save for all instances one more time and switch to the orientdb-dserver-config.xml file still in the conf/config directory.
Find the HTTP protocol setting in the <listeners> file section (approximately at the 73d code line) and edit the port-rangevariable value, stating it to 8080-8090.
Save the changes for all nodes in the way you’ve done it recently.
7. In order to protect your database servers from the unauthorized access, let’s set the admin username and password for them.
You can copy and use the default credentials from the orientdb-server-config.xml file (they were also sent to you via email after environment creation) or add your own, new ones. We’ll use the custom root/qwerty credentials as an example. So, specify the desired values within the following line:
<user name=”root” password=”qwerty” resources=”*”/>
Then, in the same file, scroll a bit down (approximately to the 100th line) and paste the received string inside the users section.
Depending on your preferences, the credentials could be identical (in this case use the Save for all instances option at any node you’ve performed the changes for) or different for each of your nodes (use Save only for the current instance for applying the changes at every instance).
8. Once all the required changes are saved, navigate to the beginning of the same file and uncomment the first nodeNameparameter in the <handler class=”com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin”> section.
This time you need to make the different changes for each node, modifying this parameter by means of entering the stated (in the 4th step) node names, inside the value variable. In accordance with the earlier specified settings in this instruction, the values should be:
You can switch between the nodes via the appropriate list in the top left part of the Configuration Manager tab (circled at the image below).
7. Finally, find the server.sh script inside the bin directory, and change the default configuration file, used by your DB server, to orientdb-dserver-config.xml within the CONFIG_FILE variable.
Save new settings for all instances.
8. In order to run your cluster with all the new configurations applied, you need to Stop your environment and Start it again using the appropriate buttons next to it.
As soon as your servers are running, let’s check the data is replicated inside the set of your nodes. For that we’ll create the same-named DB at each of the instances and ensure that classes and records inside it are instantly copied to all nodes after the addition.
1. Open the first database node in browser in order to access its OrientDB Studio administration panel.
2. Enter your admin credentials (if you set them) in the appeared pop-up window and click the Create new database button.
3. In the opened dialog frame, type the desired database name (e.g. jelastic) and specify your admin credentials. Optionally, select the preferred Type and Storage Type within the corresponding drop-down lists and click on Create database to finish.
4. Repeat the first three steps for the rest of your DB servers in order to create a compound of the databases with the same name inside your cluster.
5. After that, Connect to this newly created database at the random OrientDB instance by choosing it from the Database drop-down list and specifying your admin credentials (if there are any).
6. Once inside, switch to the Schema tab and click on the New Class button.
7. In the shown pop-up window, type the name of your new class (e.g. Repl-test) and define the remained options if necessary (or leave them blank). Click Save to finish.
8. Now, let’s add a simple record to our class (click on the New Record button next to it).
9. We’ll adjust this record to contain the additional custom field. You can add it through choosing the Add field option within the Actions list.
Specify the desired field name (for instance, Name), set the string type for it and click Add field to proceed.
10. Now, let’s set any name for our new record, e.g. John. Save the changes with the corresponding button.
11. Finally, connect to the same jelastic database at all the rest OrientDB nodes and check that the Repl-test class with your custom record exists at every one of them.
Great! As you can see, replication works like a charm, so you can start using your DB cluster according to your needs without worrying about the data’s safety.
Register for a free 2-week trial now and check it out yourself!