PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

栏目: IT技术 · 发布时间: 4年前

内容简介: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 ho
PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

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 from one database to another allows to alleviate system failures, improve productivity, run backup services, and analyze data with no performance degrade.

Among numerous database clustering solutions , Jelastic provides PostgreSQL with master-slave asynchronous replication based on the certified templates. By default, it deploys two database containers (one per role - master and slave). 

The primary (master) server runs an active instance of the database and accepts read-write operations, whilst the standby (slave) server runs a copy of the active database and handles read-only operations. Therefore, if the primary database fails due to container failure or database corruption, the slave server (running in a separate container) has to be promoted to the master retaining the writes to ensure database availability.

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

Within the cluster topology, each database container has a defaultvertical scaling from 2 reserved to 32 dynamic cloudlets (up to 4 GiB of RAM and 12.8 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.

Database Cluster can be installed automatically:

  • As a Marketplace application
  • Via embedded Auto-Clustering feature at the Dashboard

Within this tutorial, we will cover both.

PostgreSQL Cluster Installation from Marketplace

PostgreSQL Master-Slave Clusterpackage can be easily found in the Marketplace. 

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

If required change database Version , Environment name and destinationRegion in the installation window.

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

PostgreSQL Auto-Clustering Mode

In Jelastic, auto-clustering is enabled by a specially designed switch that makes clustering easier than ever before. To do this just invoke thetopology wizard at the dashboard, pick the software stack(e.g. PostgreSQL 12.3) and slide the Auto-Clustering switch to the right.

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

Change the destination region if necessary. Here we chose Premium .

Tip:The PostgreSQL Replication package sources are available within Jelastic JPS Collection alongside with other useful solutions, any of which can be integrated throughimporting a manifest.yaml or manifest.jps file from the appropriate repository.

Cluster Topology

Database cluster topology obtained upon both deployments looks like as follows:

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

When the database cluster installation is completed, you’ll see a confirmation message with master node URL and database access credentials. All this information is duplicated via email.

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

Note:If the cluster was installed with auto-clustering functionality the credentials are sent via email only.

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 a New Database

1. Click Open in Browser next to the PostgreSQL Master node to launch the phpPgAdmin web interface.

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

2. Under Servers , click PostgreSQL and log in with credentials you’ve obtained upon cluster installation. 

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

3. Click Create database

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

4. Fill in the Name box (e.g. Jelastic ), and click Create

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

Now, when the database is created in the master node, let’s check the replicated data within the slave one.

Check the Replication

To make sure that data replication from the master to the slave database node works as intended, perform the following steps.

1. Click Open in Browser next to the PostgreSQL Slave node to launch the phpPgAdmin web interface.

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

2. Access admin interface with the same username and password that you’ve used to access the master node.

PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication

Once logged in, you can see the replicated database ( Jelastic , in our example).

That’s it! The PostgreSQL environment with master-slave asynchronous replication is up and ready for data processing.

As a next step, you can connect this PostgreSQL replicated database 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 Jelastic cloud hosting providers and get a free account for testing.


以上所述就是小编给大家介绍的《PostgreSQL Auto-Clustering with Asynchronous Master-Slave Replication》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

数据结构与算法分析

数据结构与算法分析

韦斯 (Mark Allen Weiss) / 陈越 / 机械工业出版社 / 2016-3-1 / 69.00元

本书是国外数据结构与算法分析方面的经典教材,使用卓越的Java编程语言作为实现工具讨论了数据结构(组织大量数据的方法)和算法分析(对算法运行时间的估计)。本书把算法分析与有效率的Java程序的开发有机地结合起来,深入分析每种算法,内容全面、缜密严格,并细致讲解精心构造程序的方法。一起来看看 《数据结构与算法分析》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具