MariaDB - 复制。从站落后一个时间间隔
MariaDB - Replication. Slave Lagging Behind For an Interval
所以我有 1 个主服务器和 2 个从服务器 运行ning (CentOS-7)。我已经在所有服务器上安装了 MariaDB-10.1.48。我使用 GTID 实现了复制。一切都运行良好,但当我尝试将第二个从属服务器添加到复制中时出现了问题。我正在通过 Maxscale 监控服务器。两台服务器都正确同步了 GTID,但是一旦 Master 立即获得大量写入(用户 + 机器人都是 运行ning),Slave 1 很快赶上 Master 但 Slave 2 需要时间,当我 运行 show slave status - 它说 Seconds_behind_master = seconds(up to 50-60) 然后突然下降到 (0)。 S1和S2的cnf文件是一样的,事实上S2的硬盘和CPU功率比S1多很多。我试过看东西但找不到解决办法。我附上了cnf文件。除了 server_id 当然是唯一的之外,这个文件对于主控和两个从属都是相同的。非常感谢任何建议。
slave-skip-errors = 1062
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
gtid_strict_mode=1
log_slave_updates=1
sql-mode=""
slow_query_log
slow_query_log_file=/var/log/mysql/mysql-slow.log
long_query_time=2.0
log-error = /var/log/mysql/mysql-error.log
binlog_format=MIXED
max_connect_errors=2000
server-id = unique_for_every_server
bind-address = 0.0.0.0
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = some DBs (main + mysql + informmation_schema)
binlog-ignore-db= (some DBs)
replicate_do_db= some DBs (main + mysql + informmation_schema)
replicate-ignore-db= some DBs
log_bin = /var/log/mysql/mysql-bin.log
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
default-time-zone='-04:00'
max_allowed_packet = 1024M
wait_timeout = 60000
interactive_timeout= 60000
connect_timeout= 60000
table_cache = 2048
sort_buffer_size = 100M
thread_concurrency = 500
innodb_thread_concurrency = 0
innodb_read_io_threads = 64
innodb_write_io_threads = 64
query_cache_size = 100M
query_cache_limit = 150M
tmp_table_size = 100M
innodb_buffer_pool_size = 500M
innodb_additional_mem_pool_size = 20M
join_buffer_size=500M
table_open_cache = 7000
key_buffer_size = 50M
thread_cache_size = 50
key_buffer_size = 150M
read_buffer_size = 100M
read_rnd_buffer_size = 50M
key_buffer = 100M
max_connections = 2000
我刚刚在 /my.cnf/
文件中添加了 innodb_flush_log_at_trx_commit = 2
,问题就解决了。
所以我有 1 个主服务器和 2 个从服务器 运行ning (CentOS-7)。我已经在所有服务器上安装了 MariaDB-10.1.48。我使用 GTID 实现了复制。一切都运行良好,但当我尝试将第二个从属服务器添加到复制中时出现了问题。我正在通过 Maxscale 监控服务器。两台服务器都正确同步了 GTID,但是一旦 Master 立即获得大量写入(用户 + 机器人都是 运行ning),Slave 1 很快赶上 Master 但 Slave 2 需要时间,当我 运行 show slave status - 它说 Seconds_behind_master = seconds(up to 50-60) 然后突然下降到 (0)。 S1和S2的cnf文件是一样的,事实上S2的硬盘和CPU功率比S1多很多。我试过看东西但找不到解决办法。我附上了cnf文件。除了 server_id 当然是唯一的之外,这个文件对于主控和两个从属都是相同的。非常感谢任何建议。
slave-skip-errors = 1062
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
gtid_strict_mode=1
log_slave_updates=1
sql-mode=""
slow_query_log
slow_query_log_file=/var/log/mysql/mysql-slow.log
long_query_time=2.0
log-error = /var/log/mysql/mysql-error.log
binlog_format=MIXED
max_connect_errors=2000
server-id = unique_for_every_server
bind-address = 0.0.0.0
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = some DBs (main + mysql + informmation_schema)
binlog-ignore-db= (some DBs)
replicate_do_db= some DBs (main + mysql + informmation_schema)
replicate-ignore-db= some DBs
log_bin = /var/log/mysql/mysql-bin.log
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
default-time-zone='-04:00'
max_allowed_packet = 1024M
wait_timeout = 60000
interactive_timeout= 60000
connect_timeout= 60000
table_cache = 2048
sort_buffer_size = 100M
thread_concurrency = 500
innodb_thread_concurrency = 0
innodb_read_io_threads = 64
innodb_write_io_threads = 64
query_cache_size = 100M
query_cache_limit = 150M
tmp_table_size = 100M
innodb_buffer_pool_size = 500M
innodb_additional_mem_pool_size = 20M
join_buffer_size=500M
table_open_cache = 7000
key_buffer_size = 50M
thread_cache_size = 50
key_buffer_size = 150M
read_buffer_size = 100M
read_rnd_buffer_size = 50M
key_buffer = 100M
max_connections = 2000
我刚刚在 /my.cnf/
文件中添加了 innodb_flush_log_at_trx_commit = 2
,问题就解决了。