简体   繁体   English

mysql复制错误:候选从属缺少复制用户

[英]mysql replication error: Candidate slave is missing replication user

Context: I'm trying to set up mysql replication with one master and one slave. 上下文:我正在尝试使用一个主机和一个从机设置mysql复制。 I'm using the new GTID method in mysql 5.6, along with the mysql utilities for automatic failover. 我正在mysql 5.6中使用新的GTID方法,以及用于自动故障转移的mysql实用程序。

I'm able to set up replication with a master node M and a slave node S. 我能够使用主节点M和从节点S设置复制。

I'm trying to run through a simple script to show myself that everything is set up correctly. 我正在尝试通过一个简单的脚本来向自己展示一切都已正确设置。 The script is as follows: 脚本如下:

  1. Set up replication with node M as master and node S as slave 设置复制,节点M为主节点,节点S为从节点
  2. Ensure that changes made to tables in M are reflected in S 确保对M中的表所做的更改反映在S中
  3. Shutdown M and ensure that S takes over as new master 关闭M并确保S接任新主人
  4. Make a few table changes to S 对S进行一些表更改
  5. Startup M and add it back to cluster as a slave 启动M并将其作为从属服务器添加回集群
  6. Ensure that M catches up to S with its updates 确保M的更新赶上S
  7. Make M the master node again 使M再次成为主节点

My script seems successful until the last step. 直到最后一步,我的脚本似乎都成功了。 Largely, I'm following the steps here: http://www.clusterdb.com/mysql/replication-and-auto-failover-made-easy-with-mysql-utilities 基本上,我在这里按照以下步骤操作: http : //www.clusterdb.com/mysql/replication-and-auto-failover-made-easy-with-mysql-utilities

But when I run "mysqlrpladmin --master=root@S_NODE --new-master=root@M_NODE --demote-master --discover-slaves-login=root switchover", I'm getting the following error: 但是,当我运行“ mysqlrpladmin --master = root @ S_NODE --new-master = root @ M_NODE --demote-master --discover-slaves-login = root切换”时,出现以下错误:

# Discovering slaves for master at S_NODE
# Discovering slave at M_NODE
# Found slave: M_NODE
# Checking privileges.
# Performing switchover from master at S_NODE to slave at M_NODE
# Checking candidate slave prerequisites.
Candidate slave is missing replication user.
ERROR: Candidate slave is missing replication user.
# Errors found. Switchover aborted.
#
# Replication Topology Health:
+-----------------+-------+---------+--------+------------+---------+
| host            | port  | role    | state  | gtid_mode  | health  |
+-----------------+-------+---------+--------+------------+---------+ 
| S_NODE          | 3306  | MASTER  | UP     | ON         | OK      |
| M_NODE          | 3306  | SLAVE   | UP     | ON         | OK      |
+-----------------+-------+---------+--------+------------+---------+

I can't seem to find any google or stackoverflow pages related to that error message "Candidate slave is missing replication user." 我似乎找不到与该错误消息“候选从站丢失复制用户”相关的任何Google或stackoverflow页面。

I believe I have a replication user on both node S and M, since both acted as a slave at one point in my test script. 我相信我在节点S和M上都有一个复制用户,因为在我的测试脚本中的某个时刻,它们都充当了从服务器。

Any thoughts? 有什么想法吗?

I ran into this same problem while testing failover on some new clusters and noticed that after adding the --force flag as you suggest, the switchover completed successfully and created the user 'replication_user'@'S_NODE' without any prompting on my part. 在一些新群集上测试故障转移时,我遇到了同样的问题,并注意到在按照您的建议添加--force标志后,转换成功完成创建了用户'replication_user'@'S_NODE',而我没有任何提示。

It then occurred to me that the replication user I had set up was 'repl'@'specific_subnet_%' - which did not match what the script was looking for ('repl'@'S_NODE'), so the pre-check failed without --force . 然后我想到我设置的复制用户是'repl'@'specific_subnet_%'-与脚本查找的内容不匹配('repl'@'S_NODE'),因此预检查失败了,但没有--force

I had another cluster I was testing, so to validate I did the following: 我有另一个正在测试的集群,因此为了验证我做了以下事情:

  • ran the mysqlrpladmin ... switchover command without --force (it failed as expected) 在没有--force情况下运行mysqlrpladmin ... switchover命令(按预期失败)
  • created both 'replication_user'@'S_NODE' and 'replication_user'@'M_NODE' with the same grant ( REPLICATION SLAVE ) and password as my existing replication_user. 创建了'replication_user'@'S_NODE''replication_user'@'M_NODE' ,并使用与我现有的Replication_user相同的授权( REPLICATION SLAVE )和密码。 You need both S_NODE and M_NODE hosts if you want to be able to fail back and forth between them using this script. 如果要使用此脚本在它们之间来回切换,则需要S_NODE和M_NODE主机。
  • tried mysqlrpladmin ... switchover again without --force 尝试过mysqlrpladmin ... switchover没有--force再次mysqlrpladmin ... switchover

It worked like a charm this time! 这次就像魅力一样!

Moral of the story: the script expects the 'replication_user'@'new_master' user to exist. 故事的寓意:脚本期望'replication_user'@'new_master'用户存在。 The --force flag will create that user for you, and should not be necessary after the first time you use it. --force标志将为您创建该用户,并且在您第一次使用它后就不需要了。

For some reason, adding "--force" flag fixed the issue. 由于某些原因,添加“ --force”标志可解决此问题。 More details in the comments above. 在上面的评论中有更多详细信息。 If anyone knows why this might be though, please comment. 如果有人知道为什么会这样,请发表评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM