Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a master -> slave configuration where the master failed. I've been able to reset the old-slave to be a master and the old-master to slave from it. Fine.

What I can't seem to do is to remove the master information on the old-slave which is now the new-master. I see:

mysql> show slave status \G
*************************** 1. row ***************************
           Slave_IO_State: 
              Master_Host: 10.1.2.101
              Master_User: replicationSlave
              Master_Port: 3306
              ...
              Slave_IO_Running: No
              Slave_SQL_Running: No

I've read a lot of MySQL documentation but I still haven't found a way to clear the slave information from the new-master. I've tried:

  1. RESET SLAVE which does not seem to clear those settings. [[Actually it does remove the master.info file but not the memory settings. See below.]]
  2. CHANGE MASTER TO MASTER_HOST='' which just spits on an error since it was deprecated recently.
  3. Checking my.cnf which does not have the master information since they were added programmatically.
  4. RESET MASTER because some mysql docs recommended it. That only resets the bin logs.
  5. Poking around in the internal MySQL tables to see if I can find the fields to clear.

What is the proper way to do this on MySQL ~5.5.9? Thanks for any help.


Edit:

So it turns out that RESET SLAVE removes the master.info file as @RolandoMySQLDBA implied. However, you still need to restart the server before the slave information is removed.

Is there any way to remove this slave information without having to restart mysqld?

share|improve this question
    
Related to dba.stackexchange.com/questions/12092/… –  Gray Jul 18 '12 at 16:45
add comment

3 Answers

up vote 3 down vote accepted

The quickest and dirtiest way to clear slave info from a MySQL instance

  • Add skip-slave-start to /etc/my.cnf under [mysqld]
  • service mysql stop
  • rm -f /var/lib/mysql/master.info /var/lib/mysql/relay-*
  • service mysql start
  • Remove skip-slave-start from /etc/my.cnf

That should do it for you !!!

This would be necessary because according to MySQL Documentation on RESET SLAVE:

In MySQL 5.5 (unlike the case in MySQL 5.1 and earlier), 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.

Thus, replication info is still in memory. A mysql restart is the only way to go.

share|improve this answer
    
Thanks @Rolando. +1 I saw that but didn't try it. I'm trying to not have to restart mysqld to fix this. –  Gray Jul 18 '12 at 16:56
    
Also, I don't see any master.info file. Is that always there on a "master" or "slave"? –  Gray Jul 18 '12 at 16:57
    
master.info is always on Slave Server. –  Abdul Manaf Jul 19 '12 at 6:51
add comment

RESET SLAVE followed by a restart does not clear the slave info as far as phpmyadmin is concerned. You also need to set CHANGE MASTER TO MASTER_HOST=''.

share|improve this answer
add comment

I would recommend maintaining the skip-slave-start command in your config file (‘in /etc/my.cnf’) under your ‘mysqld’ to avoid any overriding of master-slave data. To give you an example- when working in a cloud environment, let’s say an old master crashes and then successfully restarts when you’re your provider fixes whatever issue – the old slave (now new master) will replicate from old master, overriding data before the DBA has a chance to realize this.

BTW, this is also relevant in non-cloud environment. If, let’s say, another admin brings up the old master without coordinating. Also, another issue why it's a good idea to maintain the ‘skip-slave-start’ command even if it's a slave – no automatic replication, meaning you have more control over preventing unpredictable results. :)

share|improve this answer
    
Thanks for the answer @Lena. That's a good idea. I'll look into it. –  Gray Sep 12 '12 at 12:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.