GreatSQL社区

搜索

[已解决] MySQL主从延迟IO thread延迟如何解决?

167 6 2024-9-11 16:34
版本:8.0.22
从库my.cnf部分配置:


[mysqld]

innodb_file_per_table=1
innodb_buffer_pool_size=20G
innodb_data_file_path=ibdata1:10M:autoextend
innodb_flush_log_at_trx_commit=2
innodb_log_buffer_size=128M
innodb_log_file_size=512M
innodb_open_files=10000
innodb_log_files_in_group=2
innodb_max_dirty_pages_pct=90
innodb_lock_wait_timeout=120
innodb_read_io_threads=32
innodb_write_io_threads=32
innodb_change_buffer_max_size=50
innodb_doublewrite_pages=4
innodb_flush_neighbors=2
innodb_io_capacity=2000

innodb_flush_method=O_DIRECT
slave_preserve_commit_order=0

gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
sync_binlog=1
binlog_expire_logs_seconds=86400
log-bin=mysql-bin
binlog-format=row

relay_log_purge=ON
relay_log_recovery=ON
slave_parallel_workers=32
slave_parallel_type=LOGICAL_CLOCK
log_slave_updates=0
slave_skip_errors=1062,1032,1396,1050,1146
slave_compressed_protocol=1
thread_pool_size=128

read_only=ON

log_slow_slave_statements=1



问题描述:
从库使用show slave status不分结果如下

mysql> show slave status \G;
*************************** 1. row ***************************
               Slave_IO_State: Queueing master event to the relay log
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.155940
          Read_Master_Log_Pos: 868228467
               Relay_Log_File: relay-bin.000021
                Relay_Log_Pos: 868163874
        Relay_Master_Log_File: mysql-bin.155940
          Exec_Master_Log_Pos: 868163659
              Relay_Log_Space: 868228981
        Seconds_Behind_Master: 10594
这里面 Master_Log_File: mysql-bin.155940和 Relay_Master_Log_File: mysql-bin.155940文件是一样的,而主库当前的binlog文件是mysql-bin.156004
从库里面show processlist如下:

mysql> show full processlist ;
+-----+-----------------+----------------------+------+---------+-------+--------------------------------------------------------+-----------------------+-----------+---------------+
| Id  | User            | Host                 | db   | Command | Time  | State                                                  | Info                  | Rows_sent | Rows_examined |
+-----+-----------------+----------------------+------+---------+-------+--------------------------------------------------------+-----------------------+-----------+---------------+
|  10 | event_scheduler | localhost            | NULL | Daemon  |  1808 | Waiting for next activation                            | NULL                  |         0 |             0 |
| 224 | system user     | connecting host      | NULL | Connect |  2190 | Queueing master event to the relay log                 | NULL                  |         0 |             0 |
| 225 | system user     |                      | NULL | Query   |     0 | Slave has read all relay log; waiting for more updates | NULL                  |         0 |             0 |
| 226 | system user     |                      | NULL | Query   | 10396 | Executing event                                        | NULL                  |         0 |             0 |
| 227 | system user     |                      | NULL | Query   | 10396 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 228 | system user     |                      | NULL | Query   | 10396 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 229 | system user     |                      | NULL | Query   | 10396 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 230 | system user     |                      | NULL | Query   | 10396 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 231 | system user     |                      | NULL | Query   | 10396 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 232 | system user     |                      | NULL | Query   | 10396 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 233 | system user     |                      | NULL | Query   | 10396 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 234 | system user     |                      | NULL | Query   | 10397 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 235 | system user     |                      | NULL | Query   | 10397 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 236 | system user     |                      | NULL | Query   | 10397 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 237 | system user     |                      | NULL | Query   | 10397 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 238 | system user     |                      | NULL | Query   | 10397 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 239 | system user     |                      | NULL | Query   | 10401 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 240 | system user     |                      | NULL | Query   | 10403 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 241 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 242 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 243 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 244 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 245 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 246 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 247 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 248 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 249 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 250 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 251 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 252 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 253 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 254 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 255 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 256 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |
| 257 | system user     |                      | NULL | Query   | 10405 | Waiting for an event from Coordinator                  | NULL                  |         0 |             0 |


怀疑IO线程延迟,在从库服务器ping主库服务器如下

64 bytes from 10.10.100.18: icmp_seq=38 ttl=63 time=0.072 ms
64 bytes from 10.10.100.18: icmp_seq=39 ttl=63 time=0.100 ms
64 bytes from 10.10.100.18: icmp_seq=40 ttl=63 time=0.072 ms


