【场景】MySQL版本:Percona-Server 5.6.23,相关主要参数:

server_id = 3306
sync_binlog=1
gtid_mod = on
enforce-gtid-consistency = 1
log-slave-updates = 1
relay-log-purge = 1
relay_log_recovery = 1
master_info_repository = "TABLE"
relay_log_info_repository = "TABLE"

打算部署一个新的slave实例用于测试,图方便从master上直接把mysql这个系统库整个目录拷贝到slave上,进行初始化后,执行 CHANGE MASTER 配置主从复制,但却提示错误信息:

mysql> change master to master_host=’10.x.x.x’,master_port=3306,master_user=’repl’,master_password=’xx’,master_auto_position=1;
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.

看到这个错误信息,最直觉的反应是 server_id 设置错误了,比如和 master 的ID重复了。经过检查,确认不是这个原因,尝试检查了其他参数,也提示同样的错误。另外奇怪的是,上面的错误信息,未被记录到错误日志中。

【分析】应该注意到一点,上面提到初始化slave实例时,是从master上直接拷贝mysql系统库整个目录的,但并没有同时也拷贝 ibdata1、ib_logfile* 等InnoDB相关文件。其实问题就在这里,因为mysql系统库中,下面这几个表是采用InnoDB引擎的,所以初始化后,无法正常读写:

innodb_index_stats
innodb_table_stats
slave_master_info
slave_relay_log_info
slave_worker_info

经验证,通过客户端访问mysql库时,就会提示下面的错误信息了:

2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/innodb_index_stats from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/innodb_table_stats from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/slave_worker_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

【解决】本次案例中造成上述问题的原因是没有按照标准流程进行初始化,或者没有把master上的全部相关文件都拷贝到slave上去,导致mysql库下的几个InnoDB表无法使用。

解决的方法有两个:

1、删解除mysql系统库目录下上述几个表对应的ibd文件,执行 mysql_install_db 重新初始化;

2、从master将整个数据库全部文件都拷贝到slave上,并确认InnoDB的共享表空间文件及REDO LOG大小配置和master上是一致的;

转载于:https://blog.51cto.com/11736068/1877792

mysql报错:You must at least set –server-id to enable either a master or a slave相关推荐

  1. 连接mysql报错WARN: Establishing SSL connection without server‘s identity verification is not recommended

    一.详细报错信息 Fri Jul 29 09:04:03 GMT+08:00 2022 WARN: Establishing SSL connection without server's ident ...

  2. mysql 报错 get error 28 from storage engine 解决方法

    mysql 报错 get error 28 from storage engine 解决方法 参考文章: (1)mysql 报错 get error 28 from storage engine 解决 ...

  3. Mysql报错Fatal error:Can't open and lock privilege tables

     Mysql报错Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 安装mysql后 ...

  4. 登录mysql报错2059,navicat连接mysql报错2059如何解决

    navicat连接mysql报错2059,如下图所示: 网上查询过后,发现这个错误出现的原因是在mysql8之前的版本中加密规则为mysql_native_password,而在mysql8以后的加密 ...

  5. python怎么捕获mysql报错

    一.前言 最近在运行python脚本的时候,经常出现:mysql server has gone away的错误,导致脚本停止运行.只是代码里面明明已经使用try: except 这种方式来捕获mys ...

  6. mysql报错:Reading table information for completion of table and column names

    一.前言 在使用命令行打开数据库的时候,报错如标题所示.这里总结记录一下. 二.错误原因 1.锁表的原因 参考链接:https://blog.csdn.net/ssergsw/article/deta ...

  7. 安装32位mysql报错_在CentOS中安装32位或64位MySql报错error: Failed dependencies解决办法...

    在CentOS中安装MySql报错error: Failed dependencies解决办法 安装64位MySql报错内容如下: error: Failed dependencies: libaio ...

  8. Navicat 远程连接docker容器中的mysql 报错1251 - Client does not support authentication protocol 解决办法

    Navicat 远程连接docker容器中的mysql 报错1251 - Client does not support authentication protocol 解决办法 1).容器中登录my ...

  9. 解决MySQL报错ERROR 2002 (HY000)【转】

    今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...

  10. ERROR 1366 (HY000): Incorrect string value......(Mysql报错解决)

    2019.11.29更新:发现了新的解决方法 错误描述 在控制台执行插入操作的时候,Mysql报错ERROR 1366 (HY000): Incorrect string value--插入操作失败, ...

最新文章

  1. 程序集注册工具 (Regasm.exe)
  2. 利用 Android Studio 和 Gradle 打包多版本APK
  3. 牛客网(剑指offer) 第六题 旋转数组的最小数字
  4. [BUUCTF-pwn]——jarvisoj_tell_me_something
  5. setXxx()和getXxx()的作用
  6. Eclipse 不为人所知的另一面 - 企业管理软件领域 ABAP 编程语言开发利器
  7. linux内核优化脚本,linux内核高级优化脚本
  8. facebook开源的prophet时间序列预测工具---识别多种周期性、趋势性(线性,logistic)、节假日效应,以及部分异常值
  9. (二)CXF之用CXF官方工具生成客户端Client
  10. ROS学习笔记8 —— 状态机在ROS中的实现
  11. 2021年4月4日新增
  12. 初探 spring data(一)--- spring data 概述
  13. 查找共家庭组计算机,家庭组多台电脑共享方法
  14. 执行ansible报CryptographyDeprecationWarning
  15. C# System.Net.Mail 类 使用465端口邮件不成功
  16. 夜深忽梦少年事,7年又一年,来看看95年那个小伙现在怎么样了
  17. 电脑文件夹删除不了的解决办法
  18. Activiti7学习之六查看流程历史信息、businessKey
  19. 将模型轴心点在unity中归正
  20. Linux——基础+常用命令

热门文章

  1. Matlab实现Hough变换检測图像中的直线
  2. JavaScript 类式继承与原型继承
  3. jTemplate —— 基于jQuery的javascript前台模版引擎
  4. Alfresco 4 项目介绍
  5. JavaScript:table元素行的添加和删除
  6. [导入]SQL Server存储过程编程经验技巧
  7. 关于Mac电脑更新IP地址的解决方法!
  8. iOS底层探索之KVC
  9. JavaScript静态页面值传递之URL篇
  10. java多态(翻译自Java Tutorials)