Based on our chat conversation, here is what was discussed
- Server1 is Stand Alone
- Server2 is a Master
- Server3 is a Slave to Server2
This implies that binary logging is enabled in Server2.
To Make Server1 a Master of Server2, perform the following:
STEP 01 : On Server2, add this to /etc/my.cnf
[mysqld]
log-slave-updates
STEP 02 : On Server3, run STOP SLAVE;
STEP 03 : On Server2, run service mysql restart
STEP 04 : On Server3, run START SLAVE;
STEP 06 : On Server1, add this to /etc/my.cnf
[mysqld]
log-bin=mysql-bin
STEP 07 : On Server1, run service mysql restart
STEP 08 : Set Replication From Server1 to Server2
See Clarification about master slave configuration in mysql
OPTIONAL
Once you have MySQL Replication Going From Server1 to Server2 to Server3, your can properly load all data into all three MySQL Instances by doing the following on Server1:
mysqldump -u... -p... --all-databases --routines --triggers > mysqldata.sql
mysql -u... -p... < mysqldata.sql
This will do three(3) things
- Repopulate everything into Server1
- MySQL Replication will handle populating Server2 from Server1
- MySQL Replication will handle populating Server3 from Server2
Since your data is 50MB in total, this should be execute very quickly.
Going by your question, I will like to review what I believe you did thus far:
- You stopped mysql on the Master
- You copied Master's /var/lib/mysql to the Slave's /var/lib/mysql
- I surmise the binlogs on the Master were copied as well
Look at the Slave's last binlog. From the question, it should be
mydbm1-bin.008524
- Filesize 1330529
Believe it or not, you have to do a few things:
1) On the Master, create a replication user like this:
GRANT REPLICATION SLAVE,REPLICATION CLIENT
ON *.* TO replicator@'%'
IDENTIFIED BY 'r3plic4t0R';
2) Make /var/lib/mysql on the Slave owned by mysql
user
chown -R mysql:mysql /var/lib/mysql
3) Make sure Master's server_id is explicitly set in my.cnf
[mysqld]
server_id = 1
4) Make sure Slave's server_id is explicitly set in my.cnf
[mysqld]
server_id = 2
5) Startup mysql on the Slave
service mysql start
6) Setup replication by running this on the Slave
CHANGE MASTER TO
MASTER_HOST='IPAddressOfMaster',
MASTER_PORT=3306,
MASTER_USER='replicator',
MASTER_PASSWORD='r3plic4t0R',
MASTER_LOG_FILE='mydbm1-bin.008524',
MASTER_LOG_POS=1330529;
START SLAVE;
SELECT SLEEP(5);
SHOW SLAVE STATUS\G
You will see something like this:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.48.20.253
Master_User: replicant
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000254
Read_Master_Log_Pos: 858190247
Relay_Log_File: relay-bin.066069
Relay_Log_Pos: 873918
Relay_Master_Log_File: mysql-bin.000254
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 858190247
Relay_Log_Space: 873772
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
1 row in set (0.00 sec)
If Slave_IO_Running
and Slave_SQL_Running
are both Yes
, CONGRATULATIONS !!!
I already answered a post back on Feb 06, 2012 ( How to setup replication(Master/slave) in MySQL 5.5.20? ) with essentially the same steps.
I wanted to add additional posts I made for setting up Circular Replication should you decide to setup the two DB servers as Master/Master
Best Answer
In Windows, you would need to modify the my.ini file and not the my.cnf file
Locate you my.ini file
If MySQL is being run as a service
Enter "services.msc" on the Start menu search box.
Find MySQL service under Name column, for example, MySQL56.
Right click on MySQL service, and select Properties menu.
Look for "Path To Executable" under General tab, and there is your .ini file, for instance, "C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MYSQL56
Otherwise the my.ini file is probably in a sub-directory of D:\xampp\mysql\
Once you've added in the binlog_do_db parameter, be sure to restart the MySQL service.
Edit by RolandoMySQLDBA
You can restart mysql from
services.msc
window by right clicking and choosing or you can login from DOS CommandLine as Administrator as runAlso, make sure your settings are under the
[mysqld]
group header inmy.ini