show engine innodb status 结果如下:


=====================================
2024-09-11 16:20:20 0x7fedb80c5700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 39 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 2897 srv_active, 0 srv_shutdown, 0 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 155488
OS WAIT ARRAY INFO: signal count 350458
RW-shared spins 591607, rounds 609256, OS waits 14509
RW-excl spins 123001, rounds 751063, OS waits 4801
RW-sx spins 1557, rounds 23725, OS waits 554
Spin rounds per wait: 1.03 RW-shared, 6.11 RW-excl, 15.24 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 82681441338
Purge done for trx's n < 82681439833 undo n < 0 state: running but idle
History list length 752
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 422151917431864, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917430968, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917430072, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917429176, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917428280, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917427384, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917426488, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917425592, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917424696, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917423800, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917422904, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917422008, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917421112, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917420216, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917419320, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917418424, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917417528, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917416632, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917415736, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917414840, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917413944, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917413048, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917412152, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917411256, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917410360, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917409464, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917408568, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917407672, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917406776, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917404984, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917404088, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917403192, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917402296, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917401400, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917399608, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917398712, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917405880, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422151917397816, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 82681441337, ACTIVE 0 sec updating or deleting
mysql tables in use 1, locked 1
2 lock struct(s), heap size 1136, 1 row lock(s), undo log entries 1
MySQL thread id 226, OS thread handle 140658972677888, query id 14107417 Applying batch of row changes (update)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (read thread)
I/O thread 7 state: waiting for completed aio requests (read thread)
I/O thread 8 state: waiting for completed aio requests (read thread)
I/O thread 9 state: waiting for completed aio requests (read thread)
I/O thread 10 state: waiting for completed aio requests (read thread)
I/O thread 11 state: waiting for completed aio requests (read thread)
I/O thread 12 state: waiting for completed aio requests (read thread)
I/O thread 13 state: waiting for completed aio requests (read thread)
I/O thread 14 state: waiting for completed aio requests (read thread)
I/O thread 15 state: waiting for completed aio requests (read thread)
I/O thread 16 state: waiting for completed aio requests (read thread)
I/O thread 17 state: waiting for completed aio requests (read thread)
I/O thread 18 state: waiting for completed aio requests (read thread)
I/O thread 19 state: waiting for completed aio requests (read thread)
I/O thread 20 state: waiting for completed aio requests (read thread)
I/O thread 21 state: waiting for completed aio requests (read thread)
I/O thread 22 state: waiting for completed aio requests (read thread)
I/O thread 23 state: waiting for completed aio requests (read thread)
I/O thread 24 state: waiting for completed aio requests (read thread)
I/O thread 25 state: waiting for completed aio requests (read thread)
I/O thread 26 state: waiting for completed aio requests (read thread)
I/O thread 27 state: waiting for completed aio requests (read thread)
I/O thread 28 state: waiting for completed aio requests (read thread)
I/O thread 29 state: waiting for completed aio requests (read thread)
I/O thread 30 state: waiting for completed aio requests (read thread)
I/O thread 31 state: waiting for completed aio requests (read thread)
I/O thread 32 state: waiting for completed aio requests (read thread)
I/O thread 33 state: waiting for completed aio requests (read thread)
I/O thread 34 state: waiting for completed aio requests (write thread)
I/O thread 35 state: waiting for completed aio requests (write thread)
I/O thread 36 state: waiting for completed aio requests (write thread)
I/O thread 37 state: waiting for completed aio requests (write thread)
I/O thread 38 state: waiting for completed aio requests (write thread)
I/O thread 39 state: waiting for completed aio requests (write thread)
I/O thread 40 state: waiting for completed aio requests (write thread)
I/O thread 41 state: waiting for completed aio requests (write thread)
I/O thread 42 state: waiting for completed aio requests (write thread)
I/O thread 43 state: waiting for completed aio requests (write thread)
I/O thread 44 state: waiting for completed aio requests (write thread)
I/O thread 45 state: waiting for completed aio requests (write thread)
I/O thread 46 state: waiting for completed aio requests (write thread)
I/O thread 47 state: waiting for completed aio requests (write thread)
I/O thread 48 state: waiting for completed aio requests (write thread)
I/O thread 49 state: waiting for completed aio requests (write thread)
I/O thread 50 state: waiting for completed aio requests (write thread)
I/O thread 51 state: waiting for completed aio requests (write thread)
I/O thread 52 state: waiting for completed aio requests (write thread)
I/O thread 53 state: waiting for completed aio requests (write thread)
I/O thread 54 state: waiting for completed aio requests (write thread)
I/O thread 55 state: waiting for completed aio requests (write thread)
I/O thread 56 state: waiting for completed aio requests (write thread)
I/O thread 57 state: waiting for completed aio requests (write thread)
I/O thread 58 state: waiting for completed aio requests (write thread)
I/O thread 59 state: waiting for completed aio requests (write thread)
I/O thread 60 state: waiting for completed aio requests (write thread)
I/O thread 61 state: waiting for completed aio requests (write thread)
I/O thread 62 state: waiting for completed aio requests (write thread)
I/O thread 63 state: waiting for completed aio requests (write thread)
I/O thread 64 state: waiting for completed aio requests (write thread)
I/O thread 65 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] , aio writes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 2803
3588397 OS file reads, 198340126 OS file writes, 1963904 OS fsyncs
838.11 reads/s, 16383 avg bytes/read, 69444.25 writes/s, 419.12 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 49, free list len 349719, seg size 349769, 111102 merges
merged operations:
insert 117365, delete mark 27149, delete 6201
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 5312557, node heap has 79 buffer(s)
Hash table size 5312557, node heap has 13 buffer(s)
Hash table size 5312557, node heap has 14581 buffer(s)
Hash table size 5312557, node heap has 529 buffer(s)
Hash table size 5312557, node heap has 16 buffer(s)
Hash table size 5312557, node heap has 19 buffer(s)
Hash table size 5312557, node heap has 1890 buffer(s)
Hash table size 5312557, node heap has 313 buffer(s)
17451.40 hash searches/s, 15923.90 non-hash searches/s
---
LOG
---
Log sequence number          91736271373913
Log buffer assigned up to    91736271373913
Log buffer completed up to   91736271373913
Log written up to            91736271373913
Log flushed up to            91736268574749
Added dirty pages up to      91736271373913
Pages flushed up to          91735676091414
Last checkpoint at           91735676091414
Checkpoint age target        972734464
Modified age no less than    543288154
Checkpoint age               595282499
Max checkpoint age           948722176
Number of logs               2
Log size                     536870912
Log total size               1073741824
190647469 log i/o's done, 67826.79 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 21988638720
Dictionary memory allocated 33520482
Buffer pool size   1310560
Buffer pool size, bytes 21472215040
Free buffers       7512
Database pages     1285608
Old database pages 474648
Modified db pages  71715
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 930503, not young 9193759
0.00 youngs/s, 0.00 non-youngs/s
Pages read 3583418, created 109468, written 6180582
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 997 / 1000, young-making rate 1 / 1000 not 26 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 1285608, unzip_LRU len: 0
I/O sum[819056]:cur[1800], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       946
Database pages     160699
Old database pages 59321
Modified db pages  9126
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 116033, not young 1208060
0.00 youngs/s, 0.00 non-youngs/s
Pages read 447525, created 13439, written 778898
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 998 / 1000, young-making rate 0 / 1000 not 28 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160699, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       944
Database pages     160678
Old database pages 59324
Modified db pages  8323
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 114859, not young 1119175
0.00 youngs/s, 0.00 non-youngs/s
Pages read 443246, created 12822, written 747777
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 996 / 1000, young-making rate 1 / 1000 not 49 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160678, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       945
Database pages     160676
Old database pages 59319
Modified db pages  9291
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 117444, not young 1167103
0.00 youngs/s, 0.00 non-youngs/s
Pages read 450191, created 13912, written 796879
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 997 / 1000, young-making rate 0 / 1000 not 25 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160676, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       926
Database pages     160747
Old database pages 59358
Modified db pages  8891
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 116324, not young 1182767
0.00 youngs/s, 0.00 non-youngs/s
Pages read 447458, created 14047, written 763826
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 995 / 1000, young-making rate 1 / 1000 not 40 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160747, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       948
Database pages     160693
Old database pages 59321
Modified db pages  8653
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 117472, not young 1149096
0.00 youngs/s, 0.00 non-youngs/s
Pages read 451855, created 13561, written 772335
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 995 / 1000, young-making rate 1 / 1000 not 31 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160693, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       948
Database pages     160677
Old database pages 59314
Modified db pages  8988
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 115605, not young 1104205
0.00 youngs/s, 0.00 non-youngs/s
Pages read 449627, created 14222, written 774457
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 996 / 1000, young-making rate 1 / 1000 not 26 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160677, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       918
Database pages     160757
Old database pages 59361
Modified db pages  8630
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 117373, not young 1137145
0.00 youngs/s, 0.00 non-youngs/s
Pages read 449425, created 13007, written 756951
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 999 / 1000, young-making rate 0 / 1000 not 12 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160757, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size   163820
Buffer pool size, bytes 2684026880
Free buffers       937
Database pages     160681
Old database pages 59330
Modified db pages  9813
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 115393, not young 1126208
0.00 youngs/s, 0.00 non-youngs/s
Pages read 444091, created 14458, written 789459
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 997 / 1000, young-making rate 1 / 1000 not 19 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 160681, unzip_LRU len: 0
I/O sum[102382]:cur[225], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
2 RW transactions active inside InnoDB
Process ID=1, Main thread ID=140652233131776 , state=sleeping
Number of rows inserted 595955, updated 8353282, deleted 17633, read 8370926
385.20 inserts/s, 3001.95 updates/s, 17.18 deletes/s, 3019.13 reads/s
Number of system rows inserted 134104, updated 42116071, deleted 115318, read 45004768
29.31 inserts/s, 13133.61 updates/s, 17.18 deletes/s, 14585.86 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================



