• MySQL 跨版本主从复制时报错:ERROR 1794 (HY000): Slave is not configured or failed to initialize properly.


    背景: zabbix 数据库迁移,搭建主从,主是5.6.25,从是5.7.15,流式备份应用 redo.log 之后,change master 和reset slave 时报出如下错误

    mysql> CHANGE MASTER TO
        ->   MASTER_HOST='192.168.40.129',
        ->   MASTER_USER='repl',
        ->   MASTER_PASSWORD='repl_123',
        ->   MASTER_PORT=3306,
        ->   MASTER_LOG_FILE='mysql-bin.000005',       
        ->   MASTER_LOG_POS=749,
        ->   MASTER_AUTO_POSITION=0;
    ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.  

    原因:从 5.6.25 版本使用 innobackupex 备份,在 5.7.15 版本中应用恢复,在 5.6.25 版本中,主从信息记录到了文件中,5.7.15 版本中的主从信息记录的是在表中,所以数据备份后需要对下面几张表进行重建。

    --5.6.25
    mysql> show variables like '%repository%';
    +---------------------------+-------+
    | Variable_name             | Value |
    +---------------------------+-------+
    | master_info_repository    | FILE  |
    | relay_log_info_repository | FILE  |
    +---------------------------+-------+
    2 rows in set (0.00 sec)
    --5.7.15
    
    mysql> show variables like '%repository%';
    +---------------------------+-------+
    | Variable_name             | Value |
    +---------------------------+-------+
    | master_info_repository    | TABLE |
    | relay_log_info_repository | TABLE |
    +---------------------------+-------+
    2 rows in set (0.00 sec)
    

     

    解决步骤:

    1、drop 备份的 ibd表

    use mysql
    drop table slave_master_info;
    drop table slave_relay_log_info;
    drop table slave_worker_info;
    drop table innodb_index_stats;
    drop table innodb_table_stats;

    2、重建

    mysql> source /usr/local/mysql/share/mysql_system_tables.sql
    Query OK, 0 rows affected, 1 warning (0.00 sec) 

    3、重启数据库

    [root@zero02 data]# /etc/init.d/mysqld restart
    Shutting down MySQL..                                      [  OK  ]
    Starting MySQL..                                           [  OK  ]
    

      至此,问题解决,登陆数据库,重新 change master to 即可!

    作者:zero_gg
    出处:http://www.cnblogs.com/zero-gg/

    如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨小小打赏一下吧,如果囊中羞涩,不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!

    本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.

  • 相关阅读:
    Android9.0/8.1/6.0 默认给系统 app 授予所有权限
    Git——处理Warning: CocoaPods is installed but broken. Skipping pod install. You appear to have CocoaPods installed but it is not working.
    Git——error: RPC failed; curl 56 LibreSSL SSL_read:报错处理
    Git——To install: sudo gem install cocoapods 报错处理
    Xcode——清除缓存相关文件
    vue —— 拉取远程仓库在本地开发
    vue —— mac中配置Node、NPM环境
    Flutter——常见报错处理
    Git——从githup上克隆下一个完整的项目操作步骤
    Git——rebase实际操作遇到的问题
  • 原文地址:https://www.cnblogs.com/zero-gg/p/9295950.html
Copyright © 2020-2023  润新知