Install MySQL 8.0 with Master‑Slave and Group Replication Using Simple Scripts
This guide introduces a set of scripts for installing MySQL 8.0, configuring master‑slave replication and group replication, detailing required files, command usage, repository location, and essential configuration notes for a three‑node deployment.
Overview
This toolkit provides Bash scripts to automate the deployment of MySQL 8.0, configure classic master‑slave replication, and set up MySQL Group Replication (MGR) on a small cluster.
Prerequisites
Place the following three files in a single directory (for example /root/soft/) and ensure they are executable: mysql8_install.sh – main driver script my_test.cnf – template my.cnf configuration file mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz – MySQL binary package (version 8.0.18)
Step 1 – Install and start MySQL
Run the installer on every node that will host a MySQL instance (both primary and replica servers): # /bin/bash mysql8_install.sh The script extracts the tarball, creates a data directory, and starts mysqld. By default it writes a configuration file under /etc/ named after the database (e.g., my_test.cnf) and creates the socket /tmp/mysql.sock.
Step 2 – Configure classic master‑slave replication
Execute the following command **only on the replica node** after the MySQL service is running on both sides: # /bin/bash mysql8_install repl The script performs the standard steps: creates a replication user on the master, sets server_id, enables binary logging, and runs CHANGE MASTER TO with the supplied master host, port, and credentials.
Step 3 – Configure MySQL Group Replication (MGR)
First run the command on the primary (writer) node, then repeat it on each secondary (reader) node: # /bin/bash mysql8_install mgr Before invoking the script, ensure that all three MySQL instances are started. Edit the script to replace placeholder IP addresses, ports, and hostnames with the values that match your environment. The script will:
Assign a unique server_id to each node
Enable the group_replication plugin
Configure group_replication_group_name, group_replication_local_address, and group_replication_group_seeds Start the group replication process
After a successful MGR setup, a generated configuration file mysqld-auto.cnf is placed in the data directory of each node.
Important notes
All three scripts assume a default data directory of /var/lib/mysql. Adjust the paths in the script if you use a different location.
The template my_test.cnf contains minimal settings; you may need to add custom buffers, InnoDB options, or security parameters for production use.
Network connectivity (firewall rules, SELinux/AppArmor) must allow MySQL port 3306 (or the port you configure) between all nodes.
Source code
The complete scripts and documentation are available at:
https://github.com/hcymysql/mysql_install
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
