{"id":1185,"date":"2025-05-06T16:48:05","date_gmt":"2025-05-06T16:48:05","guid":{"rendered":"https:\/\/humtechno.com\/master\/?p=1185"},"modified":"2025-05-06T20:03:08","modified_gmt":"2025-05-06T20:03:08","slug":"mysql-group-replication-and-multi-master-nodes","status":"publish","type":"post","link":"https:\/\/humtechno.com\/master\/2025\/05\/06\/mysql-group-replication-and-multi-master-nodes\/","title":{"rendered":"MYSQL Group Replication and Multi Master Nodes"},"content":{"rendered":"\n<figure class=\"wp-block-embed is-provider-youtube wp-block-embed-youtube\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/youtu.be\/C_K-qtUumPI\n<\/div><\/figure>\n\n\n\n\n\n\n\n<p><a href=\"https:\/\/humtechno.com\/master\/wp-content\/uploads\/2025\/05\/MYSQL-Group-Replication-and-MultiMaster.pdf\">Download Free PDF<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p><strong>MySQL Group Replication<\/strong> is a high-availability solution that enables multiple MySQL server instances (a <em>group<\/em>) to synchronize data automatically, forming a fault-tolerant, distributed database system. It supports both <strong>single-primary<\/strong> and <strong>multi-primary<\/strong> modes.<strong><\/strong><\/p>\n\n\n\n<p><strong>Key Features<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Synchronous replication:<\/strong> Transactions are replicated to all members before commit (using a group communication system).<\/li>\n\n\n\n<li><strong>Automatic failover:<\/strong> In single-primary mode, if the current primary fails, a new one is elected.<\/li>\n\n\n\n<li><strong>Conflict detection\/resolution:<\/strong> In multi-primary mode, it handles conflicts if two nodes try to update the same data.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Use Cases<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>High availability and disaster recovery.<\/li>\n\n\n\n<li>Multi-datacenter deployments (with care).<\/li>\n\n\n\n<li>Applications needing consistency and auto failover without external tools.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Architecture<\/h3>\n\n\n\n<p>Each MySQL server (node) in the group:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maintains its own copy of the data.<\/li>\n\n\n\n<li>Communicates over the network with other members via <strong>group communication<\/strong>.<\/li>\n\n\n\n<li>Uses <strong>write sets<\/strong> and <strong>certification<\/strong> to ensure consistency.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Modes<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Single-primary mode (default)<\/strong><ol><li>One node handles writes.<\/li><\/ol>\n<ol class=\"wp-block-list\">\n<li>Others are read-only unless the primary fails.<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><strong>Multi-primary mode<\/strong><ol><li>All nodes can handle writes.<\/li><\/ol>\n<ol class=\"wp-block-list\">\n<li>Conflict detection is necessary.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n\n\n\n<p><strong><u>How to Configure<\/u><\/strong><\/p>\n\n\n\n<p><strong>Steps for Configure Group Replication with Multi Master Nodes<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install Operating System on All Nodes<\/li>\n\n\n\n<li>Define IP Address for Each Node<\/li>\n\n\n\n<li>Define Host Name of Each Nodes<\/li>\n\n\n\n<li>Enter Host Name of All Node in each Node etc\/hosts<\/li>\n\n\n\n<li>Download MYSQL RPM<\/li>\n\n\n\n<li>Install MYSQL RPM<\/li>\n\n\n\n<li>Define Table Case sensitive in mysql Configure File<\/li>\n\n\n\n<li>Start MYSQL services<\/li>\n\n\n\n<li>Secure MYSQL Database<\/li>\n\n\n\n<li>Create Users Required for Replication<\/li>\n\n\n\n<li>Define Configure Parameter on Each Node<\/li>\n\n\n\n<li>Stop Firewall<\/li>\n\n\n\n<li>Disable SELINUX<\/li>\n\n\n\n<li>Restart MYSQL Services<\/li>\n\n\n\n<li>Define Replication Source<\/li>\n\n\n\n<li>Start Group Replication on Node 1 with group_replication_bootstrap_group=ON;<\/li>\n\n\n\n<li>Start Group Replication on Node 2 and Node 3<\/li>\n\n\n\n<li>Enable Read Only Node on node 2 and Node 3<\/li>\n\n\n\n<li>Monitor Group Replication<\/li>\n<\/ol>\n\n\n\n<p><strong><u>On Each Database Nodes<\/u><\/strong><\/p>\n\n\n\n<p>vi \/etc\/hosts<\/p>\n\n\n\n<p>127.0.0.1&nbsp;&nbsp; localhost localhost.localdomain localhost4 localhost4.localdomain4<\/p>\n\n\n\n<p>192.168.179.128 mysql1<\/p>\n\n\n\n<p>192.168.179.129 mysql2<\/p>\n\n\n\n<p>192.168.179.130 mysql3<\/p>\n\n\n\n<p><strong><u>On Node1 Database<\/u><\/strong><\/p>\n\n\n\n<p>vi \/etc\/hostname<\/p>\n\n\n\n<p>mysql1<\/p>\n\n\n\n<p><strong><u>On Node2 Database<\/u><\/strong><\/p>\n\n\n\n<p>vi \/etc\/hostname<\/p>\n\n\n\n<p>mysql2<\/p>\n\n\n\n<p><strong><u>On Node3 Database<\/u><\/strong><\/p>\n\n\n\n<p>vi \/etc\/hostname<\/p>\n\n\n\n<p>mysql3<\/p>\n\n\n\n<p><strong><u>On Each Database Nodes<\/u><\/strong><\/p>\n\n\n\n<p>mkdir -p \/software<\/p>\n\n\n\n<p>cd \/software<\/p>\n\n\n\n<p>wget https:\/\/repo.mysql.com\/mysql80-community-release-el8-3.noarch.rpm<\/p>\n\n\n\n<p>rpm -ivh mysql80-community-release-el8-3.noarch.rpm<\/p>\n\n\n\n<p>yum install mysql-server \u2013y<\/p>\n\n\n\n<p><strong><u>Define Table Case sensitive in mysql Configure File on Each Database Nodes<\/u><\/strong><\/p>\n\n\n\n<p>vi \/etc\/my.cnf<\/p>\n\n\n\n<p>[mysqld]<\/p>\n\n\n\n<p>lower_case_table_names = 1<\/p>\n\n\n\n<p>systemctl start mysqld<\/p>\n\n\n\n<p>systemctl enable mysqld<\/p>\n\n\n\n<p><strong><u>Secure MYSQL Database<\/u><\/strong><\/p>\n\n\n\n<p>mysql_secure_installation<\/p>\n\n\n\n<p><strong><u>Create Users Required for Replication on Each Node<\/u><\/strong><\/p>\n\n\n\n<p>mysql -uroot -pOracle123<\/p>\n\n\n\n<p>CREATE USER &#8216;root&#8217;@&#8217;%&#8217; IDENTIFIED BY &#8216;Oracle123&#8217;;<\/p>\n\n\n\n<p>GRANT ALL PRIVILEGES ON *.* TO &#8216;root&#8217;@&#8217;%&#8217; WITH GRANT OPTION;<\/p>\n\n\n\n<p>FLUSH PRIVILEGES;<\/p>\n\n\n\n<p>CREATE USER &#8216;rpl_user&#8217;@&#8217;%&#8217; IDENTIFIED WITH mysql_native_password BY &#8216;Oracle123&#8217;;<\/p>\n\n\n\n<p>GRANT REPLICATION SLAVE ON *.* TO &#8216;rpl_user&#8217;@&#8217;%&#8217;;<\/p>\n\n\n\n<p>GRANT CONNECTION_ADMIN ON *.* TO &#8216;rpl_user&#8217;@&#8217;%&#8217;;<\/p>\n\n\n\n<p>GRANT BACKUP_ADMIN ON *.* TO &#8216;rpl_user&#8217;@&#8217;%&#8217;;<\/p>\n\n\n\n<p>GRANT GROUP_REPLICATION_STREAM ON *.* TO &#8216;rpl_user&#8217;@&#8217;%&#8217;;<\/p>\n\n\n\n<p>GRANT ALL PRIVILEGES ON *.* TO &#8216;rpl_user&#8217;@&#8217;%&#8217;;<\/p>\n\n\n\n<p>GRANT REPLICATION SLAVE, BACKUP_ADMIN, CONNECTION_ADMIN ON *.* TO &#8216;rpl_user&#8217;@&#8217;%&#8217;;<\/p>\n\n\n\n<p>FLUSH PRIVILEGES;<\/p>\n\n\n\n<p><strong><u>Define Configure Parameter on Each Node<\/u><\/strong><\/p>\n\n\n\n<p>vi \/etc\/my.cnf<\/p>\n\n\n\n<p>[mysqld]<\/p>\n\n\n\n<p>lower_case_table_names = 1<\/p>\n\n\n\n<p>disabled_storage_engines=&#8221;MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY&#8221;<\/p>\n\n\n\n<p>server_id=1 -\u2013 <strong>Change on Each Node<\/strong><\/p>\n\n\n\n<p>gtid_mode=ON<\/p>\n\n\n\n<p>enforce_gtid_consistency=ON<\/p>\n\n\n\n<p>plugin_load_add = &#8220;group_replication.so&#8221;<\/p>\n\n\n\n<p>group_replication_group_name=&#8221;aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa&#8221;<\/p>\n\n\n\n<p>group_replication_start_on_boot=OFF<\/p>\n\n\n\n<p>group_replication_local_address= &#8220;192.168.179.128:33061&#8221; -\u2013 <strong>Change on Each Node<\/strong><\/p>\n\n\n\n<p>group_replication_group_seeds= &#8220;192.168.179.128:33061,192.168.179.129:33061,192.168.179.130:33061&#8221;<\/p>\n\n\n\n<p>group_replication_bootstrap_group=OFF<\/p>\n\n\n\n<p>group_replication_ip_allowlist= &#8220;192.168.179.128,192.168.179.129,192.168.179.130&#8221;<\/p>\n\n\n\n<p>group_replication_single_primary_mode = OFF&nbsp; &#8212; For Multi Master Nodes<\/p>\n\n\n\n<p>lower_case_table_names = 1<\/p>\n\n\n\n<p><strong><u>Stop Firewall and Disable SELINUX<\/u><\/strong><\/p>\n\n\n\n<p>systemctl stop firewalld<\/p>\n\n\n\n<p>chkconfig firewalld off<\/p>\n\n\n\n<p>setenforce 0<\/p>\n\n\n\n<p>vi \/etc\/sysconfig\/selinux<\/p>\n\n\n\n<p>ELINUX=disabled<\/p>\n\n\n\n<p>systemctl restart mysqld<\/p>\n\n\n\n<p><strong><u>Define Replication Source<\/u><\/strong><\/p>\n\n\n\n<p>mysql -uroot -pOracle123<\/p>\n\n\n\n<p>CHANGE REPLICATION SOURCE TO SOURCE_USER=&#8217;rpl_user&#8217;,&nbsp; SOURCE_PASSWORD=&#8217;Oracle123&#8242;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FOR CHANNEL &#8216;group_replication_recovery&#8217;;<\/p>\n\n\n\n<p><strong><u>Start Group Replication on Node 1<\/u><\/strong><\/p>\n\n\n\n<p>mysql -uroot -pOracle123<\/p>\n\n\n\n<p>SET GLOBAL group_replication_bootstrap_group=ON;<\/p>\n\n\n\n<p>START GROUP_REPLICATION;<\/p>\n\n\n\n<p>SET GLOBAL group_replication_bootstrap_group=OFF;<\/p>\n\n\n\n<p><strong><u>Start Group Replication on Node 2 and Node 3<\/u><\/strong><\/p>\n\n\n\n<p>mysql -uroot -pOracle123<\/p>\n\n\n\n<p>START GROUP_REPLICATION;<\/p>\n\n\n\n<p><strong><u>Enable Read Only on Node 2 and Node 3<\/u><\/strong><\/p>\n\n\n\n<p>SET GLOBAL super_read_only = ON;<\/p>\n\n\n\n<p><strong><u>Monitor on Group Replication<\/u><\/strong><\/p>\n\n\n\n<p>SELECT * FROM performance_schema.replication_group_members;<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_siteseo_robots_primary_cat":"17","pagelayer_contact_templates":[],"_pagelayer_content":"","neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[15],"tags":[30,31,32],"class_list":["post-1185","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql-cluster","tag-mysql-group-replication","tag-mysql-multi-master"],"_links":{"self":[{"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/posts\/1185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/comments?post=1185"}],"version-history":[{"count":3,"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/posts\/1185\/revisions"}],"predecessor-version":[{"id":1192,"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/posts\/1185\/revisions\/1192"}],"wp:attachment":[{"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/media?parent=1185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/categories?post=1185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/humtechno.com\/master\/wp-json\/wp\/v2\/tags?post=1185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}