mysql 5.7 新特性之 (mysql.gtid_executed)

2017-01-10 08:21:23来源:作者:人点击

生产环境 5.6.25 版本打开gtid,从节点需要设置log_slave_updates=on,
这样明显增加了从库的IO ,在5.7的版本中增加了mysql.gtid_executed表,
把gtid 的信息持久化了,这样我们在搭建主从环境,主从切换是可以不设置log_slave_updates=on。

1.数据库版本信息
(root@localhost) [mysql]> status;
--------------
mysql Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using EditLine wrapper

Connection id: 5
Current database: mysql
Current user:root@localhost
SSL:Not in use
Current pager: stdout
Using outfile: ''
Using delimiter:;
Server version: 5.7.15-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket:/var/lib/mysql/mysql.sock
Uptime: 22 min 49 sec

Threads: 1 Questions: 11 Slow queries: 0 Opens: 111 Flush tables: 1 Open tables: 65 Queries per second avg: 0.008
--------------

2.表的信息
source 对应server_uuid ,interval_start/end 对应transaction_id
(root@localhost) [mysql]> show create table mysql.gtid_executed/G;
*************************** 1. row ***************************
Table: gtid_executed
Create Table: CREATE TABLE `gtid_executed` (
`source_uuid` char(36) NOT NULL COMMENT 'uuid of the source where the transaction was originally executed.',
`interval_start` bigint(20) NOT NULL COMMENT 'First number of interval.',
`interval_end` bigint(20) NOT NULL COMMENT 'Last number of interval.',
PRIMARY KEY (`source_uuid`,`interval_start`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0
1 row in set (0.00 sec)

ERROR:
No query specified

3.查看表信息
(root@localhost) [mysql]> select * from gtid_executed/G;
*************************** 1. row ***************************
source_uuid: 383e67b5-4191-11e6-be68-525400eef133
interval_start: 1
interval_end: 2915

4.新的参数
(root@localhost) [(none)]> show variables like 'gtid_exe%';
+----------------------------------+-------+
| Variable_name| Value |
+----------------------------------+-------+
| gtid_executed| |
| gtid_executed_compression_period | 1000 | --表压缩
+----------------------------------+-------+

5.看官网知识点 http://dev.mysql.com/doc/refman/5.7/en/replication-gtids-concepts.html 内容太多,大家看官网连接,对于准备使用5.7版本的朋友们,还是要多熟悉掌握其特性。
本文出自 “roidba” 博客,请务必保留此出处http://roidba.blog.51cto.com/12318731/1888998

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台