2019.10.17 MySQL semi-synchronous replication

Before doing synchronization master-slave MySQL master-slave replication do first half

First, deploy MySQL master-slave semi-synchronous replication

Semi-synchronous replication support a variety of plug-ins: / usr / lib64 / MySQL / plugin / *

Semi-synchronous replication plug-ins:

 semisync_master.so

 semisync_slave.so

[root@localhost ~]# rpm -ql mariadb-server | grep semisync
/usr/lib64/mysql/plugin/semisync_master.so
/usr/lib64/mysql/plugin/semisync_slave.so

1,111,112 plug-in is installed into the mysql View

[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.41-MariaDB-log MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show plugins;

2. If not, then first installed in the master node and enable the plugin:

MariaDB [(none)]> install plugin rpl_semi_sync_master soname 'semisync_master.so';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> show plugins;

MariaDB [(none)]> show global variables like '%semi%';
+------------------------------------+-------+
| Variable_name | Value |
+------------------------------------+-------+
| rpl_semi_sync_master_enabled | OFF |
| rpl_semi_sync_master_timeout | 10000 |
| rpl_semi_sync_master_trace_level | 32 |
| rpl_semi_sync_master_wait_no_slave | ON |
+------------------------------------+-------+
4 rows in set (0.00 sec)

MariaDB [(none)]> set @@global.rpl_semi_sync_master_enabled=ON;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show global variables like '%semi%';

+------------------------------------+-------+
| Variable_name | Value |
+------------------------------------+-------+
| rpl_semi_sync_master_enabled | ON |
| rpl_semi_sync_master_timeout | 10000 |
| rpl_semi_sync_master_trace_level | 32 |
| rpl_semi_sync_master_wait_no_slave | ON |
+------------------------------------+-------+
4 rows in set (0.00 sec)

3, the installation from the node and enable the plugin:

MariaDB [(none)]> install plugin rpl_semi_sync_master soname 'semisync_master.so';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> show plugins;

MariaDB [(none)]> show global variables like '%semi%';
+------------------------------------+-------+
| Variable_name | Value |
+------------------------------------+-------+
| rpl_semi_sync_master_enabled | OFF |
| rpl_semi_sync_master_timeout | 10000 |
| rpl_semi_sync_master_trace_level | 32 |
| rpl_semi_sync_master_wait_no_slave | ON |
+------------------------------------+-------+
4 rows in set (0.00 sec)

MariaDB [(none)]> set @@global.rpl_semi_sync_master_enabled=ON;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show global variables like '%semi%';

+------------------------------------+-------+
| Variable_name | Value |
+------------------------------------+-------+
| rpl_semi_sync_master_enabled | ON |
| rpl_semi_sync_master_timeout | 10000 |
| rpl_semi_sync_master_trace_level | 32 |
| rpl_semi_sync_master_wait_no_slave | ON |
+------------------------------------+-------+
4 rows in set (0.00 sec)

4, first check the master node, then start the IO thread from the node, the master node view

MariaDB [(none)]> show global status like '%semi%';

IO thread from start node:

MariaDB [(none)]> stop slave IO_THREAD;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> start slave IO_THREAD;
Query OK, 0 rows affected (0.00 sec)

The master node:

5, the main authorized users from copying previously created in the primary node:

MariaDB [(none)]> grant replication slave on *.* to 'myslave'@'192.168.200.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> show master status;
+---------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------------+----------+--------------+------------------+
| mysql-binlog.000004 | 931 | | |
+---------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

6, from the node:

MariaDB [(none)]> stop slave;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> CHANGE MASTER TO
-> MASTER_HOST='192.168.200.111',
-> MASTER_USER='myslave',
-> MASTER_PASSWORD='123456',
-> MASTER_LOG_FILE='mysql-binlog.000004',
-> MASTER_LOG_POS=931;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.00 sec)

7, create database mydb on the primary node

MariaDB [(none)]>create database nydb character set 'utf8';

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| performance_schema |
| test |
| test01 |
| test02 |
+--------------------+
7 rows in set (0.01 sec)

Whether to replicate the success in the view from the node database:

Discovery database mydb replicate success

Data manipulation in the master node:

MariaDB [(none)]> use mydb
Database changed
MariaDB [mydb]> create table tbl1 (id int,name varchar(100));
Query OK, 0 rows affected (0.03 sec)

 The master node continues to operate:

MariaDB [mydb]> insert into tbl1 values (1,'tom');
Query OK, 1 row affected (0.01 sec)

We found that the data from the node are changing:

 

Guess you like

Origin www.cnblogs.com/990624lty-jhc/p/11691034.html