How to Replicate MySQL Database on Ubuntu 16.04

Installing MySQL Community Edition

We will need to SSH to each Ubuntu 16.04 server to install MySQL server. The default MySQL server available on the Ubuntu software repository doesn’t have the Group Replication plugin. So we will have to manually download the deb packages for MySQL Community Edition.

Generating Universally Unique Identifier (UUID) for the Group

Our MySQL Group replication service requires a unique group name. We are going to use the built in Linux uuidgen command to generate Universally Unique IDentifier (UUID).

Configuring MySQL Server 1

MySQL server should be up and running on the 3 Alibaba Cloud ECS instances. Next, we need to configure some settings on each server. We can do this by modifying the /etc/mysql/my.cnf file. Then replace the IP addresses with the correct values.

mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql>SET GLOBAL group_replication_bootstrap_group=ON;
mysql>START GROUP_REPLICATION;
mysql>SET GLOBAL group_replication_bootstrap_group=OFF;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | e3778cfd-b66e-11e8-aba5-42010a8e0002 | 172.16.0.1 | 3306 | ONLINE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)
mysql> create database sample_db;
mysql> use sample_db;
mysql> create table customers (customer_id INT PRIMARY KEY,
customer_name VARCHAR(50) NOT NULL) Engine = InnoDB;
mysql> insert into customers (customer_id, customer_name) values ('100', 'John James');
mysql> insert into customers (customer_id, customer_name) values ('200', 'Baby Doe');
mysql> insert into customers (customer_id, customer_name) values ('300', 'Jane Smith');

Related Blog Posts

How to Configure MySQL Master-Slave Replication on Ubuntu 16.04

  1. Install MySQL Server On Server 1 (Master)
  2. Edit MySQL Configuration File on Server 1
  3. Create a New User for Replication Services on Server 1
  4. Install MySQL On Server 2 (Slave)
  5. Modify the Configuration File on Server 2
  6. Change Master-Slave Configuration on Server 2
$ sudo mysql -u root -p
mysql> create database replica_demo;
Query OK, 1 row affected (0.01 sec)
$ sudo mysql -u root -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| replica_demo |
| sys |
+--------------------+
5 rows in set (0.00 sec)

Related Documenation

Standard dual-replica edition

Related Market Products

MySQL infrastructure powered by Websoft9(CentOS7.2)

Related Products

ApsaraDB RDS for MySQL

Related Course

Mysql Database Concepts and Operations

Original Source

https://www.alibabacloud.com/blog/mysql-database-replication-on-ubuntu_595014?spm=a2c41.13111930.0.0

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com