Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save masasuzu/3402591 to your computer and use it in GitHub Desktop.

Select an option

Save masasuzu/3402591 to your computer and use it in GitHub Desktop.
非同期レプリケーション時のmasterへの再接続の時系列
==+======================+=========================+=========================+========>
| | | |
| | | |
|<-------------------->|<----------------------->|<----------------------->|
| slave_net_timeout秒 | master-connect-retry秒 | master-connect-retry秒 |
| | (default 60秒) | |
| 再接続試行 再接続試行
|
| <--------------------------->
| master-retry-count回繰り返す
| (default 86400回)
master停止
こういうことだよね。認識が合っていれば、60 * 86400秒間は再接続のリトライするハズなんだけど、某サービスではそのままIO_THREADが死んだままだった。
master-connect-retryを変更するにはCHANGE MASTER TOで変更する必要がある。
STOP SLAVE;
CHANGE MASTER TO MASTER_CONNECT_RETRY = 5;
START SLAVE;
ネットワーク不調で、IO_THREADが切れたときの対策として、短くしておくと良い。(デフォルトのままだと60秒間Slaveは遅延したままになる。
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 127.0.0.1
Master_User: rsandbox
Master_Port: 21379
Connect_Retry: 1
Master_Log_File: mysql-bin.000005
Read_Master_Log_Pos: 107
Relay_Log_File: mysql_sandbox21380-relay-bin.002029
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000005
Slave_IO_Running: No
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: 107
Relay_Log_Space: 107
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: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 2003
Last_IO_Error: error connecting to master 'rsandbox@127.0.0.1:21379' - retry-time: 1 retries: 5
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment