首页 > 代码库 > Linux-6.5下 基于MariaDB-10 GTID多线程 的配置解析

Linux-6.5下 基于MariaDB-10 GTID多线程 的配置解析

                            mysql 5.6 基于 gtid 主从复制(本文是:MariaDB-10)

        MySQL 5.6引入的GTID(Global Transaction IDs)使得其复制功能的配置、监控及管理变得更加易于实现,且更加健壮。
        GTID是一个 unique 唯一的表示符,他是由服务器的uuid 全局唯一标示,是由128位的随机符组成,mysql-5.6是依靠server-id和uuid 来标示复制架构中的每一个主机,因为是128位的随机字符串在全局都不会重复,server-id 和uuid以及每一个mysql事物的事物序号组成了唯一的gtid ,自从引进mysql-5.6之后每一个二进制日志当中在每一个事物的首部都会写上gtid 标记,因此gtid使得追踪和比较复制事物变得非常简单而且能够实现从崩溃中快速恢复。尤其是innodb 引擎要想实现高可用功能必须要借助于gtid来实现。
                        mysql‘s replication

wKioL1NrbczyHfJLAAE2KAJFkp8259.jpg

主机环境为:
wKioL1NrcmDzlHu_AABaojl88dA430.jpg

本博文是以MariaDB-10配置GTID多线程的,下面是配置步骤:

一、配置MASTER节点
1、配置主机名:
wKiom1NrZrCz6rETAACLp4pkeDY080.jpg
2、停止服务:
wKioL1NrZoegtW2sAABVumJXyrw792.jpg
3、修改配置文件:
wKiom1NrZrOSamshAAI0ZhdQQ2E850.jpg
4、创建目录及属主属组:
wKiom1NrZrPhwPpgAACZyl-LxQQ571.jpg
5修改hosts:
wKioL1NrZonTw55PAAByhSd-8jM228.jpg
6、远程复制给slave主机:
wKiom1NrZrTygl2pAAG3VnRjVU0887.jpg
7、测试是否能ping通slave:
wKioL1NrZoqAXetLAAF2SFKTpEc805.jpg
8、启动服务:
wKiom1NrZrXhc85QAABX-opBW9U954.jpg
9、查看GTID信息:
wKioL1NrZouCPWq2AAFYKu_gMlY458.jpg


二、配置SLAVE节点
1、配置主机名:
wKiom1NrZraTJexKAABj3NqSR0s486.jpg
2、停止服务:
wKioL1NrZo2jK94lAABeqUZAArA266.jpg
3、修改配置文件:
wKiom1NrZrixxHf6AAIoLOovL88867.jpg
4、创建目录及修改属组属主:
wKioL1NrZo_Tj6-GAACSDMb7Jng842.jpg
5、启动服务:
wKiom1NrZrqAna70AABUnV9N8KI001.jpg
6、测试是否能ping通master:
wKioL1NrZpGg0jjYAAF42_vEYxw368.jpg
7、查看GTID信息:
wKiom1NrZr3DjM5JAAFeVVz8DZY078.jpg

三、验证效果及创建授权用户
1、master创建授权用户:
wKioL1NrZpOyBZVLAADwh3uLL5g893.jpg
2、slave指向指定复制位置:
wKiom1NrZr_ik5_eAADIgJI6i1Y880.jpg
3、slave启动同步:
wKioL1NrZpXSA4qOAABNko71gls580.jpg
4、slave查看是否成功启用同步:
wKioL1NrZpaQ7WbaAAIJ83sXlwc493.jpg
5、slave查看是否有mydb库:
wKiom1NrZsKxvI_wAAC8ZudeDMY026.jpg
6、master查看slave的数量:
wKioL1NrZpjwJqovAADrGVOhTzw305.jpg
7、master创建库:
wKiom1NrZsPScTFOAAD8utnD_IY961.jpg
8、slave查看是否同步:
wKioL1NrZpnRRoHiAADAy0CAPXA245.jpg
9、这时候你要与下面的这条命令结合的使用,才能看出动态的结果,你可以开两个窗口,我这里可能是因为数据量太小了,所以看不变化了:
9.1 master导入大量数据:
wKiom1NrZsXhBKVqAAAmn_oDBE4168.jpg
9.2 slave查看master导入数据的变化:
wKioL1NrZpuScYjtAACr3HG-g5Y456.jpg
9.3 slave查看master导入数据的变化:
wKiom1NrZsain9hKAAJUtITueA0394.jpg
9.3.1 与上图作对比:
wKiom1NrZseDIRaMAAI_yqMlKu4761.jpg
10、master查看线程信息:
MariaDB [(none)]> SHOW PROCESSLIST;
+----+-------------+------------------------+------+-------------+------+-----------------------------------------------------------------------+------------------+----------+
| Id | User        | Host                   | db   | Command     | Time | State                                                                 | Info             | Progress |
+----+-------------+------------------------+------+-------------+------+-----------------------------------------------------------------------+------------------+----------+
|  3 | system user |                        | NULL | Connect     | 1785 | Waiting for work from SQL thread                                      | NULL             |    0.000 |
|  4 | system user |                        | NULL | Connect     | 1785 | Waiting for work from SQL thread                                      | NULL             |    0.000 |
|  8 | repluser    | slave.xiaoma.com:41243 | NULL | Binlog Dump |  954 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL             |    0.000 |
| 17 | root        | localhost              | NULL | Query       |    0 | init                                                                  | SHOW PROCESSLIST |    0.000 |
+----+-------------+------------------------+------+-------------+------+-----------------------------------------------------------------------+------------------+----------+
4 rows in set (0.00 sec)
MariaDB [(none)]>
11、slave查看线程信息:
MariaDB [(none)]> SHOW PROCESSLIST;
+----+-------------+-----------+------+---------+---------+-----------------------------------------------------------------------------+------------------+----------+
| Id | User        | Host      | db   | Command | Time    | State                                                                       | Info             | Progress |
+----+-------------+-----------+------+---------+---------+-----------------------------------------------------------------------------+------------------+----------+
|  3 | system user |           | NULL | Connect | 3225828 | Waiting for work from SQL thread                                            | NULL             |    0.000 |
|  4 | system user |           | NULL | Connect | 3225828 | Waiting for work from SQL thread                                            | NULL             |    0.000 |
|  6 | root        | localhost | NULL | Query   |       0 | init                                                                        | SHOW PROCESSLIST |    0.000 |
|  7 | system user |           | NULL | Connect |    1006 | Waiting for master to send event                                            | NULL             |    0.000 |
|  8 | system user |           | NULL | Connect |     535 | Slave has read all relay log; waiting for the slave I/O thread to update it | NULL             |    0.000 |
+----+-------------+-----------+------+---------+---------+-----------------------------------------------------------------------------+------------------+----------+
5 rows in set (0.00 sec)
MariaDB [(none)]>

 

 

 


Welcome to the xiaomazi blog!!

 

 

本文出自 “不怕鬼的小马子” 博客,请务必保留此出处http://xiaomazi.blog.51cto.com/5891742/1408559