


Detailed introduction to the construction and deployment process of MySQL Group Replication[Single-Primary Mode]
1, AboutMySQL Group Replication
Group-based Replication (Group-basedReplication) is a method used in fault-tolerant systems technology in. Replication-group is composed of multiple servers (nodes) that can communicate with each other.
In the communication layer, Groupreplication implements a series of mechanisms: such as atomic message delivery and total ordering of messages.
These atomic and abstract mechanisms provide strong support for implementing more advanced database replication solutions.
MySQL Group Replication implements a multi-master, fully updated replication protocol based on these technologies and concepts.
In short, a Replication-group is a group of nodes. Each node can execute transactions independently, and read and write transactions will be coordinated with other nodes in the group before committing.
Therefore, when a transaction is ready to be submitted, it will automatically be atomically broadcast within the group to inform other nodes of what content has been changed/what transactions have been performed.
This atomic broadcast method keeps this transaction in the same order on every node.
This means that each node receives the same transaction log in the same order, so each node replays these transaction logs in the same order, and ultimately the entire group maintains a completely consistent state.
However, there may be resource contention between transactions executed on different nodes. This phenomenon easily occurs in two different concurrent transactions.
Suppose there are two concurrent transactions on different nodes that update the same row of data, then resource contention will occur.
Faced with this situation, GroupReplication determines that the transaction submitted first is a valid transaction and will be repeated in the entire group. The transaction submitted later will be directly interrupted, or rolled back, and finally discarded.
Therefore, this is also a shared-nothing replication scheme, and each node saves a complete copy of the data. See the following picture 01.png, which describes the specific workflow and can be compared with other solutions concisely. This replication scheme is, to some extent, similar to the Replication method of the database state machine (DBSM).
2, install mysql5.7.17
Official download, but the official only keeps the latest version. The url address 5.7.17 may not be valid for a long time, so it may not be necessary. I have kept it on Baidu Cloud Disk. The version is 5.7.17. You can go there at any time. Download and use,
Set /etc/hosts mapping on the three db servers, as follows:
192.168.121.71 db1 .111 db2 192.168.121.24 db3 |
#Database server address | Data Directory 68.121.71(db1) | 3317 | ##/data/mysql/data##12001 |
192.168.121.111(db2) | 3317 | /data/mysql/data | 12002 |
##192.168.121.24 (db3) |
3317 |
/data/mysql/data |
##12003 |
##3 |
, create a replication environment | Set hostname and ip mapping
Set on db1, db2, and db3 vim /etc/hosts 192.168.121.71 db1 hch_test_dbm2_121_71 192.168.121.111 db2 bpe_service 192.168.121.24 db3 hch_test_web_1_24 Copy after login | Create a replication account on db1/db2/db3:
4, install
group replication
plug-in
Install the group replication plug-in on db1, db2, and db3 in sequencemy.cnf: |
5
, configure group replicationparameters
Make surebinlog_formatrowFormat. mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW |
+---------------+-------+
1 row in set (0.00 sec)
mysql>
Copy after loginTwo configuration methods, add OR configuration file online5.1Add online
mysql> show variables like 'binlog_format'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | binlog_format | ROW | +---------------+-------+ 1 row in set (0.00 sec) mysql>
Configuration:(1) The configuration commands are as follows, specific to a certain
db The nodes will be adjusted, and most of the parameters are consistent:set @@global.transaction_write_set_extraction = XXHASH64;
set @@global.group_replication_start_on_boot = OFF;
set @@global.group_replication_bootstrap_group = OFF;
set @@global.group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d6";
set @@global.group_replication_local_address = 'db1:6606';
set @@global.group_replication_group_seeds = 'db2:6607,db3:6608';
Copy after login
(2) Inset @@global.transaction_write_set_extraction = XXHASH64; set @@global.group_replication_start_on_boot = OFF; set @@global.group_replication_bootstrap_group = OFF; set @@global.group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d6"; set @@global.group_replication_local_address = 'db1:6606'; set @@global.group_replication_group_seeds = 'db2:6607,db3:6608';
The execution process is as follows:
is as follows: The execution process is as follows: (1) db1上的my.cnf配置: (2)db2上的my.cnf配置: (3)db3上的my.cnf配置: 配置完后,重启3个db上的mysql服务,本次案例,我们选择5.2 配置文件配置方式实现。 开始构建group replication集群,通常操作命令 Db1上建立基本主库master库: Db2上启动group_replication: Db3上启动group_replication: 最后查看集群状态,都为ONLINE就表示OK: 测试,在master库db1上建立测试库db1,测试表t1,录入一条数据 去db2/db3上可以看到数据已经同步过去 然后在db2/db3上执行inert操作,则拒绝,因为db2、db3为readonly MySQL窗口报错: 【解决办法】: 根据提示打开group_replication_allow_local_disjoint_gtids_join选项,mysql命令行执行: 再执行开启组复制: 在db1上查询集群组成员 再查看后台error日志, 【解决办法】: 看报错[ERROR] Slave I/O for channel'group_replication_recovery': error connecting to master 'repl@hch_test_dbm2_121_71:3317'- retry-time: 60 retries: 1, Error_code:2005,连接master库不上,所以问题在这里,我们赋予的复制账号是ip的repl@'192.168.%',所以还需要做一个hostname(hch_test_dbm2_121_71)和db1的ip地址192.168.121.71的映射关系。 建立hostname和ip映射 然后在db2上执行如下命令后重新开启group_replication即可。 再去master库db1上,查看group_replication成员,会有db2的显示 操作问题 【解决办法】: |
The above is the detailed content of Detailed introduction to the construction and deployment process of MySQL Group Replication[Single-Primary Mode]. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

Recovering deleted rows directly from the database is usually impossible unless there is a backup or transaction rollback mechanism. Key point: Transaction rollback: Execute ROLLBACK before the transaction is committed to recover data. Backup: Regular backup of the database can be used to quickly restore data. Database snapshot: You can create a read-only copy of the database and restore the data after the data is deleted accidentally. Use DELETE statement with caution: Check the conditions carefully to avoid accidentally deleting data. Use the WHERE clause: explicitly specify the data to be deleted. Use the test environment: Test before performing a DELETE operation.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.
