mysql master reset_mysql reset slave / reset master

RESET SLAVE

官方的解释如下

1)RESET SLAVE makes the slave forget its replication position in the

master's binary log. This statement is meant to be used for a clean

start: It clears the master info and relay log info repositories,

deletes all the relay log files, and starts a new relay log file. It

also resets to 0 the replication delay specified with the MASTER_DELAY

option to CHANGE MASTER TO. To use RESET SLAVE, the slave replication

threads must be stopped (use STOP SLAVE if necessary).

2)RESET SLAVE does not change any replication connection parameters

such as master host, master port, master user, or master password, which

are retained in memory. This means that START SLAVE can be issued

without requiring a CHANGE MASTER TO statement following

reset slave

其实,它是直接删除master.info和relay-log.info文件,并删除所有的relay log,然后重新生成一个新的relay log,即使relay log中还有SQL没有被SQL线程apply完。

但是RESET SLAVE有个问题,它虽然删除了上述文件,但内存中的change master信息并没有删除,此时,可直接执行start

slave,但因为删除了master.info和relay-log.info,它会从头开始接受主的binlog并应用。(注意:这里所说的从头是说:reset的时候,正在接受的主的binlog,从新接受这个binlog).如果SQL

thread 正在复制临时表的过程中,执行了stop slave ,并且执行了reset slave,这些被复制的临时表将被删除。

reset master 做了什么?

1. reset master 将删除日志索引文件中记录的所有binlog文件,创建一个新的日志文件 起始值从000001 开始,

2. reset master 不能用于有任何slave 正在运行的主从关系的主库。因为在slave 运行时刻 reset master

命令不被支持,reset master 将master 的binlog从000001 开始记录,slave 记录的master log

则是reset master 时主库的最新的binlog,从库会报错无法找的指定的binlog文件。

你可能感兴趣的:(mysql,master,reset)