Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

主从切换原主库同步失败 #1013

Closed
cossbow opened this issue Jan 20, 2021 · 2 comments
Closed

主从切换原主库同步失败 #1013

cossbow opened this issue Jan 20, 2021 · 2 comments

Comments

@cossbow
Copy link

cossbow commented Jan 20, 2021

我运行了三个节点,一个主库两个从库,然后运行5个哨兵,一般情况下关闭主库能切换完成,但偶尔发生这种情况:重新再启动原来的主库A的时候,从当前的主库B同步数据时发生错误,具体错误信息没找到,只找到以下日志:
A的INFO日志

I0120 13:38:30.782464 2371 pika.cc:191] Server at: pika.conf
I0120 13:38:30.783274 2371 pika_server.cc:176] Using Networker Interface: ens32
I0120 13:38:30.784133 2371 pika_server.cc:219] host: 172.16.0.81 port: 6483
I0120 13:38:30.784153 2371 pika_server.cc:95] Worker queue limit is 20100
I0120 13:38:30.784390 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:30.784500 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:30.784549 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:30.784627 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:30.784678 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:30.784725 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:30.784775 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:30.784829 2371 pika_binlog.cc:111] Binlog: Find the exist file.
I0120 13:38:31.831373 2371 pika_partition.cc:87] db0 DB Success
I0120 13:38:31.855065 2371 pika_partition.cc:87] db1 DB Success
I0120 13:38:31.879359 2371 pika_partition.cc:87] db2 DB Success
I0120 13:38:31.921152 2371 pika_partition.cc:87] db3 DB Success
I0120 13:38:31.947860 2371 pika_partition.cc:87] db4 DB Success
I0120 13:38:31.971632 2371 pika_partition.cc:87] db5 DB Success
I0120 13:38:31.996385 2371 pika_partition.cc:87] db6 DB Success
I0120 13:38:32.020203 2371 pika_partition.cc:87] db7 DB Success
I0120 13:38:32.020740 2371 pika_server.cc:273] Pika Server going to start
I0120 13:38:32.020967 2400 pika_repl_client.cc:146] Try Send Meta Sync Request to Master (172.16.0.81:6482)
I0120 13:38:32.022534 2373 pika_server.cc:618] Mark try connect finish
I0120 13:38:32.022550 2373 pika_repl_client_conn.cc:146] Finish to handle meta sync response
I0120 13:38:32.166294 2374 pika_repl_client_conn.cc:258] Partition: db6 TrySync Ok
I0120 13:38:32.166479 2374 pika_repl_client_conn.cc:258] Partition: db4 TrySync Ok
I0120 13:38:32.166548 2373 pika_repl_client_conn.cc:258] Partition: db5 TrySync Ok
I0120 13:38:32.166859 2374 pika_repl_client_conn.cc:258] Partition: db1 TrySync Ok
I0120 13:38:32.166882 2373 pika_repl_client_conn.cc:258] Partition: db3 TrySync Ok
I0120 13:38:32.166898 2373 pika_repl_client_conn.cc:258] Partition: db7 TrySync Ok
I0120 13:38:32.166908 2373 pika_repl_client_conn.cc:258] Partition: db0 TrySync Ok

A的WARNING日志

Log file created at: 2021/01/20 13:38:32
Running on machine: localhost.localdomain
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
W0120 13:38:32.166677 2374 pika_repl_client_conn.cc:267] Partition: db2 TrySync Error

B的WARNING日志

W0120 14:37:51.114579 1463 pika_repl_server_conn.cc:274] Slave offset is not a start point of cur log, Slave ip: 172.16.0.81, Slave port: 6483, Partition: db2, cloest start point, filenum: 313, offset: 3796997

请问这个问题怎么手动处理呢?还是只能重建A的数据库(删除重新同步的那种)

@kernelai
Copy link
Collaborator

第一次发生主从切换时,B可能会丢失一部分数据,导致A第二次同步时,A与B的binlog点位不一致。这时候,可以强制全同步,在A上执行slaveof B_ip B_port force.从而使A上的数据与B完全一致。

@cossbow
Copy link
Author

cossbow commented Jan 26, 2021

哦,多谢了;虽然和重新建库一样,不过不用restart和delete,安全一些😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants