时间:2021-07-01 10:21:17 帮助过:6人阅读
date +%F-mysql-all.sql还恢复手动同步数据
set sql_log_bin=0;
     source /tmp/2018-3-20-mysql-full.sql
3.设置主服务器
   mysql> change master tomaster_host=‘master1‘,master_user=‘rep‘,
master_password=‘QianFeng@123‘,
br/>master_user=‘rep‘,
master_password=‘QianFeng@123‘,
    start slave;
    show slave status\G;
    到这里没什么问题一主一从就部署完成了,如果有错误可借鉴以下方法排错,希望能帮助到大家!
    例:
    *************************** 1. row ***************************  
       Slave_IO_State: Waiting for master to send event  
          Master_Host: 192.168.60.159  
          Master_User: backup  
          Master_Port: 3311  
        Connect_Retry: 60  
      Master_Log_File: mysql-bin.000012  
  Read_Master_Log_Pos: 274863854  
       Relay_Log_File: mysql-relay-bin.000007  
        Relay_Log_Pos: 2160037  
Relay_Master_Log_File: mysql-bin.000012  
     Slave_IO_Running: Yes  
    Slave_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: 1146  
Last_Error: Error executing row event: ‘Table ‘panda.t‘ doesn‘t exist‘  
Skip_Counter: 0  
Exec_Master_Log_Pos: 2159824  
Relay_Log_Space: 274866725 
    错误原因:主库删除的表在从库中不存在,导致从库在遇到删除不存在表的错误时无法继续同步。
    解决方法:利用slave-skip-errors参数,跳过对于的1146错误(这个参数是一个只读的,需要在配置文件中修改,并重启从库)
    1、在my.cnf的[mysqld]下面添加slave_skip_errors=11462、重启从库 systemctl restart mysqld
3、在从库上启动同步
start slave;
4、去掉my.cnf中的slave_skip_errors=11465、重启从库 systemctl restart mysqld
6、启动从库复制
start slave;
例:
 1. row   
Slave_IO_State: Waiting for master to send event  
Master_Host: 192.168.60.159  
Master_User: backup  
Master_Port: 3311  
Connect_Retry: 60  
Master_Log_File: mysql-bin.000012  
Read_Master_Log_Pos: 274863854  
Relay_Log_File: mysql-relay-bin.000007  
Relay_Log_Pos: 2160037  
Relay_Master_Log_File: mysql-bin.000012  
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: 1146  
Last_Error: Error executing row event: ‘Table ‘panda.t‘ doesn‘t exist‘  
Skip_Counter: 0  
Exec_Master_Log_Pos: 2159824  
Relay_Log_Space: 274866725 
错误原因:主和从的UUID一致,需改动从机的UUID即可
解决方法:
  1.在从机上 cd /var/lib/mysql
     ls 看到auto.cnf
         vim auto.cnf    随意改动一个数字即可
        保存并退出
        systemctl restart mysqld
    2.进入Mysql
        start slave;
成功
好了,到这里就结束了,有错的地方望大家批评和建议!!!NO4.Mysql数据库 主从复制 出错的解决办法
标签:Linux运维