未加星标

MariaDB Galera Cluster Replication

字体大小 | |
[数据库(mysql) 所属分类 数据库(mysql) | 发布者 店小二05 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

Extending the topic around database auto-clustering , we’d like to cover MariaDB Galera Cluster, high availability synchronous replication solution, that provides:

True multi-master topology Automatic new node provisioning No data loss when nodes crash Data replicas remain consistent Automatic membership control No complex and time-consuming failovers Parallel transaction execution on all cluster nodes No slave lag No lost transactions Reads/writes scalability Smaller client latencies Support of multi-cloud and multi-region deployments

According to official documentation , Galera implements so-called certification based replication. The basic idea is that the transaction to be replicated the write set not only contains the database rows to replicate, it also includes information about all the locks that were held by the database (ie. InnoDB) during the transaction. Each node then certifies the replicated write set against other write sets in the applier queue, and if there are no conflicting locks, we know that the write set can be applied. At this point, the transaction is considered committed, after which each node continues to apply it to the InnoDB tablespace.

This approach is also called virtually synchronous replication since it is logically synchronous, but actual writing (and committing) to the InnoDB tablespace happens independently (and thus, strictly speaking, asynchronously) on each node.

In Jelastic, Galera Cluster can be automatically activated while creating the environment. The default topology consists of 2 ProxySQL load balancers and 3 MariaDB instances.
MariaDB Galera Cluster Replication
MariaDB Galera Cluster Installation Navigate to Jelastic dashboard, click Create Environment and select MariaDB server within topology wizard. Then activate Auto-Clustering and choose Galera scheme . You can increase the default number of databases by pressing “ + ” in the Horizontal Scaling block.
MariaDB Galera Cluster Replication

In a few minutes, the environment will be created with the chosen topology and pre-configured interconnections.


MariaDB Galera Cluster Replication
You can perform the state-of-health monitoring of the cluster nodes via the Orchestrator admin panel that can be accessed with the credentials from the email related to ProxySQL Load Balancer deployment. The cluster members are shown at the panel as separated clusters with one instance inside.
MariaDB Galera Cluster Replication
Application Connection to MariaDB Galera Cluster

Let’s establish a connection to our MariaDB Galera Cluster from Java web-application, using ProxySQL load balancer as an entrypoint . Follow the linked guide to find out about the connection to other types of applications.

The creation of each master node within MariaDB cluster is accompanied by the email with phpMyAdmin credentials. Accessing the database via phpMyAdmin panel is useful for debugging or performing some manual operations on the databases.

1. Log in to phpMyAdmin using Admin Panel URL , Username and Password (received in the email). Choose the existing database test (or create whatever you want) at the left pane. After that in the right pane you will see there are no tables in the database test .
MariaDB Galera Cluster Replication
2. Get back to Jelastic dashboard. We use a separate environment with a Tomcat 9 application server for this example. Now, we have to create Database config file for our test application. To do this, click on the Config icon next to your compute node, then navigate to /opt/tomcat/temp directory and create mydb.cfg file using platform built-in file-manager .
MariaDB Galera Cluster Replication

3. Put the following lines into the mydb.cfg file and fill all the fields with entrypoint credentials like on the picture above.

host=jdbc:mariadb:// {connect_URL} / {db_name}?usePipelineAuth=false

username= {user}

password= {password}

driver=org.mariadb.jdbc.Driver

where:

{connect_URL} link to your DB cluster load balancer (i.e. ProxySQL node) {db_name} name of the database. We chose test in the first step usePipelineAuth if activated different queries are executed using pipeline (all queries are sent, only then all results are read), permitting faster connection creation. This value should be set to false , as such implementation doesn’t work with the ProxySQL in front of the cluster {user} and {password} database credentials received in the email

Download test application using the link below anddeploy to the Tomcat server.

https://download.jelastic.com/public.php?service=files&t=b2c6e4e01d487dfd5af953ba31dac848&download


MariaDB Galera Cluster Replication

Note :

To get full compatibility with proxy layer use the latest JDBC connector for MariaDB . Put connectors to /opt/tomcat/webapps/ROOT/WEB-INF/lib/

本文数据库(mysql)相关术语:navicat for mysql mysql workbench mysql数据库 mysql 存储过程 mysql安装图解 mysql教程 mysql 管理工具

分页:12
转载请注明
本文标题:MariaDB Galera Cluster Replication
本站链接:https://www.codesec.net/view/620882.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mysql) | 评论(0) | 阅读(9)