cyclos clusterPreviously, we shared How to Install Cyclos 4 in One-Click in Less than 10 Minutes. In this tutorial we will show you a more complex setup of a Cyclos cluster with master-slave database replication, scalability and high availability ensuring redundancy.

Using Jelastic you can run Cyclos on Tomcat, Jetty and Glassfish. The database for Cyclos 4 is the open source database PostgreSQL (not less than 9.3). The minimal memory space requirements to run a single Cyclos instance is 500 Mb (so you need to use at least 4 cloudlets).

jelastic cyclos
High availability prevents failed transactions and other issues that can affect your users. Extending the application across a number of the servers provides redundancy. This redundancy ensures that if one of the servers fails, the users from that node will be automatically switched to the other instance of this Tomcat cluster. Thanks to the replication, the other instance already has all the sessions of the failed node, so the end-users experience is not impacted.

In addition, the PostgreSQL database master-slave replication improves the performance and the fail-over capabilities of your environment.

Installation

Follow this tutorial on how to install and deploy Cyclos in Jelastic with PostgreSQL 9.5.2 and Tomcat 7.0.67.

Database Replication

Once the Cyclos application is deployed, you can move on to database settings. We will configure PostgreSQL master-slave replication in to protect your application from data loss or down time.

PostgreSQL in your environment with Cyclos deployed will be used as master database. For the slave database you need to create a separate environment.

Within the Jelastic dashboard create an environment with a PostgreSQL node which is going to be used as a slave database. Name your environment (e.g. slave-database) and click Create.

slave database

Find the environment with the master database in your environment list (with deployed Cyclos in our case). Click the Config button next to the PostgreSQL node.

Open the conf > postgresql.conf file. Uncomment and change the following settings to enable streaming replication:

wal_level = hot_standby

wal level
max_wal_senders = 3

max wal senders
archive_mode = on

archive mode
archive_command = ‘cp %p /tmp/%f’

archive command

Open the pg_hba.conf configuration file, which is located in the same conf folder.

Permit the standby database cluster connection by stating the following parameters:

host replication all {standby_ip_address}/32 trust

Add an additional line after you add these settings.

host replication standby ip

Tip: To get the IP address of any server, click the Info button next to it and copy the address in the opened frame:

standby ip

Next, access your environment with the master DB via SSH and enter the PostgreSQL container it contains.

If you haven’t done this before, you need to:

generate an SSH keypair
add your public SSH key to the dashboard
access your account via SSH protocol

ssh

Once you’ve entered the container, you need to stop it, delete the old WAL log file, and create a new empty one:

sudo service postgresql stop
/usr/pgsql-9.3/bin/pg_resetxlog -f /var/lib/pgsql/data/

Finally, start the container with the following command:

sudo service postgresql start

config master via ssh

Slave Database Configurations

Access the environment with standby database (named slave-database in our case) via SSH in the same way you did it for the master one:

config slave database

Just after you’ve entered the DB container you need to stop it and remove the old database with the following commands:

sudo service postgresql stop
rm -rf /var/lib/pgsql/data/*

Then copy a new database from the master server:

pg_basebackup -U webadmin -R -D /var/lib/pgsql/data/ –host={master_IP_address} –port=5432

Note: Substitute the {master_IP_address} value with the IP address of your master PostgreSQL server, located in the environment with Cyclos app deployed.

master ip

To complete the configuration of the standby PostgreSQL database, switch back to your Jelastic dashboard and click Config icon next to it.

In the conf folder locate the postgresql.conf file, uncomment the hot_standby = off parameter in the Standby Servers section, and change its value to on.

hot standby on

Save the changes.

Switch to your SSH console and run the container with the slave DB:

sudo service postgresql start

sudo service postgresql start

After both of your databases are configured, login to the admin panel of the master database (the one in the cyclos environment) and create a new database:

  • enter the DB name (e.g. cyclos4)
  • choose template0 and UTF8 encoding from the drop-down lists
  • click Create

This will result in a newly created database which will be replicated to the slave base.

Note: Because we have copied all data and configurations from the master PG server to the slave PG server, credentials for admin access to the slave database became the same as the master.

Navigate to the PostgreSQL Replication document to get more info on how to check if the database is replicated to the standby database.

Configure Cyclos

Final configurations of the Cyclos application need to be made to complete full clustering settings by switching on High Availability.

Within the Jelastic dashboard, click the Config button for Tomcat.

config tomcat

Navigate to webapps/ROOT/WEB-INF/classes folder and create cyclos.properties file.

Copy the content of cyclos-release.properties file in class folder and paste it to the newly created cyclos.properties file.

In the opened cyclos.properties file, specify your master PostgreSQL data:

  • in cyclos.datasource.jdbcUrl parameter state the host together with the name of database created while DB configuration:

 jdbc:postgresql://postgres-{env_name}.{hoster_domain}/{db_name}

  • database credentials you’ve received via email

Save the applied changes and Restart Tomcat.

Next we need to configure the cluster. Select the Change environment topology button next to your Cyclos environment.

cyclos topology

In the opened window, enable High Availability. Select the amount of resources for the automatically added NGINX-balancer node (it will handle and distribute all the requests in front of your cluster).

high availability

Click Open in browser and get started with Cyclos.

Note: That applying these changes to your environment takes several minutes and opening Cyclos for the first time can take just as long.

After opening Cyclos there are several configuration steps or you can simply use the credentials from your initial installation.

Cyclos license server authentication

cyclos4 system administrator settings

That’s how to get your own highly-reliable Cyclos cluster in the cloud, ensuring that no server is a single point of failure and that one server failure doesn’t overload the rest of the servers.

in Jelastic

0

0

Related Articles