# Replication setup

**URL:** <https://forums.percona.com/t/replication-setup/4364>\
**Category:** Other MySQL® Questions\
**Created:** [August 21, 2015, 1:46am UTC](https://forums.percona.com/t/replication-setup/4364 "2015-08-21T01:46:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikonrao](https://avatars.discourse-cdn.com/v4/letter/i/a9adbd/32.png) [@ikonrao](https://forums.percona.com/u/ikonrao)\
**Post date:** [August 21, 2015, 1:46am UTC](https://forums.percona.com/t/replication-setup/4364/1 "2015-08-21T01:46:52Z")

</div>

I have Master slave replication setup on Windows server MySQL 5.6.22 without GTID. With below parameters in my.ini

masterA\> my.ini

log\_bin=mysql-bin.log  
log\_bin\_index=mysql-bin.index  
binlog\_format=ROW  
max\_binlog\_size=1073741824  
sync\_binlog=1  
server-id=1

master status: mysql-bin-0002.log POS: 19548

slaveB\> my.ini

log\_bin=mysql-bin.log  
log\_bin\_index=mysql-bin.index  
binlog\_format=ROW  
max\_binlog\_size=1073741824  
log\_slave\_updates=ON  
sync\_binlog=1  
relay\_log=mysql-relay-bin.log  
relay\_log\_index= mysql-relay-bin.index  
max\_relay\_log\_size=1073741824  
read\_only=1  
server-id=2  
skip-slave-start

ON slave: mysql-bin-0002.log POS: 19548 \* As I have log-bin and log-slave-updates enabled

I need to promote slave as master and master as slave. But I want the new slave to continue from mysql-bin-0002.log POS: 19548. What I need to know is whether below steps are correct. Is it necessary to issue reset slave command on slave

1. Stop tomcat so that there are no connections to mysql.
2. Verfiy whether master and slave are in sync. if yes then proceed further.
3. On SLAVE\> stop slave; Change master to master\_host=‘’; ###I will keep it blank.
4. On SLAVE\> comment read\_only parameter
5. On MASTER\> Stop Mysql service. Add below parameters in my.ini  
relay\_log=mysql-relay-bin.log  
relay\_log\_index= mysql-relay-bin.index  
max\_relay\_log\_size=1073741824  
read\_only=1  
log\_slave\_updates=ON  
skip-slave-start
6. On MASTER\> start mysql service. Issue change master to command.  
CHANGE MASTER TO MASTER\_HOST=‘slaveB IP’,MASTER\_USER=‘repluser’,MASTER\_PASSWORD=‘replpwd’,MASTER\_PORT=3307,MASTER\_LOG\_FILE=‘mysql-bin.000002’,MASTER\_LOG\_POS=19548,MASTER\_CONNECT\_RETRY=10;
7. Start slave.

---

<div class="post-metadata">

**Author:** ![jrivera](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jrivera/32/13_2.png) [@jrivera](https://forums.percona.com/u/jrivera)\
**Post date:** [August 21, 2015, 7:16am UTC](https://forums.percona.com/t/replication-setup/4364/2 "2015-08-21T07:16:49Z")

</div>

I’ve started playing around with MHA and I should say it works great for manual or even automated failover of master-slave replication servers. 🙂

Steps 1 and 2 are solid.  
Step 3. you’d want to do, `STOP SLAVE; RESET SLAVE ALL;` as it is 5.6  
Step 4. set global read\_only=0;  
Step 5. these are optional and read\_only can be changed online.  
Step 6. SHOW MASTER STATUS; on old slave/new master  
Step 7. CHANGE MASTER TO … (use log file and position from #6)  
Step 8. set global read\_only=1; on new slave/old master  
Step 8. start slave; show slave status\G on new slave/old master.

Again with MHA ([url][https://code.google.com/p/mysql-master-ha/wiki/Overview[/url]](https://code.google.com/p/mysql-master-ha/wiki/Overview%5B/url%5D)), it would be as easy as :

shell\> masterha\_master\_switch --master\_state=alive --conf=/etc/app1.cnf --new\_master\_host=old\_slave --orig\_master\_is\_new\_slave
