{"id":561,"date":"2022-05-26T06:31:51","date_gmt":"2022-05-26T06:31:51","guid":{"rendered":"https:\/\/www.checkmateq.com\/blog\/?p=561"},"modified":"2023-08-03T07:30:47","modified_gmt":"2023-08-03T07:30:47","slug":"master-master-replication-of-mysql","status":"publish","type":"post","link":"https:\/\/www.checkmateq.com\/blog\/master-master-replication-of-mysql","title":{"rendered":"How to Configure Master Master Replication of MySQL"},"content":{"rendered":"<p><strong>What is MySQL?<\/strong><\/p>\n<p><a href=\"https:\/\/www.checkmateq.com\/python-development\">MySQL<\/a> is one of the most used relational database management system(dbms)\u00a0 based on SQL, developed and distributed by Oracle corporation. it&#8217;s a relational database stores data in tables in which data in tables may be related to each other these relations between tables helps to structure the data and preform operations like Create , Read, Update and Delete famously known as CRUD operations.<\/p>\n<p><strong>What is database replication?<\/strong><\/p>\n<p>database replication is way of copying or storing data\u00a0 at more than\u00a0 one server\/node, it helps to increase\u00a0 availability of data, replication is a simple process of copying data from one server to other so that all the users are enabled to access same data at a particular point of time without any inconsistency, by default all the MySQL replications are asynchronous which means data is written to primary storage first and then copied on to the secondary in contrast data is written to both the servers simultaneously in synchronous replication.<\/p>\n<p><strong>Master Master replication:<\/strong><\/p>\n<p>To understand what is master master you have to know what is master node and what is a slave node,\u00a0 \u00a0 \u00a0a users can both read and write data to a master node where as all the data written to master is copied to slave node which acts as read only server to users, in master master replication there will be more than one master node\/server ,here\u00a0 a two way communication is established between all the master nodes where data written to any of the master node is copied to\u00a0 all other master nodes and slave nodes, each master node can have slave nodes separately, this increases the availability\u00a0 of\u00a0 database for users to\u00a0 both read and write data .<\/p>\n<p><strong>Steps to setup Master Master replication<\/strong><\/p>\n<p>I am using two aws\u00a0 ec2 instances with RHEL platform and assume these are Private IPv4 addresses\u00a0 of the instances.<\/p>\n<pre>Instance-1:\u00a0 172.31.43.199\r\nInstance-2: 172.31.33.123\r\n<\/pre>\n<p>Note: if you are also using instances hosted on any cloud provider please allow traffic on port number 3306 (mysql mostly uses this port number)<\/p>\n<h4><strong>Step-1:\u00a0 Install MySQL on both the machines<\/strong><\/h4>\n<p>follow all the below process for both the machines, let&#8217;s start with installing mysql-server on both the machines<\/p>\n<p>execute this command on both your terminals to install mysql-server.<\/p>\n<pre>sudo yum install mysql-server -y<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-566 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-171-300x129.png\" alt=\"\" width=\"839\" height=\"361\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-171-300x129.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-171-1024x440.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-171-768x330.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-171-1536x660.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-171-1200x516.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-171.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>after the installation start the database server<\/p>\n<pre>systemctl start mysqld<\/pre>\n<p>enable the service, enabling\u00a0 makes it to automatically start on boot.<\/p>\n<pre>systemctl enable mysqld<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-568 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-1-300x25.jpeg\" alt=\"\" width=\"732\" height=\"61\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-1-300x25.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-1-1024x86.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-1-768x64.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-1-1536x129.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-1-1200x100.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-1.jpeg 1900w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>execute the given command to check the the status of MySQL server and confirm that it&#8217;s <strong>running<\/strong><\/p>\n<pre>systemctl status mysqld<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-569 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-3-300x121.jpeg\" alt=\"\" width=\"736\" height=\"297\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-3-300x121.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-3-1024x412.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-3-768x309.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-3-1536x618.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-3-1200x483.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-3.jpeg 1895w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>In step-2 we will configure server-1(machine-1) as master and server-2 (machine-2) as a slave for it.<\/p>\n<h4><strong>Step-2: <\/strong><strong>Configuring sever-1 as master node and server-2 as slave node.<\/strong><\/h4>\n<p>edit the mysql-server.cnf file on your machine-1<\/p>\n<pre>sudo vi \/etc\/my.cnf.d\/mysql-server.cnf<\/pre>\n<p>add these under [mysqld] in your configuration file , save it and close.<\/p>\n<pre>bind-address = 172.31.43.199(use your machine-1 private ip here)\r\nserver-id = 1\r\nlog_bin = mysql-bin\r\n<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-574 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-300x48.jpeg\" alt=\"\" width=\"1295\" height=\"207\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-300x48.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-1024x165.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-768x123.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-1536x247.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-1200x193.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6.jpeg 1698w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p><strong>bind_address<\/strong>: tells MySQL on which network it can listen for connections, if you give 0.0.0.0 that means you are allowing access from any ip.<\/p>\n<p><strong>server-id<\/strong>:\u00a0 server id&#8217;s should be unique for every node\/server.<\/p>\n<p><strong>log_bin<\/strong>: binary log is a sequence of files with a base name and numeric extension, server logs all statements that change data to the binary log, which is used for backup and replication.<\/p>\n<p>Now restart your mysql-server using below command.<\/p>\n<pre>sudo systemctl restart mysqld<\/pre>\n<p>Now use below command and login to your mysql-shell<\/p>\n<pre>sudo mysql -u root -p<\/pre>\n<p>execute the below given commands in you MySQL shell , these commands will create a user and will grant the permission &#8220;REPLICATION SLAVE&#8221; to the created user on all the tables in all the databases.<\/p>\n<pre>mysql&gt; CREATE USER 'aks'@'172.31.33.123' IDENTIFIED BY '@Aksshaay1'; \r\nmysql&gt; GRANT REPLICATION SLAVE ON *.*TO 'aks'@'172.31.33.123';<\/pre>\n<p>Here &#8220;aks&#8221; is a user name , &#8220;172.31.33.123&#8221; is private-ip of my server-2 and &#8220;@Aksshaay1&#8221; is password for the user, &#8220;REPLICATION SLAVE&#8221; is a permission type given to user &#8220;aks&#8221; on all the databases and all tables(*.*)<\/p>\n<p>then run below command\u00a0 to load the changes and exit.<\/p>\n<pre>mysql&gt; FLUSH PRIVILEGES;<\/pre>\n<p>FLUSH PRIVILEGES will reload grant tables in mysql database , which makes changes to take effect immediately without\u00a0 restarting or reloading MySQL.<\/p>\n<pre>mysql&gt; EXIT;<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-591 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-1-300x41.jpeg\" alt=\"\" width=\"630\" height=\"86\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-1-300x41.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-1-1024x141.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-1-768x106.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-1-1536x211.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-1-1200x165.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-1.jpeg 1642w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>now use below command to verify the status of master , copy file name and position.<\/p>\n<pre>SHOW MASTER STATUS\\G<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-592 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-2-300x69.jpeg\" alt=\"\" width=\"617\" height=\"142\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-2-300x69.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-2-1024x237.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-2-768x178.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-2-1200x277.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-2-2.jpeg 1514w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p><strong>Configure server-2 as a slave to server-1: <\/strong><\/p>\n<p>edit the configuration file &#8220;mysql-server.cnf&#8221;.<\/p>\n<pre>sudo vi \/etc\/my.cnf.d\/mysql-server.cnf<\/pre>\n<p>add these under [mysqld] inyour configuration file.<\/p>\n<pre>bind-address=172.31.33.123(give your 2nd machine private ip here)\r\nserver-id=2\r\nlog_bin=mysql-bin\r\n<\/pre>\n<p>save the file and restart mysql-server<\/p>\n<pre>systemctl restart mysqld<\/pre>\n<p>login to your mysql shell to configure it as a slave for server-1<\/p>\n<pre>sudo mysql -u root -p<\/pre>\n<p>use below command to stop replication threads.<\/p>\n<pre>mysql&gt; STOP SLAVE;<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-594 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-5-1-300x22.jpeg\" alt=\"\" width=\"695\" height=\"51\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-5-1-300x22.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-5-1-1024x76.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-5-1-768x57.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-5-1-1200x89.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-5-1.jpeg 1289w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>now run below command to set your server-2 to replicate data from master(server-1)<\/p>\n<pre>mysql&gt; CHANGE MASTER TO\r\n-&gt; MASTER_HOST='172.31.43.199',\r\n-&gt; MASTER_USER='aks',\r\n-&gt; MASTER_PASSWORD='@Aksshaay1',\r\n-&gt; MASTER_LOG_FILE='musql-bin.000005',\r\n-&gt; MASTER_LOG_POS=1481;\r\n<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-595 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-1-300x45.jpeg\" alt=\"\" width=\"714\" height=\"107\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-1-300x45.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-1-768x114.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-6-1.jpeg 1008w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>then execute below command to start replication threads.<\/p>\n<pre>mysql&gt; START SLAVE;<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-596 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-7-1-300x22.jpeg\" alt=\"\" width=\"641\" height=\"47\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-7-1-300x22.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-7-1-1024x77.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-7-1-768x58.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-7-1-1200x90.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-7-1.jpeg 1361w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>as of now we have created a one way communication from server-1(as master ) to server 2(as slave), now lets check our configuration.<\/p>\n<p>on your server-1 use below command to create a database,<\/p>\n<pre>mysql&gt;CREATE DATABASE dtabase_aks;<\/pre>\n<p>database_aks is the name of database iam creating, and use below command to check weather database is created or not.<\/p>\n<pre>mysql&gt;SHOW DATABASES;<\/pre>\n<p>and now logon to your server-2 and use command SHOW DATABASES to check for replication, in the snapshot below left side is my server-1(master) , I created a database &#8216;databses_aksshaay&#8217; and checking for replication of same in server-2 on the right side.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-599 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-9-2-300x146.jpeg\" alt=\"\" width=\"743\" height=\"362\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-9-2-300x146.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-9-2-1024x500.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-9-2-768x375.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-9-2-1536x750.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-9-2-1200x586.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-9-2.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>our configuration of server-1 as master ans server-2 as slave is done now let&#8217;s configure server-2 as master and server-1 as slave so that it will be a two way communication.<\/p>\n<h4><strong>STEP-3: Configure Server-2 as Master\u00a0 and Server-1 as slave.\u00a0<\/strong><\/h4>\n<p>login to mysql shell of server-2<\/p>\n<p>sudo mysql -u root -p<\/p>\n<p>execute below commands to create user and give replication permission.<\/p>\n<pre>mysql&gt; CREATE USER 'ajay'@'172.31.43.199' IDENTIFIED BY '@Password1';\r\nGRANT REPLICATION SLAVE ON *.*TO 'ajay'@'172.31.43.199';<\/pre>\n<p>here &#8216;ajay&#8217; is a user &#8216;172.31.43.199&#8217; is private-ip of my server-1 and \u00a0use below given command\u00a0 to reload the grant table<\/p>\n<pre>mysql&gt; FLUSH PRIVILEGES;<\/pre>\n<p>execute below command and copy file name and position number which we will use later.<\/p>\n<pre>mysql&gt; SHOW MASTER STATUS\\G<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-605 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-12-300x56.jpeg\" alt=\"\" width=\"622\" height=\"116\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-12-300x56.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-12-768x143.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-12.jpeg 1012w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>copy file name and position number.<\/p>\n<pre>mysql&gt; EXIT;<\/pre>\n<p>exit from your shell .<\/p>\n<p><strong>Configure server-1 as a slave to server-2:<\/strong><\/p>\n<p>login to your to mysql shell of server-1 and configure master details.<\/p>\n<pre>sudo mysql -u root -p<\/pre>\n<p>use below command to stop replication threads.<\/p>\n<pre>mysql&gt; STOP SLAVE;<\/pre>\n<p><img loading=\"lazy\" class=\"wp-image-606 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-13-300x22.jpeg\" alt=\"\" width=\"668\" height=\"49\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-13-300x22.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-13-1024x77.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-13-768x57.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-13-1536x115.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-13-1200x90.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-13.jpeg 1566w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>then execute below command to set master ,please use your server-2 private ip here, for user and password use from user created on server-2 and for file name and position number use the detail you copied from SHOW MASTER STATUS command on server-2.<\/p>\n<pre>mysql&gt; CHANGE MASTER TO\r\n-&gt; MASTER_HOST='172.31.33.123',\r\n-&gt; MASTER_USER='ajay',\r\n-&gt; MASTER_PASSWORD='@Password1',\r\n-&gt; MASTER_LOG_FILE='mysql-bin.000005',\r\n-&gt; MASTER_LOG_POS=323;\r\n<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-607 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-14-300x44.jpeg\" alt=\"\" width=\"654\" height=\"96\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-14-300x44.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-14-1024x150.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-14-768x113.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-14-1200x176.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-14.jpeg 1463w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>use below command to start replication threads.<\/p>\n<pre>mysql&gt;START SLAVE;<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-608 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-15-300x23.jpeg\" alt=\"\" width=\"652\" height=\"50\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-15-300x23.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-15-1024x78.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-15-768x59.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-15-1200x92.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-15.jpeg 1461w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>Yes that&#8217;s it you have configured a master master replication ,Lets test it now I am going to create\u00a0 a database named database_s1_s2 on server-1 which will be replicated on server-1\u00a0 and a database named database_s2_s1 on server-2 which will be replicated on to server-1.<\/p>\n<p>use below commands<\/p>\n<p>To create data base , give your database name in the place of database-name.<\/p>\n<pre>CREATE DATABASE\u00a0 database-name;<\/pre>\n<p>To see databases<\/p>\n<pre>SHOW DATABASES;<\/pre>\n<p>My server-1 is on the left side and server-2 on the right ,first I am creating a database on server-1 and checking it on server-2\u00a0 then creating a database on server-2 and checking it on server-1.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-644\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-16-154x300.jpeg\" alt=\"\" width=\"324\" height=\"631\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-16-154x300.jpeg 154w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-16-526x1024.jpeg 526w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-16.jpeg 555w\" sizes=\"(max-width: 324px) 85vw, 324px\" \/>\u00a0 \u00a0 \u00a0 <img loading=\"lazy\" class=\"alignnone wp-image-648\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-18-167x300.jpeg\" alt=\"\" width=\"351\" height=\"631\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-18-167x300.jpeg 167w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-18-570x1024.jpeg 570w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/mm-18.jpeg 601w\" sizes=\"(max-width: 351px) 85vw, 351px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>If you need an offshore cloud computing solution or a dedicated DevOps engineer to assist your production environment, please <a href=\"https:\/\/www.checkmateq.com\/contact-us\">contact us<\/a>. Our skilled offshore engineers are ready to take on any issues that arise in order to keep production running smoothly.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is MySQL? MySQL is one of the most used relational database management system(dbms)\u00a0 based on SQL, developed and distributed by Oracle corporation. it&#8217;s a relational database stores data in tables in which data in tables may be related to each other these relations between tables helps to structure the data and preform operations like &hellip; <a href=\"https:\/\/www.checkmateq.com\/blog\/master-master-replication-of-mysql\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Configure Master Master Replication of MySQL&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":655,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[41,39,40,38],"_links":{"self":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/561"}],"collection":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/comments?post=561"}],"version-history":[{"count":59,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":4191,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/561\/revisions\/4191"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media\/655"}],"wp:attachment":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media?parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/categories?post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/tags?post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}