所以我在两个不同的MySQL服务器上设置了我的初始主从复制对。 这部分工作很好。 所以我所要做的就是把第一个主人当成奴隶,把第一个奴隶当成第二个主人,对吗?
错误!
当我尝试在辅助主服务器上创build第二个从属帐户时,会发生这种情况:
mysql> grant replication slave on *.* to 'repslave2'@'ourhost' identified by 'password'; Query OK, 0 rows affected (0.00 sec) mysql> start master; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'master' at line 1
什么? 你是什么意思,“语法错误”? 这是非常简单的东西。 我拼写“大师”的权利。 它在另一台服务器上工作,无需安装任何特殊的东西。 “停止奴隶”和“开始奴隶”工作在这台服务器上宣传。 为什么不行?
编辑添加:
我想我已经发现问题的一部分 – 主从复制混淆在两个服务器之间。 在这里,我试图阻止主要的主人:
mysql> stop master; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'master' at line 1 mysql> stop slave; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> stop master; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'master' at line 1 mysql> start master; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'master' at line 1 mysql> start slave; ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO
您必须首先在新主设备上定义主设备,然后在发送启动主设备之前停止要设为主设备的服务器上的从设备; 命令。
可能不是你想要的答案,但它是正确的。
更好的理解你想要做什么会是有帮助的。
尝试start slave 。
每个主服务器应该是另一个主server-id ,不要忘记在my.cnfconfiguration的每个服务器中都有不同的server-id 。
还要正确设置auto_increment_increment和auto_increment_offset以避免重复的主键中断复制。
如果在正确configuration每个服务器之后Slave_IO_Running和Slave_SQL_Running都为yes请检查show slave status 。
configuration完成后input这个命令START SLAVE IO_THREAD