Reputation: 213
I want to add Server3 to MySQL Master & Replicate it as slave, When I run [start slave;] I am getting below error
"ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO"
I have checked all the configuration of my current slave (Server2) but unable to find any solution or fix.
Altered with solution
Step1: GRANT REPLICATION SLAVE ON . TO 'slave_user'@'master_ip' IDENTIFIED BY 'slave_pass'; FLUSH PRIVILEGES;
Step2: FLUSH TABLES WITH READ LOCK; mysqldump --all-databases --single-transaction > all_databases.sql
Step4: CHANGE MASTER TO MASTER_HOST='master_ip', MASTER_USER='slave_user', MASTER_PASSWORD='slave_pass', MASTER_LOG_FILE='mysql-bin.000071', MASTER_LOG_POS=754916280;
I got MASTER_LOG_FILE & MASTER_LOG_POS from "show master status\G" command which I ran on master server
@Zafar Malik: please correct if the step are correct.
Upvotes: 3
Views: 17763
Reputation: 6844
You can follow below steps-
Create a user on master which can connect from slave2 with replication rights.
take dump backup from master server with master-data=2 option, to get binary co-ordiante.
Note: Assuming binary logs are enabled on master server.
restore this backup on slave2.
Now execute change master to command as per below-
CHANGE MASTER TO MASTER_HOST='master_server_ip', MASTER_USER='replication_user', MASTER_PASSWORD='replication_pass', MASTER_LOG_FILE='mysql-bin.001', MASTER_LOG_POS=123;
Note: Where MASTER_LOG_FILE,MASTER_LOG_POS you can get from your backup file.
Update: :
Check steps as you asked below-
Step1:
GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'slave_ip' IDENTIFIED BY 'slave_pass';
Note: As slave will connect to master, so above command will execute on master which provide permission to slave ip. Grant command auto flush permissions so no need of flush privileges after it, you can if you want.
Step2: FLUSH TABLES WITH READ LOCK; mysqldump --all-databases --single-transaction > all_databases.sql
Step4:
CHANGE MASTER TO MASTER_HOST='master_ip', MASTER_USER='slave_user', MASTER_PASSWORD='slave_pass', MASTER_LOG_FILE='mysql-bin.000071', MASTER_LOG_POS=754916280;
I got MASTER_LOG_FILE & MASTER_LOG_POS from "show master status\G" command which I ran on master server
Note: Assuming you got above co-ordinates after applying read lock and before releasing it.
Upvotes: 2