首页 > 其他分享 >percona toolkit之pt-slave-restart使用

percona toolkit之pt-slave-restart使用

时间:2023-06-07 17:58:44浏览次数:46  
标签:slave Log pt SSL toolkit Source Replicate SQL Last

介绍

pt-slave-restart是一款mysql主从异常处理工具,监控replica端SQL_THREAD是否正常,如果异常pt-slave-restart尝试跳过导致错误的事务,然后重新启动SQL_THREAD已达到修复SQL_THREAD的目的。

 

测试

MySQL主从复制source端

mysql> select * from t1;
+----+-------+
| id | name  |
+----+-------+
|  1 | name1 |
|  2 | name2 |
|  3 | name3 |
+----+-------+

 

MySQL主从复制replica端

mysql> select * from t1;
+----+-------+
| id | name  |
+----+-------+
|  1 | name1 |
|  2 | name2 |
|  3 | name3 |
+----+-------+

 

执行pt-slave-restart监控replica端

[root]# pt-slave-restart h=192.168.1.73,P=3312,u=root,p=m密码

 

MySQL主从复制source端

mysql> set sql_log_bin=0;
mysql> insert into t1 values(4,'name4');
mysql> set sql_log_bin=1;
mysql> delete from t1 where id=4;

 

MySQL主从复制replica端,此时SQL_THREAD线程报错1062报错:

mysql> show replica status\G
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 192.168.1.73
                  Source_User: repuser
                  Source_Port: 3311
                Connect_Retry: 60
              Source_Log_File: binlog.000045
          Read_Source_Log_Pos: 1021064795
               Relay_Log_File: 64562e05689a-relay-bin.000056
                Relay_Log_Pos: 1095227
        Relay_Source_Log_File: binlog.000045
           Replica_IO_Running: Yes
          Replica_SQL_Running: No
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 1062
                   Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'ANONYMOUS' at source log binlog.000045, end_log_pos 1021061873. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 1021061586
              Relay_Log_Space: 1021065568
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File: 
           Source_SSL_CA_Path: 
              Source_SSL_Cert: 
            Source_SSL_Cipher: 
               Source_SSL_Key: 
        Seconds_Behind_Source: NULL
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 1062
               Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'ANONYMOUS' at source log binlog.000045, end_log_pos 1021061873. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
  Replicate_Ignore_Server_Ids: 
             Source_Server_Id: 88
                  Source_UUID: e28ee878-f92e-11ed-b68e-0242ac110003
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: 
           Source_Retry_Count: 86400
                  Source_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 230607 09:04:33
               Source_SSL_Crl: 
           Source_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Source_TLS_Version: 
       Source_public_key_path: 
        Get_Source_public_key: 0
            Network_Namespace: 

 

稍等一会儿,pt-slave-restart会自动修复replica端主从异常

[root]# pt-slave-restart h=192.168.1.73,P=3312,u=root,p=Gaoyu@029
2023-06-07T17:01:10 P=3312,h=192.168.1.73,p=...,u=root 64562e05689a-relay-bin.000056     1004491 1062 

注释:
    时间戳:2023-06-07T17:01:10
    replica端信息:P=3312,h=192.168.1.73,p=...,u=root
    relay log:64562e05689a-relay-bin.000056
    relay log位置:1004491
    主从复制最后报错码:1062

 

查看replica端主从复制信息,此时主从复制恢复正常

mysql> show replica status\G
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 192.168.1.73
                  Source_User: repuser
                  Source_Port: 3311
                Connect_Retry: 60
              Source_Log_File: binlog.000045
          Read_Source_Log_Pos: 1021515791
               Relay_Log_File: 64562e05689a-relay-bin.000056
                Relay_Log_Pos: 1549019
        Relay_Source_Log_File: binlog.000045
           Replica_IO_Running: Yes
          Replica_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_Source_Log_Pos: 1021515378
              Relay_Log_Space: 1021516564
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File: 
           Source_SSL_CA_Path: 
              Source_SSL_Cert: 
            Source_SSL_Cipher: 
               Source_SSL_Key: 
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Source_Server_Id: 88
                  Source_UUID: e28ee878-f92e-11ed-b68e-0242ac110003
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 86400
                  Source_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Source_SSL_Crl: 
           Source_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Source_TLS_Version: 
       Source_public_key_path: 
        Get_Source_public_key: 0
            Network_Namespace: 

 

