错误:
The server is not configured as slave; fix in config file or with CHANGE MASTER TO
这表示server-id 错误;将server-id 正确写在[mysqld]下的位置;
Failed to open the> 没有找到relay-bin.000001日至;因为修改前没有清除原有的配置;
解决方案:reset slave;后在change master to ....;
一:主主服务器同步;
主主服务器mysql同时两台服务器同时监听对方服务器mysql变化;当有一台服务器中数据有变化,另一台实时同步;
主从服务器同时建立二进制文件;每产生语句变化或磁盘变化写入日至;
主从服务器同时读另一台服务二进制日至;将读到的日至转成本身服务的relaylog,然后读区本服务器的relaylog同步数据;
两台服务器建立授权复制账号;
两台服务器利用账号来监听另一台服务器;
1、两台服务器my.cnf中配置
//服务器1 server-id=163
log-bin=mysql-bin
binlog-format=mixed
relay-log=mysql-relay
//服务器2
server-id=244
log-bin=mysql-bin
binlog-format=mixed
relay-log=mysql-relay
2、两台服务器都建立授权监听账号
grant replication client,replication slave on *.* to 'repl163'@'118.xxx.xxx.1'>
grant replication client,replication slave on *.* to 'repl163'@'118.xxx.xxx.2'>
3、两台服务器都监听对方log日至
change master to master_host='118.xxx.xxx.1',master_user='repl163',master_password='password',master_log_file='mysql-bin.000001',master_log_pos=746;
change master to master_host='118.xxx.xxx.2',master_user='repl163',master_password='password',master_log_file='mysql-bin.000001',master_log_pos=746;
4、通过show slave status \G查看监听状态
错误:Last_IO_Error: error connecting to master 'repl163@118.xxx.xxx.1:3306' - retry-time: 60 retries: 2
表示连接出错,检查得知为ip写错了;
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first
表示在没有解锁的情况下停止slave进程:需要clear slave;
然后再执行change master to...
5、show slave status \G没有问题后启动;