问题:
这里主从的延迟是不是IO线程延迟导致的,为什么 Master_Log_File: mysql-bin.155940和 Relay_Master_Log_File: mysql-bin.155940 文件是一样的,按理Master_Log_File应该是要保持跟当前主库的Binlog文件一样。



全部回复(6)
yejr 2024-9-11 16:44:31
第一次遇到这种情况,slave上看到的Master_Log_File 和 master 上看到的 binlog 差距太大了,可能是主机间网络连接出现问题了。

可以先看看两边服务器上系统及MySQL日志,看看能不能发现异常。
fengzhencai 2024-9-11 16:45:25
间隔了十分钟后执行mysql> show slave status \G;

*************************** 1. row ***************************
               Slave_IO_State: Queueing master event to the relay log
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.155975
          Read_Master_Log_Pos: 606507744
               Relay_Log_File: pbsdbs-0-relay-bin.000126
                Relay_Log_Pos: 605779044
        Relay_Master_Log_File: mysql-bin.155975
             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: 605778829
              Relay_Log_Space: 606508258
              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: 9694
fengzhencai 2024-9-11 16:46:48
在上一次show slave status 过后的十秒后 再看:
mysql> show slave status \G;
*************************** 1. row ***************************
               Slave_IO_State: Queueing master event to the relay log
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.155977
          Read_Master_Log_Pos: 1847205
               Relay_Log_File: relay-bin.000132
                Relay_Log_Pos: 64262
        Relay_Master_Log_File: mysql-bin.155977
             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: 64047
              Relay_Log_Space: 1847719
              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: 9546
