How to Set Up MySQL 8 Multi-Master Group Replication on Ubuntu 22.04

preview_player
Показать описание
In this video, I will set up MySQL multi-primary group replication using a set of three Ubuntu 22.04 servers.

PLEASE SUBSCRIBE :)
PLEASE HIT LIKE IF IT HELPED :)

Steps:
Install MySQL
apt-get update; apt-get -y install mysql-server-8.0

Open up access to the ports 3306 and 33061 in the firewall
ufw allow 3306

Server 1
ufw allow from server2_ip to any port 33061
ufw allow from server3_ip to any port 33061

Server 2
ufw allow from server1_ip to any port 33061
ufw allow from server3_ip to any port 33061

Server 3
ufw allow from server1_ip to any port 33061
ufw allow from server2_ip to any port 33061

Generate UUID
uuidgen
Output
168dcb64-7cce-473a-b338-6501f305e561

Modify the configuration of server 1.

ALL MYSQL
[mysqld]

# General replication settings
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"
gtid_mode = ON
enforce_gtid_consistency = ON
master_info_repository = TABLE
relay_log_info_repository = TABLE
binlog_checksum = NONE
log_replica_updates = ON
log_bin = binlog
binlog_format = ROW
transaction_write_set_extraction = XXHASH64
loose-group_replication_bootstrap_group = OFF
loose-group_replication_start_on_boot = OFF
loose-group_replication_ssl_mode = REQUIRED
loose-group_replication_recovery_use_ssl = 1

# Shared replication group configuration
loose-group_replication_group_name = "168dcb64-7cce-473a-b338-6501f305e561"
loose-group_replication_ip_allowlist = "mysql1,mysql2,mysql3"
loose-group_replication_group_seeds = "mysql1:33061,mysql2:33061,mysql3:33061"

# For multi-primary mode, where any host can accept writes
loose-group_replication_single_primary_mode = OFF
loose-group_replication_enforce_update_everywhere_checks = ON

# Host specific replication configuration
bind-address = "0.0.0.0"
server_id = " "
report_host = " "
loose-group_replication_local_address = " :33061"

Restart mysql
systemctl restart mysql

Configuring Replication Users and Enabling Group Replication Plugin
mysql

SET SQL_LOG_BIN=0;
CREATE USER 'repl'@'%' IDENTIFIED BY 'Password123!' REQUIRE SSL;
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
CHANGE REPLICATION SOURCE TO SOURCE_USER='repl', SOURCE_PASSWORD='Password123!' FOR CHANNEL 'group_replication_recovery';
SHOW PLUGINS;

Starting Group Replication
Server 1
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group=OFF;

Server 2 and Server 3
START GROUP_REPLICATION;

Test replication
Server 3
CREATE DATABASE lazy;

Server 1
SHOW DATABASES;
USE lazy;
CREATE TABLE admins (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL
);

Server 2
SHOW DATABASES;
USE lazy;
SHOW TABLES;

Chapters:
00:00 Intro
00:17 Install MySQL
00:50 Setup Firewall
02:10 Generate UUID
05:51 Configure Replication User
06:58 Enable Group Replication Plugin
07:33 Start Group Replication
08:36 Test and Verification

Drop me your feedback and comments below.

That's all for now.

If this video helped you in any way, please like share and subscribe!

Thank you!!!
Рекомендации по теме
Комментарии
Автор

thanks for your input, was easy to follow.

Only thing to add, if a node is rebooted or mysql is restarted it doesn't auto join unless you add
= ON

icepicknz
Автор

Great tutorial. I did it. Thank you so much. However, in my case, there were a few differences. I made the following adjustments:

1. I'm using Red Hat 8, so I had to disable SELinux;

2. I installed MySQL on one machine and cloned it to the second and third machines. Therefore, I had to delete the auto.cnf file located at /var/lib/mysql/ and restart the MySQL service (systemctl restart mysqld.service).

=> In both cases, errors occurred when running the command: START GROUP_REPLICATION;

anginhphong
Автор

Great Job but i have one question, what about if server one that run bootstrap is down or restart ?

muhammadatallah
Автор

Hi, in the server 2 or server 3 when create Database show this

ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement

Server2 After reboot server and Start Replication

ERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log.

But when test tutorial all start, but can't create database, only on server1, and don't see in another server.

Regards

jarscr
Автор

Hello sir, i tried your video and he works yesterday But today i launch my vms and when i want to start and test the replication i have this errors in the 2 others nodes "ERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log." What's wrong? Do we need to do a configuration again after restart? Thanks for the course.

mamadouyacineGueye
Автор

When i am followed your steps in second node GROUP_REPLICATION was not started and it was getting this error

START GROUP_REPLICATION;
ERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log.

HariDasari-wlqm
Автор

I don´t understand why not on faster Debian, why on Ubuntu...

tmakademia