这篇文章上次修改于 3382 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
先上主库Master库:
mysql>show processlist; 查看下进程是否Sleep太多。发现很正常。
show master status; 也正常。
再上从库Slave上查看
mysql > show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: No
方法一:手动同步
1、停止slave
mysql> slave stop;
2、到master上查看主库的状态
记录File和Position对应的值
mysql> show master status;
+------------------+-----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000020 | 135617781 | | |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)
3、到slave上执行手动同步
mysql> change master to
master_host='master_ip',
master_user='user',
master_password='pwd',
master_port=3307,
master_log_file='mysql-bin.000020',
master_log_pos=135617781;
1 row in set (0.00 sec)
mysql> slave start;
1 row in set (0.00 sec)
4、再次查看slave状态
mysql > show slave status\G
方式二:重新做主从,完全同步
1、先进入主库,进行锁表,防止数据写入
mysql > flush tables with read lock;
2、进行数据备份
mysqldump -uroot -p -hlocalhost>mysql.bak.sql
3、查看master状态
mysql > show master status;
4、停止从库slave状态
mysql > stop slave;
5、把sql文件导入从库slave
mysql > source /tmp/mysql.bak.sql
6、置从库同步,注意该处的同步点,就是主库show master status信息里的| File| Position两项
change master to master_host = '192.168.1.***', master_user = 'backup', master_port=3306, master_password='', master_log_file = 'mysqld-bin.000001', master_log_pos=3260;
7、重新开启从同步
mysql > start slave;
8、查看同步状态
mysql > show slave status\G;
只有一条评论 (QwQ)