As a critical component for most applications, data has to be available for end users in a dynamically changing environment. Storing data in one location is a subject to risk in case of a system failure. Therefore, you need to come up with a strategy on how to ensure high availability and one of the solutions is to maintain the data on multiple synchronized servers.
Having your data replicated to another database can be very helpful for a variety of reasons, such as improving performance, running backup services, analyzing information, and by all means alleviating system failures.
Among numerous database clustering solutions, Jelastic provides the PostgreSQL package with master-slave asynchronous replication that can be installed automatically and run with no additional configurations required.
Now let’s take a quick look at the package specs and follow the step-by-step installation guide.
PostgreSQL Replication Package for Instant Deploy
The presented PostgreSQL Replication solution for one-click installation is based on Jelastic certified PostgreSQL 9.5.5 template. By default, it deploys two database containers (one per role - master and slave) with asynchronous replication between them.
The primary (master) server runs active database which handles read-write operations, whilst the standby (slave) server operates with this DB copy and handles read-only operations. Therefore, if the primary database fails, the system will run data from the fail-over slave container.
Within the package, each database container has a default vertical scaling from 1 reserved to 24 dynamic cloudlets (up to 3 GiB of RAM and 9.6 GHz of CPU) that are allocated dynamically based on the incoming load. Subsequently, you can change the resource allocation limit by following the above-linked guide.
Now, let’s proceed further to get the PostgreSQL package up and running in the Cloud.
Deploying PostgreSQL Replication Package
The package installation is a fairly simple process that you can perform in just a few clicks.
1. Log in to the Jelastic Platform with your credentials and click Marketplace at the top pane.
Within the Apps section, use the search box to find the PostgreSQL Database Replication package and click Install.
When the package installation is completed, you’ll see a confirmation message with master node URL and simultaneously receive an email notification with your administration data.
Now, let’s put the master database into action to check that data is successfully replicated to the slave.
Testing PostgreSQL Database Replication
To ensure that data is replicated properly, we’ll create a new DB instance in the master container and check its presence inside the slave.
Create New PG Database
1. Click Open in browser next to the PostgreSQL master node to launch the phpPgAdmin web interface.
2. Under Servers, click PostgreSQL and log in with credentials you’ve received via email after the package installation.
3. Click Create database, fill in the Name box (e.g. Jelastic), and click Create.
Now, when the database is created in the master node, let’s check the replicated data within the slave container.
Check the Replication
To ensure that data replication from the master to the slave container works as intended, perform the following steps.
1. Click Open in browser next to the PostgreSQL slave node to launch the phpPgAdmin web interface.
2. Access admin interface with the same username and password that you’ve received via email after the package installation.
Once logged in, you can see and manage the database (Jelastic, in our example) that was earlier created in the master container.
That’s it! The PostgreSQL environment with master-slave asynchronous replication is up and ready for data processing.
As a next step, you can already connect this PostgreSQL replicated databases to your project. The process depends on application specifics, so follow the instructions below for:
Try out by yourself how easy it can be to handle multiple copies of essential data within replicated PostgreSQL databases with no need to make manual configurations. Register at one of our cloud hosting providers and get free trial account.