MySQL db replication
This is a step by step guide to setup database replication for MySQL. In this replication setup, there are primarily two (or more) database servers – master and slave. The two databases are exact copies i.e. they have exactly same data. Any operation done on the master is immediately executed on the slave as well and hence the two are synced.
Steps 1 : We need to configure the master and prepare it for replication
Edit my.cnf file and enable networking for master. Also, allow MySQL to communicate with other machines. Depending on your flavour of linux, you can locate my.cnf file in /etc/my.cnf or /etc/mysql/my.cnf. Comment out the following two lines.
#skip-networking
#bind-address = 127.0.0.1Next, we restart mysql to bring the aforementioned changes into effect.
Step 2 : Log into the MySQL database as root and create a user with replication privileges.
GRANT REPLICATION SLAVE ON *.* TO ‘repl’@'%’ IDENTIFIED BY ‘<my_password>’;
FLUSH PRIVILEGES;
Step 3 : Now, we need to lock down the MySQL
USE mydatabase;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
You will get the following information back
mysql> SHOW MASTER STATUS;
+———————-+————–+——————-+———————–+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+———————-+————–+——————-+———————–+
| mysql-bin.000004 | 466435744 | | |
+———————-+————–+——————-+———————–+
1 row in set (0.00 sec)
Save this information as it is going to be used while configuring the slave.
Take a dump of the master.
mysql -u root -p<my_password> –opt mydatabase > mydatabase.sql
Once, the aforementioned information has been noted down, we can unlock MySQL.
UNLOCK TABLES;
Step 4 : Coming on to the slave, first we need to create the database.
CREATE DATABASE mydatabase;
Now, copy the sql dump from master server to the slave server. You can use scp to transfer the sql dump file
scp mydatabase.sql slave_user@slave_machine:/tmp/mydatabase.sql
mysql -u root -p<my_password> mydatabase < /tmp/mydatabase.sql
Step 5 : Now we need to configure the slave
Open my.cnf file and append the following lines
server-id=2
master-host=master_server_ip
master-user=repl
master-password=mypassword
master-connect-retry=60
replicate-do-db=mydatabase
Now, restart mysql
sudo /etc/init.d/mysql restart
Step 6 : Next, log into mysql and execute the following commands
SLAVE STOP;
CHANGE MASTER TO MASTER_HOST=’master_host_address’, MASTER_USER=’repl’, MASTER_PASSWORD=’<my_password>’, MASTER_LOG_FILE=’mysql-bin.004′, MASTER_LOG_POS=466435744;
Finally, we need to stare the slave
SLAVE START;
Now the replication should be in effect. You can test if the replication has been successfully implemented by adding a row in any of the tables in the master, and the same will be added to the slave as well.
Broadband is a term normally considered to be synonymous with a high-speed connection to the internet. The term itself is technology neutral; broadband can be delivered by a range of technologies including DSL, LTE or next generation access. Broadband is often contrasted with dial-up access which uses 56 kbps modem.





Use the username and password provided to you by your provider and click on Next.
Finally on the last page, click on Apply to set everything up.
Wait for a minute and you’re all set with the modem.
