MySQL Forums
Forum List  »  Replication

Replication not working
Posted by: Adithya Khamithkar
Date: April 01, 2014 04:40AM

Hi,

I am following these steps for a master slave replication but it does not seem to work. When I check the slave and run this SHOW SLAVE STATUS\G I get the out put that its connected to the master. When when I check the same on the master it shows empty..

1.3 Perform the following task on mysql 1 & 2:
1.3.1 Install MySql-server
> sudo apt-get install mysql-server mysql-client
1.3.2 General MySql configuration
Open the my.cnf
> sudo vim /etc/mysql/my.cnf
Look for the line bind-address.. and comment it to allow all network to connect to it
#bind-address = 127.0.0.1
1.3.3 MySql Master configuration
Open the my.cnf
> sudo vim /etc/mysql/my.cnf
Uncomment the following line
server-id = 1
log_bin = /var/lib/mysql/log-bin.log
binlog_do_db = “database name”
Restart MySql
> sudo /etc/init.d/mysql restart
1.3.4 Grant privileges to slave for replication(to be done on master)
> mysql -u root -p
> GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
> FLUSH PRIVILEGES;
Switch to the database you want to replicate
> USE “database name”;
> FLUSH TABLES WITH READ LOCK;
> SHOW MASTER STATUS;
Out put
+----------------+----------+------------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------+----------+------------------+------------------+
| log-bin.000001 | 107 | “database name” | |
+----------------+----------+------------------+------------------+
1 row in set (0.00 sec)
Unlock the tables:
> UNLOCK TABLES;
> Exit
1.3.5 MySql Slave configuration
Open the my.cnf
> sudo vim /etc/mysql/my.cnf
Look for the following line and uncomment it:
server-id = 1
And replace it with:
server-id = 2
relay-log = /var/lib/mysql/relay-log-bin.log
log_bin = /var/lib/mysql/log-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_do_db = “database name”
Restart MySql
> sudo /etc/init.d/mysql restart
Log into MySql shell:
> mysql -u root -p
Execute the following lines to set the master
> CHANGE MASTER TO MASTER_HOST='IP',MASTER_USER='user-name', MASTER_PASSWORD='password', MASTER_LOG_FILE='log-bin.000002', MASTER_LOG_POS= 107;
Start the slave:
> START SLAVE;
Check status of the slave:
> SHOW SLAVE STATUS\G
If there is an issue in connecting, you can try starting slave with a command to skip over it:
> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; SLAVE START;

Options: ReplyQuote


Subject
Views
Written By
Posted
Replication not working
2022
April 01, 2014 04:40AM
686
April 06, 2014 12:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.