fengzhencai 2024-9-11 16:48:27
又过了十秒以后:
mysql> show slave status \G;
*************************** 1. row ***************************
               Slave_IO_State: Queueing master event to the relay log
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.155978
          Read_Master_Log_Pos: 19122071
               Relay_Log_File: relay-bin.000135
                Relay_Log_Pos: 18047903
        Relay_Master_Log_File: mysql-bin.155978
             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: 18047688
              Relay_Log_Space: 19122585
              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: 9457
yejr 2024-9-11 16:50:42
fengzhencai 发表于 2024-9-11 16:45
间隔了十分钟后执行mysql> show slave status \G;

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

看到你补充的10分钟后观察结果
          Read_Master_Log_Pos: 606507744
...
          Exec_Master_Log_Pos: 605778829

二者相差了 728915 ,这个差距还是很大的,你再看看slave端的磁盘I/O能力是不是很差。

也直接尝试在slave端,去master端scp一个GB级别的文件测试看看传输效率。
reddey 2024-9-11 20:16:37
yejr 发表于 2024-9-11 16:50
看到你补充的10分钟后观察结果
          Read_Master_Log_Pos: 606507744
...

还是要检查一下硬盘的IO性能
一个学艺不精的国产数据库爱好者
fengzhencai

6

主题

0

博客

23

贡献

新手上路

Rank: 1

积分
40

助人为乐(铜)

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-12-4 01:53 , Processed in 0.024624 second(s), 20 queries , Redis On.
快速回复 返回顶部 返回列表