此时source端与replica端t1表数据是一致的,因为source端先insert后delete。 

 

参考:https://docs.percona.com/percona-toolkit/pt-slave-restart.html

标签:slave,Log,pt,SSL,toolkit,Source,Replicate,SQL,Last
From: https://www.cnblogs.com/haha029/p/17464108.html

相关文章

  • 我让 ChatGPT 回答了知乎收藏最高的 Top 20 个问题
    文/高扬 按上一次所讲的方式,我向它请教了知乎上的收藏数/关注数最多的Top20问题。 经测试,比如“有什么终生受用的技能”这类人生泛用型问题基本都能回答。 对于推荐音乐、电影、网购等类型,它回答的不是太好,可能我用的是GPT3.5版本,还并没有能力浏览网页或访问数......
  • Chtjpt:下一代技术的引领者
    Chtjpt(ChatbotwithGPT-3.5)是基于GPT-3.5架构开发的一种先进的对话生成技术。通过深度学习和自然语言处理技术的结合,Chtjpt在智能对话领域展现了卓越的性能。本文将探讨Chtjpt技术的背景、应用领域和未来发展前景。背景Chtjpt技术是基于GPT-3.5模型的扩展和改进,GPT-3.5是由OpenAI......
  • ChatGPT在生物医学领域的应用
    ChatGPT在生物医学领域的应用组长:杨欢      组员:陈海月、徐琼、邾蓉烨摘要:目前,人工智能在生物医学领域的应用已经取得了令人瞩目的进展,ChatGPT作为一种基于人工智能的聊天机器人模型,因其具有强大的自然语言处理和生成能力,在生物医学领域有着广泛的应用潜力。在本研究......
  • docker iptables
    -name:获取是否已经安装dockershell:'systemctlis-activedocker||echo"NoFound"'register:docker_svc#18.09.x版本二进制名字有变化,需要做判断-name:获取docker版本信息shell:"{{base_dir}}/bin/dockerd--version|cut-d''-f3"regist......
  • TypeScript 的基础知识(跟着ChartGpt学习)
    以下都是我的ChartGpt老师教学的内容哦,(若想知道怎么用ChartGpt学习,或者想知道我的问答方式,可以点这个查看我的学习记录)一:TypeScript的基本数据类型TypeScript支持JavaScript的基本数据类型,包括number、string、boolean、null、undefined和symbol。其中,number表示数......
  • TypeScript 的简介(跟着ChartGpt学习)
    以下都是我的ChartGpt老师教学的内容哦,(若想知道怎么用ChartGpt学习,或者想知道我的问答方式,可以点这个查看我的学习记录)TypeScript是一种由微软开发和维护的开源编程语言,它是JavaScript的一个超集,也就是说,所有的JavaScript代码都可以被TypeScript编译器编译。TypeScript......
  • extendscript
    //获取当前活动序列varactiveSequence=app.project.activeSequence;//获取视频轨道和标签的位置varvideoTrack=activeSequence.videoTracks[0];//假设视频位于第一个视频轨道varmarker1=activeSequence.markers[0];varmarker2=activeSequence.markers[1];//......
  • 从TPT看汽车测试术语(上)
      汽车世界在不断发展,“软件定义的汽车”等新术语证明了软件对当今汽车的重要性。无论是MiL、SiL、PiL、HiL、还是单元测试、集成测试,汽车软件测试的世界有很多技术术语,本文将从一款专业的汽车软件测试工具TPT出发,带大家从实际应用的角度掌握汽车测试术语。  什么是测试......
  • 面向开发者的 ChatGPT 提示工程课程|吴恩达携手OpenAI 教你如何编写 prompt
    提示工程(PromptEngineering)是一门相对较新的学科,旨在开发和优化提示,从而高效地将语言模型(LM)用于各种应用和研究主题,并帮助开发人员更好地理解大型语言模型(LLM)的能力和局限。随着ChatGPT等大语言模型的爆火,提示工程在大模型中的重要性不言而喻。有效的提示工程需要考虑哪些......
  • JavaScript上传文件
    效果实现无论是上传文件还是上传图片,用的都是input标签的type="file";input标签触发onChange事件时,会接受input元素本身作为参数,元素对象的files属性,值是fileList(即文件列表,列表中是一个个文件对象,文件对象包括文件的名称,大小等);有了文件列表之后,需要创建一个FileReader对象......