支持半同步,GTID,组提交,从库并发功能. 基于最新的MYSQL 8.0.24!
先上MY.CNF 目录大家改改就能用
[client]
port=3306
default-character-set=utf8
socket=/tmp/mysql.sock
[mysqldump]
quick
max_allowed_packet = 2G
[mysql]
no-auto-rehash
sohw-warnings
prompt="\\u@\\h:\\d\\r:\\m:\\s>"
default-character-set=utf8
[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
user=mysql
open-file-limit=65535
pid-file=/u01/mysql8/soft/mysqld.pid
log-error=/u01/mysql8/soft/mysql-error.log
[mysqld]
#large-pages
#**********common parameters*********
default-storage-engine = INNODB
character-set-server = utf8mb4
collation_server = utf8mb4_0900_ai_ci
log_timestamps = SYSTEM
gtid-mode=on
enforce-gtid-consistency=1
optimizer_switch='batched_key_access=on'
explicit_defaults_for_timestamp=on
secure_file_priv=null
user = mysql
port = 3306
socket = /tmp/mysql.sock
datadir = /u01/mysql8/data
tmpdir = /u01/mysql8/data
basedir=/u01/mysql8/soft
skip-name-resolve
skip_external_locking
##lower_case_table_name = 1 #mysql8.0 要求我们不能在initialize之后再更改 lower_case_table_names 的值
event_scheduler = 0
back_log = 512
default-time-zone = '+8:00'
max_connections =3000
max_connect_errors = 999999
max_allowed_packet = 64M
slave_pending_jobs_size_max = 128M
max_heap_table_size = 8M
max_length_for_sort_data =16K
wait_timeout = 172800
interactive_timeout = 172800
net_buffer_length = 8K
read_buffer_size = 2M
read_rnd_buffer_size = 2M
sort_buffer_size =2M
join_buffer_size = 2M
table_open_cache = 4096
table_open_cache_instances = 2
table_definition_cache =4096
thread_cache_size =512
tmp_table_size = 8M
##**************LOGS SETTING****************
long_query_time =1
slow_query_log = 1
slow_query_log_file =/u01/mysql8/binlog/mysql8_master_slow.log
log_slow_slave_statements
log_queries_not_using_indexes
log_slow_admin_statements=1 ##启记录管理型慢SQL
min_examined_row_limit = 250 ##查询检查返回少于该参数指定行的SQL不被记录到慢查询日志
#****************BINLOGS SETTING*********************
log-bin=/u01/mysql8/binlog/binlog
binlog-checksum=CRC32
binlog_cache_size = 2M ##Per Sessions
binlog_format=row
max_binlog_size=512M ##日志文件大小
max_binlog_cache_size=2147483648 ##事务语句
#expire_logs_days=15 ##自动清理1天前的log文件
binlog_expire_logs_seconds= 1296000 ## 自动清理15前的log文件
sync_binlog=1
binlog_group_commit_sync_delay = 80
binlog_group_commit_sync_no_delay_count = 8
##FOR MASTER***************************
server-id=1
master-verify-checksum=1
master-info-repository=TABLE
#rpl_semi_sync_master_enabled = 1
rpl_semi_sync_master_timeout=10000 ##毫秒 超时
rpl_semi_sync_master_wait_no_slave=ON ##表示MASTER事务都要等待丛库确认收到
##For slave*****************************************************************
#server-id=2
#relay-log-info-repository=TABLE
#relay-log-recovery=1
#slave-parallel-workers=4
#log_bin_trust_function_creators=1
#log_slave_updates=1
#slave-net-timeout=10
#slave_parallel_type=LOGICAL_CLOCK
#replicate-do-db=books
#rpl_semi_sync_slave_enabled=ON
#sync_master_info=10000
#sync_relay_log=10000
#sync_relay_log_info=10000
#read_only=1
##**********INNODB SETTING***********************
innodb_data_home_dir =/u01/mysql8/data
innodb_data_file_path = ibdata1:12M;ibdata2:16M:autoextend
#innodb_file_per_table = 0
innodb_open_files=60000
innodb_strict_mode=1
innodb_flush_method=O_DIRECT
innodb_checksum_algorithm=crc32
innodb_autoinc_lock_mode=2
##buffer pool**************
innodb_buffer_pool_size=128M
innodb_buffer_pool_instances=4
innodb_max_dirty_pages_pct=75
innodb_adaptive_flushing = ON
innodb_flush_neighbors = 0
innodb_lru_scan_depth =4096
innodb_change_buffering = all
innodb_old_blocks_time =1000
innodb_buffer_pool_dump_at_shutdown=ON
innodb_buffer_pool_load_at_startup=ON
innodb_page_cleaners=4
##Redo*********************
innodb_log_group_home_dir=/u01/mysql8/data
innodb_log_buffer_size=4M
innodb_log_file_size=1024M
innodb_log_files_in_group=2
innodb_flush_log_at_trx_commit = 1
innodb_fast_shutdown = 1
##Transaction*************
innodb_thread_concurrency = 64
innodb_lock_wait_timeout=120
innodb_rollback_on_timeout = 1
transaction_isolation= READ-COMMITTED
##IO setting********************************
performance_schema=on
innodb_read_io_threads=8
innodb_write_io_threads=16
innodb_io_capacity=20000
innodb_use_native_aio=1
innodb_doublewrite=ON
##undo setting********************************
innodb_undo_directory=/u01/mysql8/data
innodb_undo_tablespaces=4
innodb_undo_log_truncate=ON
innodb_purge_threads=4
innodb_purge_batch_size=512
innodb_max_purge_lag=65535
以上是主库的参数 备库稍微改改就行.
先把主库搞定再说
#######安装半同步插件#########################################
mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so';
Query OK, 0 rows affected (0.19 sec)
mysql> show 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_for_slave_count | 1 | 等待从库数量 |
| rpl_semi_sync_master_wait_no_slave | ON |要等待丛库确认收到 |
| rpl_semi_sync_master_wait_point | AFTER_SYNC |到从库前不被其他会话可见 |
+-------------------------------------------+------------+--------------------------+
6 rows in set (0.00 sec)
mysql> set global rpl_semi_sync_master_enabled =on;
Query OK, 0 rows affected (0.00 sec)
##新建复制账号 并且设置非8.0验证方式
mysql> create user 'rpl'@'%' identified by '123456';
Query OK, 0 rows affected (10.54 sec)
mysql> grant replication slave on *.* to rpl;
Query OK, 0 rows affected (0.27 sec)
mysql> alter user 'rpl'@'%' identified with mysql_native_password by '123456';
mysql> FLUSH PRIVILEGES;
##退出,关闭MYSQLD服务,并添加半同步参数## 上面参数列表中取消#号
##这样完成了主库的常用设置
搞备库:
#****************BINLOGS SETTING*********************
log-bin=/u01/mysql8/binlog/binlog
binlog-checksum=CRC32
binlog_cache_size = 2M ##Per Sessions
binlog_format=row
max_binlog_size=512M ##日志文件大小
max_binlog_cache_size=2147483648 ##事务语句
#expire_logs_days=15 ##自动清理1天前的log文件
binlog_expire_logs_seconds= 1296000 ## 自动清理15前的log文件
sync_binlog=1 ##同步到磁盘上
binlog_group_commit_sync_delay = 80 ##80毫秒组提交
binlog_group_commit_sync_no_delay_count = 8 ##8个事务组提交
##FOR MASTER***************************
#server-id=1
#master-verify-checksum=1
#master-info-repository=TABLE
#rpl_semi_sync_master_enabled = 1
#rpl_semi_sync_master_timeout=10000 ##毫秒 超时
#rpl_semi_sync_master_wait_no_slave=ON ##表示MASTER事务都要等待丛库确认收到
##For slave*****************************************************************
server-id=2 ##服务实例ID
relay-log-info-repository=TABLE ##中续日志存表
relay-log-recovery=1
slave-parallel-workers=4 ##并行4个恢复
log_bin_trust_function_creators=1
log_slave_updates=1 ##同时更新到从库的BINLOG上
slave-net-timeout=10
slave_parallel_type=LOGICAL_CLOCK ##并行逻辑时钟
replicate-do-db=books ##只恢复BOOKS库
#rpl_semi_sync_slave_enabled=ON ##半同步从库插件
sync_master_info=10000
sync_relay_log=10000 ##同步到磁盘每1万中续日志
sync_relay_log_info=10000 ##同步中续日志信息
read_only=1 ##只读从库
重启下安装从库半同步插件
mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
Query OK, 0 rows affected (0.11 sec)
mysql> show variables like '%semi%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled | OFF |
| rpl_semi_sync_slave_trace_level | 32 |
+---------------------------------+-------+
2 rows in set (0.05 sec)
[mysql@MYSQL-SLAVE1 soft]$ service mysqld stop
Shutting down MySQL.. [确定]
[mysql@MYSQL-SLAVE1 soft]$ vim my.cnf
[mysql@MYSQL-SLAVE1 soft]$ service mysqld start
mysql> show variables like '%semi%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled | ON |
| rpl_semi_sync_slave_trace_level | 32 |
+---------------------------------+-------+
2 rows in set (0.04 sec)
启动复制:
mysql> show slave status;
Empty set, 1 warning (0.01 sec)
mysql> change master to
-> master_host = '192.168.2.11',
-> master_port = 3306,
-> master_user = 'rpl',
-> master_password = '123456',
-> master_auto_position = 1;
Query OK, 0 rows affected, 8 warnings (2.48 sec)
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.50 sec)
mysql> start slave;
Query OK, 0 rows affected, 1 warning (1.72 sec)
##出现不成功问题,修复后要STOP SLAVE; START SLAVE;重新启动下
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.2.11
Master_User: rpl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000001
Read_Master_Log_Pos: 604
Relay_Log_File: MYSQL-SLAVE1-relay-bin.000002
Relay_Log_Pos: 813
Relay_Master_Log_File: binlog.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: books
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: 604
Relay_Log_Space: 1029
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: 3bd7a89c-abf6-11eb-8bb8-0800275a26da
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: 3bd7a89c-abf6-11eb-8bb8-0800275a26da:1-2
Executed_Gtid_Set: 3bd7a89c-abf6-11eb-8bb8-0800275a26da:1-2
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
Master_public_key_path:
Get_master_public_key: 0
Network_Namespace:
1 row in set, 1 warning (0.01 sec)
ERROR:
No query specified
主库信息基本对上了
mysql> show master status;
+---------------+----------+--------------+------------------+------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+------------------------------------------+
| binlog.000001 | 604 | | | 3bd7a89c-abf6-11eb-8bb8-0800275a26da:1-2 |
+---------------+----------+--------------+------------------+------------------------------------------+
1 row in set (0.00 sec)
SLAVE 3就基本画葫芦了!!
Mysql主从切换为从主
##从库变主库 old slave:
show processlist; #确保Slave has read all relay log;
STOP SLAVE IO_THREAD
show slave status \G; ##检查IO及SQL线程是否正常,如果为NO表明同步不一致
stop slave;
reset master;
reset slave all; ##(看版本号)
##新建复制账号 并且设置非8.0验证方式
mysql> create user 'rpl'@'%' identified by '123456';
Query OK, 0 rows affected (10.54 sec)
mysql> grant replication slave on *.* to rpl;
Query OK, 0 rows affected (0.27 sec)
mysql> alter user 'rpl'@'%' identified with mysql_native_password by '123456';
mysql> FLUSH PRIVILEGES;
show master status; #记住这里列出的log_file和log_pos信息
------------------------------------------------------------------------------
## 主库变从库 old master:
Reset master; #(新的slave,老的master)
Reset slave;
mysql> change master to
-> master_host = '192.168.2.11',
-> master_port = 3306,
-> master_user = 'rpl',
-> master_password = '123456',
-> master_auto_position = 1;
start slave;
show slave status\G;
Replication 主要配置参数:
1、log_bin:指定binlog文件的名称,同时也表示开启binlog功能,在replication模式下,master上必须开启log_bin,如果slave不需要failover,可以不开启。文件将会放置在“datadir”目录下。
2、binlog_checksum:是否开启binlog校验功能,在5.6.6+之后此值默认为“CRC32”,此前版本默认为“NONE”表示不开启校验和算法;用于控制master将每个变更操作写入binlog时是否携带checksum值,使用checksum可以在replication时,slave用于校验变更操作在网络传输时是否被破坏。
3、binlog_format:可选值“MIXED”、“ROW”、“STATEMENT”,在5.6版本之前默认为“STATEMENT”,5.6之后默认为“MIXED”;因为“STATEMENT”方式在处理一些“不确定”性的方法时会造成数据不一致问题,我们建议使用“MIXED”或者“ROW”。
4、sync_binlog:binlog文件刷新磁盘的时机,默认为“0”,表示binlog刷新磁盘的时机有操作系统决定,“1”表示每个变更操作写入binlog后立即刷新磁盘,这是最安全的方式,在crash时最多丢失一个“group”,当然也是磁盘效率最低的一种;其他任何大于0的数字,表示“多少次”变更操作写入binlog文件后执行flush。此值越大,对磁盘IO消耗越小,当回额外消耗内存,效率越高。
5、binlog_row_image:可选值“full”、“minimal”、“noblob”,默认值为“full”,对“STATEMENT”复制模式无效;每个变更操作发生时,都有2个“image”,“before”表示变更前此行所有列的值,“after”表示变更后此行所有列的值;“full”表示在binlog中将会记录before和after的全部信息,易于排错,但是会导致日志量很大,对磁盘空间和网络传输都有一定的影响;“minimal”只记录before中能够唯一标记此行的列值,比如主键或者唯一索引键,在after中只记录那些有值变更的列;“noblob”类似于full,但是不记录那些没有变更的blob或者text类型的列。
默认值为“full”,因为before和after均写入了binlog,所以通常不会带来问题;如果使用minimal或noblob,我们需要首先确保所有的表都有“主键”或者“唯一索引键”,且slave和master上的表结构完全一致,这样binlog只需要在before中记录能够唯一确定此行的的列即可,否则可能会引入数据不一致的问题。
6、log_slave_updates:默认值为“FALSE”,slave在读取relay log后执行变更操作时,是否也将变更操作再次保存在本地的binlog中,就像变更操作在本地发生一样,开启此特性时也需要同时开启binlog。如果你的slave后端仍有其他slave跟进,需要开启此特性;比如A<-B<-C链状模式,A是B的master,B为C的master,因此A和B需要同时开启binlog和log_slave_updates,否则C将无法正常replication。
7、max_binlog_size:binlog文件的大小,单位“字节”,默认为1G;即当binlog的尺寸大于此值时,将会滚动生成新的binlog文件,但是同一个事务将不会被分割在2个binlog文件中。如果没有设定“max_relay_log_size”配置项,那么此选项也会控制relay log的大小。
8、log_bin_index:binlog索引文件名称,此文件记录当前所有正在使用的binlog文件列表。默认与binlog文件名一样,只是后缀为“<binlog-filename>.index”。
9、expire_logs_days:binlog文件保存的天数,超过指定天数后,binlog历史文件将被删除;默认为“0”表示“不自动删除、永久保存”。通常我们建议不修改此值,即永久保存binlog日志,以备将来一旦数据操作失误时,可以用于恢复。如果磁盘空间有限,可以将binlog备份到其他存储平台,而在本地使用“PURGE BINARY LOGS”指令清除早期的binlog历史文件,释放磁盘空间。
10、master_verify_checksum:master在读取binlog时是否校验,与“binlog_checksum”对应,默认为“false”即关闭。
11、innodb_flush_log_at_trx_commit:innodb表中事务写入binlog后刷新磁盘的时机,配合“sync_binlog”参数使用,默认值为“1”表示每个事务提交后立即刷新binlog文件,是目前最安全的方式。“0”表示缓存事务,每隔1秒钟(innodb_flush_log_at_timeout控制)批量写入binlog并刷新一次磁盘,当crash时这种方式不能100%保证事务全部都写入磁盘,binlog中最多会丢失1秒内的事务。“2”表示事务提交后立即写入binlog文件,每隔一秒钟刷新一次磁盘,它和“1”并没有太大区别,只不过这个方式下操作系统也会影响文件的刷新时机。
12、binlog_order_commits:默认为“true”,事务提交的顺序与写入binlog的顺序保持一致,即在事务提交时会锁定binlog并写入;如果关闭此特性,事务将会并发的提交,那么binlog中事务的顺序有可能与其实际提交的顺序不同,恢复replication带来一定的影响,不过这种方式会提升一定的并发性。
13、server_id:当前mysql实例的id,整个replication中所有的实例的id都不能重复,而且每个server都必须配置此选项,此值是一个数字,integer型。
14、relay_log:relay log的文件名,建议在master和slave上均配置。
15、relay_log_index:relay log索引文件名称。
16、relay_log_info_repository:可选值为“FILE”、“TABLE”,用于保存slave读取relay log的位置信息,以便crash重启后继续恢复;“FILE”表示将信息写入relay-log.info文件,“TABLE”表示将信息写入mysql.slave_relay_log_info表中。
17、master_info_repository:可选值“FILE”、“TABLE”,将master的状态和链接信息保存何处,FILE则表示保存在master.info文件中,TABLE表示保存在mysql.slave_master_info表中。
18、slave_net_timeout:slave与master链接IO超时的时间,超时后将会中断read,默认为3600。
19、slave_parallel_workers:设置执行replication的worker线程的数量,默认为0,表示关闭多线程,此时slave只有一个SQL线程。如果开启多线程,slave中的SQL线程将作为worker线程池的“协调器”,SQL线程从relay log中读取变更操作记录,并以database为分离标准将操作分发给相应的workers线程,每个worker线程在一端时间内将持续执行一个database的变更操作,简单而言,就是不同的worker线程执行不同database的操作,多个database数据将在slave上被并行的执行,为了能够正确的工作,事务不能跨多个databases。
此值用于控制worker线程的个数,“协调器”线程不包含在内,我们在slave上通过“SHOW PROCESSLIST”指令可以查看到SQL线程、worker线程的数据和状态。
开启多线程时,并发执行会导致,在slaves上不同的databases被执行的时机可能与master上不同,归因于线程上线文的切换和CPU资源分配的不确定性;即一个事务执行后,不能保证此事务之前的其他事务(其他databases)也已经执行成功,这或许会对slave上binlog的记录、数据恢复和客户端数据访问带来影响。建议线程数为“database个数”,每个database一个worker线程;也有很多DBA将此值设置为2,即只用一个worker线程,这就不会带来事务顺序与master不一致的问题;需要强调的是,无论多少个线程,单个database的事务总是在一个worker中执行,单个database的事务顺序总是正确的。
20、slave_pending_jobs_size_max:仅对多线程有效,SQL线程将变更操作读取后分发给worker线程,每个worker线程以队列的方式缓存亟待执行的变更操作记录,此处用于控制队列的大小,默认为16M,单位为“字节”;此值不得大于“max_allowed_packet”。
21、slave_sql_verify_checksum:slave中SQL线程是否使用校验和检测relay log中的变更操作,与“binlog_checksum”配合,默认为“1”表示开启。
22、slave_transaction_retries:如果SQL线程在执行事务时发生InnoDB死锁且等待超时后,slave重试的次数,默认为10,如果超过此次数,slave将会抛出error且终止replication;此值在“slave_parallel_workers”开启时无效,即为0,不重试。
23、sync_relay_log:slave将多少条变更操作写入relay log后刷新磁盘文件,默认为10000;“0”表示刷新时机有操作系统决定,“1”表示每写入一条变更操作即立即刷新,是最安全的方式,不过因为relay log的安全级别与binlog还是要低一些,建议保持默认值,这通常也不会带来问题。
24、gtid_mode:是否开启GTID特性,可选值为“ON”、“OFF”;在replication模式下我们应该开启。
25、enforce_gtid_consistency:如果gtid_mode=ON,此值必须开启,可选值为“ON”、“OFF”,表示是否强制gtid的“一致性”避免并发操作。
26、binlog_ignore_db:binlog中忽略的db,master与slave均可以配置,通常在master端。如果需要ignore多个databases,此配置允许声明多次,每次指定一个db。
27、binlog_do_db:指定可以写入binlog的database名字,与binlog_ignore_db相反,只有指定的db才会写入binlog。此配置允许声明多次,每次指定一个db。(上述两个如果在slave上配置,可能还需要开启“log_slave_updates”,默认情况下,slaves端是不写binlog的)
28、replicate_do_db:同上,只是在slave端生效,slave中的SQL线程在读取relay log时,会检测此变更操作所属DB,SQL线程只会执行此配置参数指定的db。如果不声明replicate_do_db,表示所有的db都会执行。此配置允许声明多次,每次指定一个db。与此配置项对应的还有“replicate_ignore_db=<db>”、“replicate_db_table=<db>.<table>”、“replicate_ignore_table=<db>.<table>”。
29、read_only:当前实例是否为“只读”模式,在此模式下除了具有“SUPER”权限的用户外,其他权限用户均不可以修改数据。SUPER权限包括(举例):CHANGE MASTER TO、KILL、SET GLOABL等。通常slave上,需要设定read_only=1以避免客户端意外修改数据,而造成数据错乱问题。默认为“0”(OFF)表示关闭。read_only并不会影响replication进程对数据的变更。
30、super_read_only:对于具有SUPER权限的用户,是否也只读,默认为“0”(OFF)表示关闭。super_read_onl开启时,也会隐式的开启“read_only”参数。
31、slave_preserve_commit_order:对于多线程slaves,来保障事务在slave上执行的顺序与relay log中的顺序严格一致,只有当“slave_parallel_workers”开启时有效;此时“log_bin”、“log_slave_updates”必须开启,而且“slave_parallel_type”值必须为“LOGICAL_CLOCK”(默认值为DATABASE)。即当多线程开启时,且根据relay log中事务的逻辑顺序执行statements,是否需要严格保持顺序,默认值为0表示并发执行忽略顺序。
slave_parallel_type默认为DATABASE,原理参见18,能够确保每个DATABASE中的事务顺序严格一致,但是无法保证所有databases的事务执行顺序也是严格一致的(gap),比如两个事务依次操作了2个DB:A和B,尽管事务A、B分别被worker X、Y线程接收,但是因为线程调度的问题,有可能导致A的执行时机落后于B。
如果你的事务经常是“跨DB”操作,那么可以考虑使用此参数限定顺序。当此参数开启时,这要求任何worker线程执行的事务时,只有当前事务中此之前的所有事务都执行后(被其他worker线程执行),才能执行和提交。(每个事务中,都记录了当前GTID的privious GTID,只有privious GTID被提交后,当前GTID事务才能提交)




