mysql gtid配置_mysql 5.7 GTID主从配置

binlog-format:二进制日志的格式,有row、statement和mixed几种类型;需要注意的是:当设置隔离级别为READ-COMMITED必须设置二进制日志格式为ROW,现在MySQL官方认为STATEMENT这个已经不再适合继续使用;但mixed类型在默认的事务隔离级别下,可能会导致主从数据不一致;

log-slave-updates、gtid-mode、enforce-gtid-consistency、report-port和report-host:用于启动GTID及满足附属的其它需求;

master-info-repository和relay-log-info-repository:启用此两项,可用于实现在崩溃时保证二进制及从服务器安全的功能;

sync-master-info:启用之可确保无信息丢失;

slave-paralles-workers:设定从服务器的SQL线程数,根据cpu核数设定;0表示关闭多线程复制功能;

binlog-checksum、master-verify-checksum和slave-sql-verify-checksum:启用复制有关的所有校验功能;

binlog-rows-query-log-events:启用之可用于在二进制日志记录事件相关的信息,可降低故障排除的复杂度;

log-bin:启用二进制日志,这是保证复制功能的基本前提;

server-id:同一个复制拓扑中的所有服务器的id号必须惟一。

report-host:

The host name or IP address of the slave to be reported to the master during slave registration. This value appears in the output of SHOW SLAVE HOSTS on the master server.

report-port:

The TCP/IP port number for connecting to the slave, to be reported to the master during slave registration.

master-info-repository:

The setting of this variable determines whether the slave logs master status and connection information to a FILE (master.info), or to a TABLE (mysql.slave_master_info)

relay-log-info-repository:

This option causes the server to log its relay log info to a file or a table.

log_slave_updates:

Whether updates received by a slave server from a master server should be logged to the slave's own binary log. Binary logging must be enabled on the slave for this variable to have any effect.

master服务器配置

编辑master的参数文件

#GTID parameter

gtid-mode=on

enforce-gtid-consistency=true

slave-parallel-workers=10

binlog-checksum=CRC32

binlog-format=ROW

log-slave-updates=true

report-port=3306

report-host=192.168.56.212

master-info-repository=TABLE

relay-log-info-repository=TABLE

sync-master-info=1

master-verify-checksum=1

slave-sql-verify-checksum=1

binlog-rows-query-log_events=1

重启master的mysql数据库

[root@ray ~]# /data/3306/mysqld restart

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

mysql> show global variables like '%gtid%';

+--------------------------+-------+

| Variable_name            | Value |

+--------------------------+-------+

| enforce_gtid_consistency | ON    |

| gtid_executed            |       |

| gtid_mode                | ON    |   #说明gti功能已启动

| gtid_owned               |       |

| gtid_purged              |       |

+--------------------------+-------+

5 rows in set (0.01 sec)

创建同步用户

mysql> GRANT REPLICATION SLAVE ON *.* TO 'rep'@'%' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.78 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

从服务器slave配置

my.cnf参数文件配置

#GTID parameter

gtid-mode=on

enforce-gtid-consistency=true

slave-parallel-workers=10

binlog-checksum=CRC32

relay-log = /data/3307/logs/relay-log

relay-log-index = /data/3307/logs/relay-log.index

binlog-format=ROW

log-slave-updates=true

report-port=3307

report-host=192.168.56.212

master-info-repository=TABLE

relay-log-info-repository=TABLE

sync-master-info=1

sync_relay_log = 1

sync_relay_log_info = 1

master-verify-checksum=1

slave-sql-verify-checksum=1

binlog-rows-query-log_events=1

relay_log_recovery = ON

重启mysql数据库

[root@ray ~]# /data/3307/mysqld restart

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

mysql> show global variables like '%gtid%';

+--------------------------+-------+

| Variable_name            | Value |

+--------------------------+-------+

| enforce_gtid_consistency | ON    |

| gtid_executed            |       |

| gtid_mode                | ON    |

| gtid_owned               |       |

| gtid_purged              |       |

+--------------------------+-------+

5 rows in set (0.56 sec)

change master to

master_host='192.168.56.212',

master_user='rep',

master_password='123456',

master_port=3306,

master_auto_position = 1;

mysql> change master to

->  master_host='192.168.56.212',

->  master_user='rep',

->  master_password='123456',

->  master_port=3306,

->  master_auto_position = 1;

Query OK, 0 rows affected, 2 warnings (0.59 sec)

mysql> start slave;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.56.212

Master_User: rep

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: ray-bin.000009

Read_Master_Log_Pos: 588

Relay_Log_File: relay-log.000003

Relay_Log_Pos: 797

Relay_Master_Log_File: ray-bin.000009

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 588

Relay_Log_Space: 1175

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 1

Master_UUID: 97e8847a-ffdf-11e6-87ed-08002736c224

Master_Info_File: mysql.slave_master_info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set: 97e8847a-ffdf-11e6-87ed-08002736c224:1-2

Executed_Gtid_Set: 97e8847a-ffdf-11e6-87ed-08002736c224:1-2

Auto_Position: 1

Replicate_Rewrite_DB:

Channel_Name:

Master_TLS_Version:

1 row in set (0.00 sec)

参数:

master-info-repository=TABLE

relay-log-info-repository=TABLE

把master.info 和relay.info 保存在表中,默认是myisam引擎,官方建议修改为innodb

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> alter table slave_master_info engine=innodb;

Query OK, 0 rows affected (0.29 sec)

Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table slave_relay_log_info engine=innodb;

Query OK, 0 rows affected (0.07 sec)

Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table slave_worker_info engine=innodb;

Query OK, 0 rows affected (0.13 sec)

Records: 0  Duplicates: 0  Warnings: 0

忽略过滤表:

配置文件,需要重启

replicate-ignore-table=test.t1

在线动态修改,无需重启

CHANGE REPLICATION FILETER REPLICATE_DO_DB=(DB1,DB2);

CHANGE REPLICATION FILETER REPLICATE_IGNORE_DB=(DB1,DB2);

CHANGE REPLICATION FILETER REPLICATE_DO_TABLE=(DB1.T1);

CHANGE REPLICATION FILETER REPLICATE_IGNORE_TABLE=(DB1.T1);

CHANGE REPLICATION FILETER REPLICATE_WILD_DO_TABLE=(DB1.T%);

CHANGE REPLICATION FILETER REPLICATE_WILD_IGNORE_TABLE=(DB%.T%);

CHANGE REPLICATION FILETER REPLICATE_REWRITE_DB=(FROM_DB,TO_DB);

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541526.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql log4jlogger_mybatis结合log4j打印SQL日志

mybatis结合log4j打印SQL日志1.Maven引用jar包默认的mybatis不能打印出SQL日志,不便于查看调试,须要结合log4jdbc-log4j2就能够完整的输入SQL的调试信息。pom.xml 配置maven。注意以下3个都须要org.bgee.log4jdbc-log4j2log4jdbc-log4j2-jdbc4.11.16org.…

限制对web路径的访问

$ipcmd -I INPUT -i eth0 -p tcp --dport 80 -m string --string "/adapi" --algo bm -j DROP$ipcmd -I INPUT -i eth0 -p tcp --dport 80 -m string --string "/epapi" --algo bm -j DROP转载于:https://blog.51cto.com/luoguoling/1919928

kotlin 查找id_Kotlin程序查找等边三角形的区域

kotlin 查找idFormula to find area of Equilateral Triangle: area ( 1.73 side side)/4 查找等边三角形面积的公式: 面积(1.73边边)/ 4 Given the value of side, we have to find the area of Equilateral Triangle. 给定边的值,我们必须找到等边…

Orcale11g单机安装与卸载

前言:本篇主要介绍Oracle11g企业版安装的准备工作,建议使用图形化界面安装,静默安装出现问题较多,初学者不好排查,本篇只给出关键步骤,最后介绍完全删除Orcale方法; Oracle Database 11g Expres…

qt连接mysql4.7数据库_QT4.7访问MySQL的驱动编译过程

我们假设你已经成功安装了MySQL(我用的是MySQL的安装版)和QT,MySQL的安装路径采用的是其默认安装路径,也就是安装在了C:\Program Files下。下面开始正式讲解QT访问安装版MySQL的驱动的编译方法。第一步:因为MySQL的安装路径下有空格&#xff…

cellpadding_在CSS中设置cellpadding和cellspacing

cellpaddingIntroduction: 介绍: It is not unknown anymore that now and then we make use of tables in our web page or website, therefore we all are familiar with how to create tables or grids in our website or web page but there are times when we…

JavaScript中的arguments对象

JavaScript中的arguments对象 arguments 是一个类似数组的对象, 对应于传递给函数的参数。 语法 arguments 描述 arguments对象是所有函数中可用的局部变量。你可以使用arguments对象在函数中引用函数的参数。此对象包含传递给函数的每个参数的条目,第一个条目的索引…

mongodb 排序_技术分享 | MongoDB 一次排序超过内存限制的排查

本文目录:一、背景1. 配置参数检查2. 排序字段是否存在索引二、测试环境模拟索引对排序的影响1. 测试环境信息2. 报错语句的执行计划解释 3. 建立新的组合索引进行测试三、引申的组合索引问题1. 查询语句中,排序字段 _id 使用降序2. 查询语句中&#xff…

sim800 模式切换_SIM的完整形式是什么?

sim800 模式切换SIM:订户标识模块或订户标识模块 (SIM: Subscriber Identity Module or Subscriber Identification Module) SIM is an abbreviation of a Subscriber Identity Module or Subscriber Identification Module. SIM is a portable chip and an integra…

css新单位 vw , vh

考虑到未来响应式设计的开发,如果你需要,浏览器的高度也可以基于百分比值调整。但使用基于百分比值并不总是相对于浏览器窗口的大小定义的最佳方式,比如字体大小不会随着你窗口改变而改变,如今css3引入的新单位明确解决这一问题。…

linux下mysql目录结构_linux下mysql安装配置与目录结构

本节内容:linux下mysql安装与配置、mysql目录结构。1、准备安装程序(官方网站下载)服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm客户端:MySQL-client-community-5.1.44-1.rhel4.i386.rpm2、安装(打印信息略) 代码示例:[rootlocalh…

Python字典values()方法与示例

字典values()方法 (Dictionary values() Method) values() method is used to get all values of a dictionary, it returns a view object that contains the all values of the dictionary as a list. values()方法用于获取字典的所有值,它返回一个包含字典所有值…

spark源码分析之Executor启动与任务提交篇

任务提交流程 概述 在阐明了Spark的Master的启动流程与Worker启动流程。接下继续执行的就是Worker上的Executor进程了,本文继续分析整个Executor的启动与任务提交流程Spark-submit 提交一个任务到集群通过的是Spark-submit通过启动脚本的方式启动它的主类&#xff0…

mysql 5.5.22.tar.gz_MySQL 5.5.22源码编译安装

MySQL 最新的版本都需要cmake编译安装,估计以后的版本也会采用这种方式,所以特地记录一下安装步骤及过程,以供参考。注意:此安装是默认CentOS下已经安装了最新工具包,比如GNU make, GCC, Perl, libncurses5-dev&#x…

Java Vector setElementAt()方法与示例

向量类setElementAt()方法 (Vector Class setElementAt() method) setElementAt() method is available in java.util package. setElementAt()方法在java.util包中可用。 setElementAt() method is used to set the given element (ele) at the given indices in this Vector.…

利用python进行数据分析D2——ch03IPython

为无为,事无事,味无味。大小多少,报怨以德。图难于其易,为大于其细;天下难事必作于易,天下大事必作于细。——老子关于图片的例子:import matplotlib.pyplot as plt imgplt.imread(ch03/stinkbug.png) import pylab plt.imshow(img) pylab.show()结果:调…

mysql 视图 字典_MySQL深入01-SQL语言-数据字典-服务器变量-数据操作DML-视图

SQL语言的组成部分常见分类:DDL:数据定义语言DCL:数据控制语言,如授权DML:数据操作语言其它分类:完整性定义语言:DDL的一部分功能约束约束:包括主键,外键,唯一…

为什么我会被淘汰?

这是一个值得讨论的问题。华为前段时间也传出了大规模裁员的一些负面新闻,一时间搞的人心惶惶。总结起来说,还是怕失去这份赖以生存的工作,尤其是对于上有老下有小的中年人来说,工作尤为重要。 淘汰,是软件行业不变的真…

Java Throwable initCause()方法与示例

Throwable类initCause()方法 (Throwable Class initCause() method) initCause() Method is available in java.lang package. initCause()方法在java.lang包中可用。 initCause() Method is used to instantiate the cause of this throwable to the given value and this met…

mysql 存储过程死循环_pl/sql存储过程loop死循环

今早,一个存储过程,写过很多次的存储过程,随手一写,各种报错,各种纠结,网上一搜,有好多个都遇到,论坛上给出的结局答案,今早,一个存储过程,写过很…