slave_net_timeout, MASTER_HEARTBEAT_PERIOD, MASTER_CONNECT_RETRY, as well as set and view MASTER_RETRY_COUNT

In the master-slave replication, there are several parameters is very important to include slave_net_timeout, MASTER_HEARTBEAT_PERIOD, MASTER_CONNECT_RETRY, and MASTER_RETRY_COUNT.

  • It represents slave_net_timeout master slave has not received any data (including binlog, heartbeat) within slave_net_timeout of time, that slave disconnected, needs to reconnect. The default value is 60s.

  • MASTER_HEARTBEAT_PERIOD represents a period heartbeat. When the MASTER_HEARTBEAT_PERIOD of time, no Master binlog event sent to the slave when the slave sends data to the heartbeat.

  • MASTER_CONNECT_RETRY represents reconnection interval.
    After slave_net_timeout timeout reconnection immediately subsequent reconnection interval MASTER_CONNECT_RETRY by the CHANGE MASTER TO command parameters specified. The default value is 60s.

  • MASTER_CONNECT_RETRY represents the maximum number of reconnection. The default value is 86400 times.

View and set the 1.slave_net_timeout

View slave_net_timeout can use the following ways:

mysql> select @@global.slave_net_timeout;
+----------------------------+
| @@global.slave_net_timeout |
+----------------------------+
|                         60 |
+----------------------------+
1 row in set (0.00 sec)

or

mysql> show variables like 'slave_net_timeout';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| slave_net_timeout | 50    |
+-------------------+-------+
1 row in set (0.00 sec)

Set slave_net_timeout:

mysql> set global slave_net_timeout=50;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'slave_net_timeout';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| slave_net_timeout | 50    |
+-------------------+-------+
1 row in set (0.00 sec)

2.MASTER_HEARTBEAT_PERIOD, MASTER_CONNECT_RETRY,以及 MASTER_RETRY_COUNT

Set 2.1

MASTER_HEARTBEAT_PERIOD
MASTER_HEARTBEAT_PERIOD to command set by the change master.
with no change master to heartbeat parameters, the default is set to half of slave_net_timeoute. When slave_net_timeoute change, does not modify the heartbeat.

MASTER_RETRY_COUNT
MASTER_RETRY_COUNT through the command line parameter --master-retry-count settings can also be set by change master to fashion.
The former is not recommended, encourage the use of change master to.

MASTER_CONNECT_RETRY
MASTER_CONNECT_RETRY to command set by the change master.

2.2 View

Execution show slave status from the library, you can view Master_Retry_Count, Connect_Retry, as well as more master copy from the storage location information Master_Info_File.

>show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: xr-dba-mysql-hazyytest-test01
                  Master_User: XXXX
                  Master_Port: 5002
                Connect_Retry: 10
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 488
               Relay_Log_File: relay.000002
                Relay_Log_Pos: 698
        Relay_Master_Log_File: mysql-bin.000001
             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: 488
              Relay_Log_Space: 892
              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: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 48201050
                  Master_UUID: 10035945-ddeb-11e9-89f3-0022ac533a2f
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 10035945-ddeb-11e9-89f3-0022ac533a2f:1-2
            Executed_Gtid_Set: 10035945-ddeb-11e9-89f3-0022ac533a2f:1-2
                Auto_Position: 1
1 row in set (0.00 sec)

Can be seen from the above results, Master_Info_File stored in the data tables:
Master_Info_File: mysql.slave_master_info.

Then by querying the data table to see these parameters:

>select * from mysql.slave_master_info\G
*************************** 1. row ***************************
       Number_of_lines: 23
       Master_log_name: mysql-bin.000001
        Master_log_pos: 488
                  Host: xr-dba-mysql-hazyytest-test01
             User_name: XXX
         User_password: XXXX
                  Port: 5002
         Connect_retry: 10
           Enabled_ssl: 0
                Ssl_ca:
            Ssl_capath:
              Ssl_cert:
            Ssl_cipher:
               Ssl_key:
Ssl_verify_server_cert: 0
             Heartbeat: 8
                  Bind:
    Ignored_server_ids: 0
                  Uuid: 10035945-ddeb-11e9-89f3-0022ac533a2f
           Retry_count: 86400
               Ssl_crl:
           Ssl_crlpath:
 Enabled_auto_position: 1
1 row in set (0.00 sec)

Here, Connect_retry to 10, Heartbeat to 8, Retry_count 86400.

>select Connect_retry,Heartbeat, Retry_count from mysql.slave_master_info;
+---------------+-----------+-------------+
| Connect_retry | Heartbeat | Retry_count |
+---------------+-----------+-------------+
|            10 |         8 |       86400 |
+---------------+-----------+-------------+
1 row in set (0.00 sec)

In addition, these parameters are configured in executing a query command from the main library on the library, the result is empty.

>select Connect_retry,Heartbeat, Retry_count from mysql.slave_master_info;
Empty set (0.00 sec)

In MySQL5.7 version, you can also view these parameters in replication-connection-configuration-table in.

> select * from performance_schema.replication_connection_configuration\G
*************************** 1. row ***************************
                 CHANNEL_NAME:
                         HOST: 10.23.66.88
                         PORT: 5002
                         USER: repl
            NETWORK_INTERFACE:
                AUTO_POSITION: 1
                  SSL_ALLOWED: NO
                  SSL_CA_FILE:
                  SSL_CA_PATH:
              SSL_CERTIFICATE:
                   SSL_CIPHER:
                      SSL_KEY:
SSL_VERIFY_SERVER_CERTIFICATE: NO
                 SSL_CRL_FILE:
                 SSL_CRL_PATH:
    CONNECTION_RETRY_INTERVAL: 60
       CONNECTION_RETRY_COUNT: 86400
           HEARTBEAT_INTERVAL: 60.000
                  TLS_VERSION:
1 row in set (0.01 sec)

3. References

change master to

replication-connection-configuration-table

Guess you like

Origin www.cnblogs.com/lanyangsh/p/12375274.html
Recommended