qq70191 发表于 2018-10-5 13:25:54

如何检查mysql数据库中mysql复制是否正常工作?

  通过在slave上执行show slave status来检查复制是否正常工作
  mysql> SHOW SLAVE STATUS\G
  *************************** 1. row ***************************
  Slave_IO_State: Waiting for master to send event
  Master_Host: master1
  Master_User: root
  Master_Port: 3306
  Connect_Retry: 60
  Master_Log_File: mysql-bin.000004
  Read_Master_Log_Pos: 931
  Relay_Log_File: slave1-relay-bin.000056
  Relay_Log_Pos: 950
  Relay_Master_Log_File: mysql-bin.000004
  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: 931
  Relay_Log_Space: 1365
  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: 0
  Slave_IO_State:代表当前slave的状态
  Slave_IO_Running:代表负责读取主库bin log的IO线程是否是运行状态,正常情况下应
  该是YES
  Slave_SQL_Running:代表负责执行备库relay log的SQL线程是否是运行状态,正常情
  况下应该是YES
  Last_IO_Error, Last_SQL_Error: 分别代表最后一次IO线程和SQL线程所发生的错误,
  正常情况下应该是空代表没有错误
  Seconds_Behind_Master:代表备库的SQL线程比主库的bin log晚多少秒。0代表目前
  没有复制延迟
  (Master_Log_file, Read_Master_Log_Pos):表示IO线程在主库bin log中的坐标位置
  (Relay_Master_Log_File, Exec_Master_Log_Pos):表示SQL线程在主库bin log中的坐
  标位置

  (Relay_Log_File,>  在主库可以通过执行show processlist命令查看主库的bin log日志生成进程
  mysql> SHOW PROCESSLIST \G;
  *************************** 4. row ***************************
  Id: 10
  User: root
  Host: slave1:58371
  db: NULL
  Command: Binlog Dump
  Time: 777
  State: Has sent all binlog to slave; waiting for binlog to be updated
  Info: NULL
  互联网企业大多用的数据库是MySQL的,想要众多的IT工作者中脱颖而出,就需要拥有高深的技术,学习增值是必不可少的。学习之路,是贵在坚持的。老男孩教育MySQL DBA课程,几经更新课程,杜绝纸上谈兵,全企业真实案例结合理论授课,想深入的学习MySQL DBA的知识,可以关注下老男孩教育。

页: [1]
查看完整版本: 如何检查mysql数据库中mysql复制是否正常工作?