mysql 实例的主对主复制中缺少数据

mysql 实例的主对主复制中缺少数据

我使用的是 MySQL 8。我有两个主服务器,它们配置为主-主复制,my.cnf 中的配置如下。除了 server-id 之外,配置完全相同。它似乎运行正常,直到我最近运行了一个包含大量数据的 spring boot。

我有一个最高父表,称为“产品”表,并且有 4 或 5 个子表通过 product_id 外键由产品表引用。

我注意到一个主表上的小插入/更新/删除通过复制反映在另一个主表上。

我必须将 2300 件产品上传到产品表中。每件产品都有 3 或 4 个属性(图片和一些选项),这些属性应保存在 4 或 5 个子表中。

我注意到,当它将产品数据插入其中一个主数据库中的产品表和其他子表中时,我没有在另一个主数据库中看到任何复制的数据。当我测试 50 个产品表时,它运行正常。

我检查了日志(/var/log/mysqldb.log)以查看是否有任何故障。我没有看到任何故障。

所以我想弄清楚复制何时发生。复制是在 Java 应用程序端完成整个事务后发生的,还是在对表进行任何更改(按行)时发生的?

在我看来,事务直到 Java 应用程序中的循环结束才会提交。没问题。如果复制在事务之后开始,那么复制不应该发生吗?或者 my.cnf 中是否存在任何配置错误?

谢谢。

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

sql-mode=""


innodb_buffer_pool_instances    = 2
innodb_buffer_pool_size = 2G
innodb_file_per_table           = 1
innodb_flush_log_at_trx_commit  = 0
innodb_flush_method             = O_DIRECT
innodb_log_buffer_size          = 16M
innodb_log_file_size            = 512M
innodb_stats_on_metadata        = 0
innodb_read_io_threads          = 64
innodb_write_io_threads         = 64


key_buffer_size                 = 48M   # UPD
back_log                        = 512
thread_cache_size               = 100
thread_stack                    = 192K

interactive_timeout             = 180
wait_timeout                    = 180

# Buffer Settings
join_buffer_size                = 4M    # UPD
read_buffer_size                = 3M    # UPD
read_rnd_buffer_size            = 4M    # UPD
sort_buffer_size                = 4M    # UPD





default-storage-engine=InnoDB
max_user_connections=100
max_allowed_packet              = 256M
max_connect_errors              = 1000000


#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin

default-authentication-plugin=mysql_native_password


skip-name-resolve

port=3306

server-id               = 1


datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid







####### replication #########

log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = sampledb
log_bin_index       = /var/log/mysql/mysql-bin.log.index
relay_log           = /var/log/mysql/mysql-relay-bin
relay_log_index     = /var/log/mysql/mysql-relay-bin.index
max_binlog_size     = 100M
log_slave_updates   = 1


slave_type_conversions=ALL_NON_LOSSY

相关内容