NOTE: I am using ubuntu as my OS with mysql 5.5.
On master server:
[1] sudo vi /etc/mysql/my.cnf
# under [mysqld] add the following line, considering you have the default lines:
log-bin = master-bin
log-bin-index = master-bin.index
server_id = 1
[2] # Update your bind-address so that any one can access the db. You can also update your firewall accordingly:
bind-address = 0.0.0.0 # NOTE: you can comment the bind-address line too.
[3] mysql> create user replicaiton_user
grand replication slave on *.*
to replication_user identified by 'your_password';
[4]: Restart the mysql: " sudo service mysql restart "
[ You can have a look at /var/log/mysql/error/log mean while if you face any issue. ]
Configuring SLAVE:
[1]: sudo vi /etc/mysql/my.cnf
# under [mysqld] add the following line, considering you have the default lines:
relay_log = slave-relay-bin
relay_log_index = slave-relay-bin.index
server-id = 2
[2] Can comment the bind-address = 127.0.0.1 [ so that your application can access the slave system as a read only access. ]
[3] sudo service mysql restart
[4] mysql> change master to
master_host = 'your_master_host',
master_port = 'port_number_where_master_db_is_running',
master_user = 'replication_user',
master_password = 'your_replication_user's_password'
[5] > start slave;
[6] > show slave status;
[7]: Any further issue, check: /var/log/mysql/error.log
No comments:
Post a Comment