How To Setup Mysql Replication On Redhat and Centos

 

How to Setup Mysql Master Slave Replication on Centos and Redhat

 

Here we will see how to setup Mysql Database Replication. Mysql replication is very useful in terms of

fail over solution

 

Advantages:

  1. Hot Stand by Node for Fail Over
  2. Can be used for transparent backup
  3. Load balancing

 

Installing Mysql server:

# yum -y install mysql*

Make this server master and configure it.

# vi /etc/my.cnf

Now you have to add following configuration entries in under [mysqld] section and replace database name scripts with your database name.

set_up_mysql_replication_html_m57a5a029

 

Now restart Mysql Service:

# /etc/init.d/mysqld restart

 

Login into mysql server as root and create slave user’s and grant privileges to use for replication

Before doing this replace slave_user and with your user name and password.

set_up_mysql_replication_html_4c1606aa

Here one important thing need to do write down file (mysql-bin.000009) and position numbers, Later on this number will be use in Slave Server configuration.

Configure Slave server:

Install Mysql server on slave server

# yum install mysql-server mysql

 

#vi /etc/my.cnf

set_up_mysql_replication_html_m1c0e655c

 

Restart mysql service:

#/etc/init.d/mysqld restart

 

First step to login into mysql server as root user, here we need value’s that we got on master server.

set_up_mysql_replication_html_3f221397

Next go with below queries for post configuration.

mysql> SLAVE STOP;
mysql> CHANGE MASTER TO MASTER_HOST='172.16.60.21', MASTER_USER='slave_user', MASTER_PASSWORD='sun123', MASTER_LOG_FILE='mysql-bin.000009', MASTER_LOG_POS=197;
mysql> SLVAE START;

set_up_mysql_replication_html_a6fbc62

Once everything done without any error, you can check slave status with below query,

mysql> show slave status\G

set_up_mysql_replication_html_2f2285fe

Test Mysql Replication on Master and Slave Server:

Create database on Master Mysql Server:

set_up_mysql_replication_html_661934e0

Verify the same on Slave server by running below command.

set_up_mysql_replication_html_5791a2a9

That’s it here is simple steps for setup mysql replication…

 

Leave a comment

Your email address will not be published.


*