Running Cyclos Cluster on Jelastic Platform-as-Infrastructure

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Cyclos is a complete on-line banking system with additional modules such as e-commerce and communication tools. With the dynamic structure of Cyclos, you can ‘build’ a dedicated payment system from scratch, by simply changing the configuration.

Recently, Cyclos released a new fourth version and Jelastic enabled the ability to install it, in just one click. This can be done via the Cyclos site (you need to register first) or via our JPS widget as seen in our Cyclos 4 document.

In 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 requirement to run a single Cyclos instance is 500 Mb (so you need to use at least 4 cloudlets).

In this tutorial we’ll show you how to configure a highly reliable and scalable Cyclos cluster with master-slave database replication – and High Availability enabled within Jelastic’s Cloud hosting.scheme_new_07

The High Availability helps to prevent failed transactions and other issues that can influence your users. Extending the application across a number of the servers provides redundancy. The redundancy ensures that if one of the servers fail, 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 end-users will never notice any changes.

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

A. Jelastic Environment Creation

Firstly, we need to prepare a basis for our application cluster – an environment with all of the required containers.

1. Sign up for a Jelastic account (if you haven’t done this before) or log into your Jelastic account.

2. Click Create environment and select:

  • Tomcat 7 as your application server
  • PostgreSQL 9.3 as the database you want to use

Note: that you need to use a version of PostgreSQL not less than 9.3

cyclos environment

Next, enter your environment name, for example, cyclos, and click Create.

It will take just a minute for your environment to be created.

environment listed

B. Cyclos Deployment

Now, we are ready to deploy a Cyclos application.

1. To download the Cyclos package, navigate to the Cyclos web site and register if you haven’t done this before.

download button

register at cyclos

2. Confirm your account creation via the email received.

Sign in with your credentials and download the installation package.

Note: that here you can also use Jelastic one-click install button in order to get Cyclos automatically installed. It is recommended to install Cyclos manually if you want to set a clustered solution.

cyclos

3. Extract the files from .zip package you have just downloaded.

web

4. Create a .WAR file from web folder content (cyclos-4.0.1/web/).

Just put the content of the web folder to another zip archive file, for example cyclos_4.zip, and rename it to cyclos_4.war or any other name with the .war extension.

5. Upload your Cyclos war package to the Deployment manager.

upload war file

5. Once the package is in Jelastic, deploy it to the environment you have just created.

deploy cyclos

C. Configure Database Replication

When your Cyclos application is deployed, you can proceed to the database settings. So let’s configure PostgreSQL master-slave replication in order to protect your application from downtime or data loss.

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

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

postgresql environment

Master DB Configs

1. 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.

2. Open conf > postgresql.conf file. Uncomment and change the following settings for enabling streaming replication:

wal_level = hot_standby
max_wal_senders = 3
archive_mode = on
archive_command = ‘cp %p /tmp/%f’

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

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

host replication all {standby_ip_address}/32 trust

Note: that you need to add one additional line after the added settings.

Don’t forget to Save the changes you’ve performed.

5. Now you should access your environment with master DB via SSH and enter the PostgreSQL container it contains.

In the case you haven’t done the similar operations before, you need to:

cyclos env via ssh

6. 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/

7. Finally, start the container with the following command:

sudo service postgresql start

config master via ssh

Slave DB Configs

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

cyclos slave ssh

2. 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/*

3. 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: you should substitute the {master_IP_address} valuewith the IP address of your master PostgreSQL server, located in the environment with Cyclos app deployed.

config slave via ssh

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

5. 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.

enable hot standby slave

Save the changes you’ve performed.

6. Finally, switch to your SSH console and run the container with slave DB:

sudo service postgresql start

start slave container

After both of your databases are configured, log in 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

master-cyclos0db

As a result, you’ll get a newly created database which will be replicated to the slave base also.

NOTE: as we’ve copied all the 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 to the master’s one.

master-db

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

D. Configure Cyclos

Now, we need to make the final configurations of our Cyclos application and then complete full clustering settings by switching on High Availability.

  1. Open the Jelastic dashboard and click Config button for Tomcat.

tomcat config

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

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

4. 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

server-conf

Save the applied changes and Restart Tomcat.

3. Finally, let’s configure the cluster itself. Click on the Change environment topology button next to your Cyclos environment.

change topology

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

HA

4. Click Open in browser and proceed to work.

open

Note: that the first Cyclos opening can take a few minutes, please be patient.

After opening, you need to go through several steps of the Cyclos configuration wizard using credentials you’ve registered at the Cyclos site previously.

cyclos credentials

That’s all! Now, you have your own highly-reliable Cyclos cluster in the cloud. This cluster ensures that no server is a single point of failure. And, the cloud ensures that one server failure doesn’t overload the rest of the servers. Feel free to leave a comment below about your Cyclos clustering experience and subscribe to our blog, to see more clustered solutions.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates