Search code examples
mysqlheartbeat

What is heartbeat replication monitoring?


What is the meaning of "master heartbeat time period" in MySQL server, and how can I configure this variable in my.cnf?


Solution

  • As mentioned here on the mysql performance blog

    MASTER_HEATBEAT_PERIOD is a value in seconds in the range between 0 to 4294967 with resolution in milliseconds. After the loss of a beat the SLAVE IO Thread will disconnect and try to connect again.

    You can configure it on a slave using syntax also mentioned in that article and in the queries below.

    mysql_slave > STOP SLAVE;
    mysql_slave > CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=1;
    mysql_slave > START SLAVE;
    

    More information on using CHANGE MASTER can be found on the mysql documentation site

    MASTER_HEARTBEAT_PERIOD sets the interval in seconds between replication heartbeats. Whenever the master's binary log is updated with an event, the waiting period for the next heartbeat is reset. interval is a decimal value having the range 0 to 4294967 seconds and a resolution in milliseconds; the smallest nonzero value is 0.001. Heartbeats are sent by the master only if there are no unsent events in the binary log file for a period longer than interval.

    Setting interval to 0 disables heartbeats altogether. The default value for interval is equal to the value of slave_net_timeout divided by 2.