在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

mysql 5.7 GTID如何实现主从配置

111次阅读
没有评论

共计 6223 个字符,预计需要花费 16 分钟才能阅读完成。

这篇文章给大家分享的是有关 mysql 5.7 GTID 如何实现主从配置的内容。丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,一起跟随丸趣 TV 小编过来看看吧。

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);

感谢各位的阅读!关于“mysql 5.7 GTID 如何实现主从配置”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-26发表,共计6223字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 天天干天天做天天操 | 这里只有久久精品 | 国产一级做a爱片久久毛片a | 一级片在线观看视频 | 曰本人做爰大片免费观看一 | 97夜夜澡人人双人人人喊 | 精品动漫一区二区三区 | 韩国美女福利专区一区二区 | 成人aa免费视频在线播放 | 少妇真人直播免费视频 | 俺来也欧美亚洲a∨在线 | 欧美日韩精品高清一区二区 | 日韩视频中文字幕精品偷拍 | 精品国产三级a∨在线 | 九九色 | 国产亚洲精品bv在线观看 | 亚洲色图制服丝袜 | 色视频综合无码一区二区三区 | 国产黄色在线 | 亚洲 自拍 另类小说综合图区 | 老子影院午夜精品无码 | 精品国产一区二区在线观看 | 色多多高清在线观看视频www | 国产精品久久久久久人妻 | 国产精品免费观看视频 | a级大片免费观看 | 人妻妺妺窝人体色www聚色窝 | 国产伦精品一区二区三区视频金莲 | 亚洲网址| 日本免费一区二区三区中文字幕 | 一本加勒比hezyo无码人妻 | 国产色婷婷五月精品综合在线 | 黄网站色视频大全免费观看 | 特级全黄一级毛片免费 | 亚洲男人第一无码av网站 | 久久这里只有精品视频99 | 亚洲更新| 免费一级欧美毛片 | 色情无码www视频无码区澳门 | 欧美a级黑粗大硬长爽 | 91网址在线观看 |