{"id":60517,"date":"2018-09-26T11:00:44","date_gmt":"2018-09-26T08:00:44","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=60517"},"modified":"2018-09-24T11:38:19","modified_gmt":"2018-09-24T08:38:19","slug":"mysql-replication-tutorial","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/","title":{"rendered":"MySQL Replication Tutorial"},"content":{"rendered":"<h2 id=\"introduction\">1. Introduction<\/h2>\n<p><a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noopener\">MySQL<\/a>\u00a0is one of the most used SQL databases in many of the world-enterprise applications due to its ability to manage transactions and the ACID-behaviour which is built into its core. One of the reasons MySQL is so popular is due to the easiness it provides for its usage and its related commands. In the open source web application framework LAMP (which consist of Linux, Apache, MySQL and PHP),\u00a0MySQL server is a central &amp; important component. The MySQL Database server is written using C and C++ which internally uses\u00a0a lexical analyser to parse and understand the SQL queries.<\/p>\n<p>Today, when the systems have become distributed, scalable and highly fault tolerant, we cannot afford a fault in our databases like the DB servers going down and there is no way this is managed automatically. In this lesson, we will study about MySQL Replication, a concept through which we can make sure that even if the MySQL DB for a system goes down, it can shift to its replica and manage data from that as well, without letting users know what happened in the garage. This is one of the reasons that most of the systems today make use of\u00a0MySQL Replication.\u00a0MySQL Replication can be done for various reasons, including but not limited to:<\/p>\n<ol>\n<li>To ensure we have a backup of the data directly from our database<\/li>\n<li>To run analytics or check the data without disturbing the main database<\/li>\n<li>Scaling out the DB for better performance<\/li>\n<\/ol>\n<p>As\u00a0MySQL replication has so many uses, we must perform it in our production systems. If you want to find out what is MySQL Server and how to use it, read <a href=\"https:\/\/examples.javacodegeeks.com\/enterprise-java\/sql-enterprise-java\/mysql-server-tutorial\/\" target=\"_blank\" rel=\"noopener\">this<\/a> lesson. Let&#8217;s get started.<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#introduction\">1. Introduction<\/a><\/dt>\n<dt><a href=\"#mysql_setup\">2. MySQL Setup<\/a><\/dt>\n<dt><a href=\"#master_config\">3. Master MySQL Server Configuration<\/a><\/dt>\n<dt><a href=\"#slave_config\">4. Slave MySQL Server Configuration<\/a><\/dt>\n<dt><a href=\"#replication_lag\">5. Replication lag<\/a><\/dt>\n<dt><a href=\"#advantages\">6. Advantages of Replications<\/a><\/dt>\n<dt><a href=\"#disadvantages\">7. Disadvantages of Replication<\/a><\/dt>\n<dt><a href=\"#limitations\">8. Limitations of Replication<\/a><\/dt>\n<dt><a href=\"#types\">9. Types of MySQL Replication<\/a><\/dt>\n<dt><a href=\"#performance_effect\">10. Effect on Performance<\/a><\/dt>\n<dt><a href=\"#conclusion\">11. MySQL Replication &#8211; Conclusion<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2 id=\"mysql_setup\">2. MySQL Setup<\/h2>\n<p>For this lesson, we have made two new servers with different IPs which we will be using as Master and Slave in our replica set. To proceed further, we need to setup MySQL Server and Client tools on both of them. We can do this be executing the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Installing MySQL Server and Client<\/em><\/span><\/p>\n<pre class=\"brush:bash\">sudo apt-get install mysql-server mysql-client\r\n<\/pre>\n<p>Once we run this command, the mentioned utilities will be installed on the server. We will do the same installation on both the servers we made. While installing, we also set a MySQL root password:<\/p>\n<p><figure id=\"attachment_60518\" aria-describedby=\"caption-attachment-60518\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql.png\"><img decoding=\"async\" class=\"wp-image-60518 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql.png\" alt=\"MySQL Replication - Setting Root Password\" width=\"820\" height=\"378\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql-300x138.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql-768x354.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-60518\" class=\"wp-caption-text\">Setting Root Password<\/figcaption><\/figure><\/p>\n<p>Once the installation process is completed, we can confirm if the MySQL server is up and running with the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Check MySQL Service status<\/em><\/span><\/p>\n<pre class=\"brush:bash\">sudo service mysql status\r\n<\/pre>\n<p>We will see an output like this:<\/p>\n<p><figure id=\"attachment_60520\" aria-describedby=\"caption-attachment-60520\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status.png\"><img decoding=\"async\" class=\"wp-image-60520 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status.png\" alt=\"MySQL Replication - Check MySQL Server Status\" width=\"820\" height=\"304\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status-300x111.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status-768x285.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-60520\" class=\"wp-caption-text\">Check MySQL Server Status<\/figcaption><\/figure><\/p>\n<p>Now that we know that the MySQL server is up and running, we can connect to it using the username and password we supplied to it during the installation process. We can use the following command to do so:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Logging into MySQL<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mysql -u root -p\r\n<\/pre>\n<p>When we press enter, MySQL Server will silently wait for us to provide the password. When we type it, the password will not be echoed back to the terminal due to security reasons. We will see the following prompt once we have logged into the MySQL command line:<\/p>\n<p><figure id=\"attachment_60522\" aria-describedby=\"caption-attachment-60522\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login.png\"><img decoding=\"async\" class=\"wp-image-60522 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login.png\" alt=\"MySQL Replication - MySQL Login\" width=\"820\" height=\"304\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login-300x111.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login-768x285.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-60522\" class=\"wp-caption-text\">MySQL Login<\/figcaption><\/figure><\/p>\n<p>When we are inside the MySQL command prompt, we can use the given command to show the databases which are present in the system and to ensure that MySQL is running fine:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Show All databases<\/em><\/span><\/p>\n<pre class=\"brush:bash\">show databases;\r\n<\/pre>\n<p>Here is what we get back with this command:<\/p>\n<p><figure id=\"attachment_60525\" aria-describedby=\"caption-attachment-60525\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list.png\"><img decoding=\"async\" class=\"wp-image-60525 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list.png\" alt=\"MySQL Replication - Check MySQL Databases\" width=\"570\" height=\"255\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list.png 570w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list-300x134.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><figcaption id=\"caption-attachment-60525\" class=\"wp-caption-text\">Check MySQL Databases<\/figcaption><\/figure><\/p>\n<p>In the output, MySQL just displays the list of MySQL default databases that are used for administration purpose. Once we can see the Active status on both the servers, we can move ahead with the configuration for Master and Slave databases.<\/p>\n<h2 id=\"master_config\">3. Master MySQL Server Configuration<\/h2>\n<p>Now that we have active MySQL installation, we can start with the configuration of the master database first. To do this, we need to add configuration in the master MySQL config file. To open it with the nano editor on Ubuntu, use the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Edit config file<\/em><\/span><\/p>\n<pre class=\"brush:bash\">sudo nano \/etc\/mysql\/mysql.conf.d\/my.cnf\r\n<\/pre>\n<p>This file contains many options with which we can modify and configure the behaviour of the MySQL server we are running on the system. Firstly, we need to find the <code>bind-address<\/code> property in the file which will look like this:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Bind Address property<\/em><\/span><\/p>\n<pre class=\"brush:bash\"># Instead of skip-networking the default is now to listen only on\r\n# localhost which is more compatible and is not less secure.\r\nbind-address            = 127.0.0.1\r\n<\/pre>\n<p>We will modify this IP to the current server IP itself so that it looks like:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Updated Bind Address property<\/em><\/span><\/p>\n<pre class=\"brush:bash\">bind-address            = &lt;server_ip_here&gt;\r\n<\/pre>\n<p>The next property we need to find is <code>server-id<\/code> in the file which will look like this:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Server ID property<\/em><\/span><\/p>\n<pre class=\"brush:bash\"># note: if you are setting up a replication slave, see README.Debian about\r\n#       other settings you may need to change.\r\n#server-id              = 1\r\n<\/pre>\n<p>This will be a commented property which we will uncomment:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Updated Server ID property<\/em><\/span><\/p>\n<pre class=\"brush:bash\">server-id              = 1\r\n<\/pre>\n<p>Next important property to look for is <code>log_bin<\/code>. This property informs about the file where the replica set details are actually kept. This looks like:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Log Bin property<\/em><\/span><\/p>\n<pre class=\"brush:bash\">#log_bin                        = \/var\/log\/mysql\/mysql-bin.log\r\n<\/pre>\n<p>This is the file where the slave logs about the changes it has accomodated in it from the master database. We will just uncomment the property for now. Finally, we will edit the <code>binlog_do_db<\/code> property which informs the slave database server about which DB to replicate across the Slave database. We can include more than one database by repeating this line for all of the databases we will need:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline;\"><em>DB to backup<\/em><\/span><\/p>\n<pre class=\"brush:bash\">binlog_do_db            = jcg_database\r\n<\/pre>\n<p>Here is a glimpse of the config file which shows some of the properties we updated:<\/p>\n<p><figure id=\"attachment_60529\" aria-describedby=\"caption-attachment-60529\" style=\"width: 786px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/master-config-updated-file.png\"><img decoding=\"async\" class=\"wp-image-60529 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/master-config-updated-file.png\" alt=\"MySQL Replication - Updated config file\" width=\"786\" height=\"521\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/master-config-updated-file.png 786w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/master-config-updated-file-300x199.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/master-config-updated-file-768x509.png 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><figcaption id=\"caption-attachment-60529\" class=\"wp-caption-text\">Updated config file<\/figcaption><\/figure><\/p>\n<p>Once all of the properties are done, we can save the file and make sure that MySQL server is restarted so that these changes are reflected in the server. To restart MySQL server, run the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Restart MySQL<\/em><\/span><\/p>\n<pre class=\"brush:bash\">sudo service mysql restart\r\n<\/pre>\n<p>Once the MySQL Server restartes, the next changes we need to do is inside the MySQL shell itself. So log back in the MySQL command line again.<\/p>\n<p>We need to grant some privileges to the Slave DB so that it can access and replicate the data from the DB we mentioned in the config file, <code>jcg_database<\/code>. We will execute the following commands to grant the privileges to the Slave DB:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Grant Privileges<\/em><\/span><\/p>\n<pre class=\"brush:bash\">GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' IDENTIFIED BY 'password';\r\n<\/pre>\n<p>Now, flush the privileges with the command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Flush Privileges<\/em><\/span><\/p>\n<pre class=\"brush:bash\">FLUSH PRIVILEGES;\r\n<\/pre>\n<p>Now, switch to the database we want to replicate after creating it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Use new DB<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mysql&gt; CREATE SCHEMA jcg_database;\r\nQuery OK, 1 row affected (0.00 sec)\r\n\r\nmysql&gt; USE jcg_database;\r\nDatabase changed\r\n<\/pre>\n<p>Now, lock the database to stop any new changes happening in it with the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Apply Read Lock<\/em><\/span><\/p>\n<pre class=\"brush:bash\">FLUSH TABLES WITH READ LOCK;\r\n<\/pre>\n<p>Please note that we made some new tables and inserted some data before we applied this lock. Now, type the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Check Master Status<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SHOW MASTER STATUS;\r\n<\/pre>\n<p>Here is what we get back with this command:<\/p>\n<p><figure id=\"attachment_60530\" aria-describedby=\"caption-attachment-60530\" style=\"width: 738px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-master-status.png\"><img decoding=\"async\" class=\"wp-image-60530 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-master-status.png\" alt=\"MySQL Replication - Master DB Status\" width=\"738\" height=\"198\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-master-status.png 738w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-master-status-300x80.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><figcaption id=\"caption-attachment-60530\" class=\"wp-caption-text\">Master DB Status<\/figcaption><\/figure><\/p>\n<p>Note the position as this is the place from where the slave DB will start replicating the database. Now, if we do any changes to DB, it will unlock automatically, so do not do any new changes in same window. The next part is a little tricky. Open a new terminal window or tab (without closing the current tab) and log into the MySQL server and execute the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Dump MySQL<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mysqldump -u root -p --opt jcg_database &gt; jcg_database.sql\r\n<\/pre>\n<p>Here is what we get back with this command:<\/p>\n<p><figure id=\"attachment_60531\" aria-describedby=\"caption-attachment-60531\" style=\"width: 706px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-dump.png\"><img decoding=\"async\" class=\"wp-image-60531 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-dump.png\" alt=\"MySQL Replication - MySQL Dump\" width=\"706\" height=\"107\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-dump.png 706w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-dump-300x45.png 300w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><\/a><figcaption id=\"caption-attachment-60531\" class=\"wp-caption-text\">MySQL Dump<\/figcaption><\/figure><\/p>\n<p>Now we we can exit the new tab we opened separately and return to older tab. On that tab, unlock the DB and exit from MySQL:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Unlock and Quit<\/em><\/span><\/p>\n<pre class=\"brush:bash\">UNLOCK TABLES;\r\nQUIT;\r\n<\/pre>\n<p>With that, we are done with all the configuration needed to be done on master database.<\/p>\n<h2 id=\"slave_config\">4. Slave MySQL Server Configuration<\/h2>\n<p>Now, we are ready to start configuring our Slave database which will replicate the data. We can log in to the Slave server and open MySQL command line in it. For now, we only need to create a DB with the same name which we want to replicate and exit from the MySQL terminal:<\/p>\n<p><figure id=\"attachment_60534\" aria-describedby=\"caption-attachment-60534\" style=\"width: 538px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-slave-create-db.png\"><img decoding=\"async\" class=\"wp-image-60534 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-slave-create-db.png\" alt=\"MySQL Replication - MySQL Slave DB\" width=\"538\" height=\"141\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-slave-create-db.png 538w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-slave-create-db-300x79.png 300w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/a><figcaption id=\"caption-attachment-60534\" class=\"wp-caption-text\">MySQL Slave DB<\/figcaption><\/figure><\/p>\n<p>Now, we need to import the original database into Slave MySQL server with the SQL file we made. make sure that you bring that file on this new server and run the following command to import it into slave MySQL DB:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Import DB<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mysql -u root -p jcg_database &lt; \/root\/jcg_database.sql\r\n<\/pre>\n<p>Once you hit enter, the database content and metadata will be imported into the slave DB. Once that is done, we can configure the Slave MySQL DB as well:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Configure DB<\/em><\/span><\/p>\n<pre class=\"brush:bash\">nano \/etc\/mysql\/mysql.conf.d\/mysqld.cnf\r\n<\/pre>\n<p>We need to make sure that some properties in this config file are setup as well. The firt property is <code>server-id<\/code>. It is currently set to 1 which is the default value. Set it to some other value:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Server ID for Slave<\/em><\/span><\/p>\n<pre class=\"brush:bash\">server-id               = 2\r\n<\/pre>\n<p>Here are some other properties which we need to modify as well:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Other properties for Slace<\/em><\/span><\/p>\n<pre class=\"brush:bash\">relay-log               = \/var\/log\/mysql\/mysql-relay-bin.log\r\n\r\nlog_bin                 = \/var\/log\/mysql\/mysql-bin.log\r\n\r\nbinlog_do_db            = jcg_database\r\n<\/pre>\n<p>We will have to add <code>relay-log<\/code> property as it is not present in the config file by default. Once this is done, we need to restart the Slave MySQL DB as well so that the configuration changes we did can come into effect. Execute the following command to do this:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Restart MySQL<\/em><\/span><\/p>\n<pre class=\"brush:bash\">sudo service mysql restart\r\n<\/pre>\n<p>Once the MySQL Server restartes, the next changes we need to do is inside the MySQL shell itself. So log back in the MySQL command line again.<\/p>\n<p>In the MySQL shell, execute the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Enable Replication<\/em><\/span><\/p>\n<pre class=\"brush:bash\">CHANGE MASTER TO MASTER_HOST='&lt;master-server-ip&gt;',MASTER_USER='root', MASTER_PASSWORD='hello123', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=  1306;\r\n<\/pre>\n<p>This command completes various steps at a single time, which are:<\/p>\n<ul>\n<li>It informs current MySQL server that it is Slave to given MySQL Master Server<\/li>\n<li>It provides Slace with login credentials to Master Server<\/li>\n<li>It informs about the position from which Slave needs to start the replication process and also the log file details<\/li>\n<\/ul>\n<p>We can now finally activate the slave server with the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Activate MySQL Slave Server<\/em><\/span><\/p>\n<pre class=\"brush:bash\">START SLAVE;\r\n<\/pre>\n<p>We can now see some master details with the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MySQL Master Status<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SHOW SLAVE STATUS\\G;\r\n<\/pre>\n<p>Here is what we get back with the above command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MySQL Master Status Info<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mysql&gt; SHOW SLAVE STATUS\\G;\r\n*************************** 1. row ***************************\r\n               Slave_IO_State: Waiting for master to send event\r\n                  Master_Host: 206.189.133.122\r\n                  Master_User: root\r\n                  Master_Port: 3306\r\n                Connect_Retry: 60\r\n              Master_Log_File: mysql-bin.000001\r\n          Read_Master_Log_Pos: 1306\r\n               Relay_Log_File: mysql-relay-bin.000002\r\n                Relay_Log_Pos: 320\r\n        Relay_Master_Log_File: mysql-bin.000001\r\n             Slave_IO_Running: Yes\r\n            Slave_SQL_Running: Yes\r\n              Replicate_Do_DB:\r\n          Replicate_Ignore_DB:\r\n           Replicate_Do_Table:\r\n       Replicate_Ignore_Table:\r\n      Replicate_Wild_Do_Table:\r\n  Replicate_Wild_Ignore_Table:\r\n                   Last_Errno: 0\r\n                   Last_Error:\r\n                 Skip_Counter: 0\r\n          Exec_Master_Log_Pos: 1306\r\n              Relay_Log_Space: 527\r\n              Until_Condition: None\r\n               Until_Log_File:\r\n                Until_Log_Pos: 0\r\n           Master_SSL_Allowed: No\r\n           Master_SSL_CA_File:\r\n           Master_SSL_CA_Path:\r\n              Master_SSL_Cert:\r\n            Master_SSL_Cipher:\r\n               Master_SSL_Key:\r\n        Seconds_Behind_Master: 0\r\nMaster_SSL_Verify_Server_Cert: No\r\n                Last_IO_Errno: 0\r\n                Last_IO_Error:\r\n               Last_SQL_Errno: 0\r\n               Last_SQL_Error:\r\n  Replicate_Ignore_Server_Ids:\r\n             Master_Server_Id: 1\r\n                  Master_UUID: 3b890258-be5d-11e8-88c2-422b77d8526c\r\n             Master_Info_File: \/var\/lib\/mysql\/master.info\r\n                    SQL_Delay: 0\r\n          SQL_Remaining_Delay: NULL\r\n      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates\r\n           Master_Retry_Count: 86400\r\n                  Master_Bind:\r\n      Last_IO_Error_Timestamp:\r\n     Last_SQL_Error_Timestamp:\r\n               Master_SSL_Crl:\r\n           Master_SSL_Crlpath:\r\n           Retrieved_Gtid_Set:\r\n            Executed_Gtid_Set:\r\n                Auto_Position: 0\r\n         Replicate_Rewrite_DB:\r\n                 Channel_Name:\r\n           Master_TLS_Version:\r\n1 row in set (0.00 sec)\r\n<\/pre>\n<p>If there is an issue in connecting, you can try starting slave with a command to skip over it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MySQL Master Status<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; SLAVE START; \r\n<\/pre>\n<p>Now, we are done with MySQL replication and you should see the data being replicated across MySQL servers. To test the replication, you can try inserting some data into the Master database and check if the data is replicated to the slave database as well.<\/p>\n<h2 id=\"replication_lag\">5. Replication lag<\/h2>\n<p>MySQL replication makes use of two threads to complete replication across master and slave databases:<\/p>\n<ol>\n<li>IO_THREAD<\/li>\n<li>SQL_THREAD<\/li>\n<\/ol>\n<p>The IO_THREAD connects to the master MySQL server, reads the binary log to track and change events in the database, copies them to the local relay log file from where SQL_THREAD of Slave database reads and track the changes and replicate them to the Slave database. If we observe any replication lag, we must first identify if this lag is from Slave&#8217;s IO_THREAD or Slave&#8217;s SQL_THREAD.<\/p>\n<p>Usually, I\/O thread doesn&#8217;t cause any significant replication delay as it is just reading the binary logs from the master database but there are factors which can affect its performance like network connectivity, network latency etc. and how fast is the communication network line between the two servers. If there are high amount fo writes on Master, the replication could be slow due to bandwidth issues.<\/p>\n<p>On the other side of the coin, if it is the SQL Thread on Slave which is causing the delay, the most probable reason for the same is that the SQL queries from the Master DB are taking too long to execute on Slave database which piles up the changes which need to be done. Also, take into account that slave is single threaded prior to MySQL 5.6, which would be another reason for delays on the slave SQL_THREAD.<\/p>\n<h2 id=\"advantages\">6. Advantages of Replication<\/h2>\n<p>To reiterate what we stated earlier briefly, let us state here some explicit advantages of MySQL replication in a production environment:<\/p>\n<ul>\n<li><strong>Performance<\/strong>: A Slave server can be easily used to provide READ support to any client asking for data. This means that the load on the Master database is reduced a lot as there are no reads being done on it.<\/li>\n<li><strong>Backup Performance<\/strong>: If there are any backup tasks which are run, it can be run via the Slave database as data is being replicated. This means that backup jobs will not affect the Master database at all.<\/li>\n<li><strong>Disaster Recovery<\/strong>: In the events of Master database going completely offline, the Slave database can quickly take its place and start performing write operations, if configured in that manner. This will allow minimal site downtime as the master server is rebuilt and restored.<\/li>\n<\/ul>\n<h2 id=\"disadvantages\">7. Disadvantages of Replication<\/h2>\n<p>Although everything sounded so good about MySQL Replication, there are some downsides about the replication process as well, which are stated here:<\/p>\n<ul>\n<li><strong>Complexity<\/strong>: An application with a lot of Slaves for replication can create a maintenance nightmare if not managed correctly but this can be easily overcome<\/li>\n<li><strong>Performance<\/strong>: To complete the replication process, the binary logs need to be written to the disk. Although this can be minimal but it still needs to be considered while looking at overall server performance. This can be solved by making binary logs written to a separate partition of the disk to limit IO performance issues.<\/li>\n<\/ul>\n<h2 id=\"limitations\">8. Limitations of Replication<\/h2>\n<p>There are some limitations (or replication design) points which needs to be stated explicitly here:<\/p>\n<ul>\n<li>Replication is not a backup for application logic and any changes which are done on the Master database will always replicate to Slave database and there is no way this can be limited. If a user deletes data on the master database, it will be deleted on the Slave database as well.<\/li>\n<li>In case of multiple Slaves, performance is not increased but decreased as well because the database connections are now distributed across multiple servers and the risk of issues in case of any server fails will increase.<\/li>\n<\/ul>\n<h2 id=\"types\">9. Types of MySQL Replication<\/h2>\n<p>Essentially, MySQL support three different methods to replicate data from the master server to a slave server. All of these ways make use of the binary logs but it differs in the way the logs are written to it. Here are the ways replication is done:<\/p>\n<ol>\n<li>Statement-based replication: With this method, with each change in the database, the SQL statements for those changes are stored in the binary log file. The slave will read these SQL statements and execute them on its own MySQL database to produce the exact same copy fo data from the master server. This is the default replication method in MySQL 5.1.11 and earlier and MySQL 5.1.29 onwards.<\/li>\n<li>Row-based replication: In this method, the binary log file stores all of the record-level changes which occur in the master database tables. The slave server reads this data and updates its own records based on master&#8217;s data to produce an exact replica of the master database.<\/li>\n<li>Mixed-format replication: In this method, the server will dynamically select between statement-based replication and row-based replication, depending on some conditions like using a user-defined function (UDF), using an INSERT command with the DELAYED clause, using temporary tables, or using a statement that uses system variables. This is the default replication method in MySQL 5.1.12 to MySQL 5.1.28.<\/li>\n<\/ol>\n<p>In a use-case when you are not sure about which replication method to move forward with, it&#8217;s best to go with Statement-based replication as it is used most commonly and simplest to carry out. Though, if you have a write-heavy system, <strong>Statement-based replication is not recommended as it applies table locks<\/strong> as well. In that case, you can go with Row-based replication method which requires a lot less table locks.<\/p>\n<h2 id=\"performance_effect\">10. Effect on Performance<\/h2>\n<p>As mentioned, replication can affect the performance of your database but it can be minimal. The impact on the master server from replication is typically very small compared to all of the other things it has to do because the master only really has to accomplish two significant things in a replication environment:<\/p>\n<ul>\n<li>formulate and write events to the binary log on the local hard drive<\/li>\n<li>send a copy of every event it writes to the binary log to every connected slave<\/li>\n<\/ul>\n<p>We cannot consider writing the binary log to be a cost of replication, because we should <strong>always<\/strong> have binary logging turned on even if we&#8217;re not replicating. It&#8217;s an extremely valuable troubleshooting and recovery tool.<\/p>\n<p>The cost of sending the replication events to the slave(s) is also negligible because the slave is responsible for maintaining a persistent TCP connection to the master, which only has to copy the data onto the socket as the events occur. Beyond that, the master neither knows nor cares whether or when the slave gets around to executing them.<\/p>\n<p>A partial exception to that last statement is <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/replication-semisync.html\" target=\"_blank\" rel=\"noopener\">semi-synchronous<\/a> replication, which is not the default. In this mode, the master waits for at least one slave to acknowledge receipt and persistent storage (though not actual execution) of the binary log events from each transaction, before the master returns control to the client on each commit.<\/p>\n<p>But in every case, the master is <strong>not<\/strong> responsible for actually executing the updates on the slave &#8212; it just sends one of two things to the slave: either a copy of the actual input query that ran (in statement-based mode) or the data for the rows actually inserted\/updated\/deleted by each query (in row-based mode). In mixed mode, the query optimizer will decide which format to use on a per-event basis.<\/p>\n<h2 id=\"conclusion\">11. MySQL Replication &#8211; Conclusion<\/h2>\n<p>MySQL Replication is an excellent choice (besides its disadvantages and limitations) when it comes to making sure that a production system runs with failover reliability which makes it a fault-tolerant system, which is a must when it comes to distributed and highly available systems today. The replication is so important to be done that even the cloud distributors like AWS support it natively.<\/p>\n<p>This lesson provides with important configuration changes which need to be done for a system to replicate its data across a single slave. We can set up any number of slaves without disturbing the master server as there is no configuration on the Master server which relates or binds it to any Slave server. We also provided some knowledge about the advantages, disadvantages and limitations MySQL replication has which were important to be stated explicitly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction MySQL\u00a0is one of the most used SQL databases in many of the world-enterprise applications due to its ability to manage transactions and the ACID-behaviour which is built into its core. One of the reasons MySQL is so popular is due to the easiness it provides for its usage and its related commands. In &hellip;<\/p>\n","protected":false},"author":154,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[881,647],"class_list":["post-60517","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-database","tag-mysql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MySQL Replication Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about MySQL? Then check out our detailed tutorial on MySQL Replication!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL Replication Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about MySQL? Then check out our detailed tutorial on MySQL Replication!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-26T08:00:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubham Aggarwal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sbmaggarwal\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubham Aggarwal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/\"},\"author\":{\"name\":\"Shubham Aggarwal\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2\"},\"headline\":\"MySQL Replication Tutorial\",\"datePublished\":\"2018-09-26T08:00:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/\"},\"wordCount\":3051,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"database\",\"mysql\"],\"articleSection\":[\"sql\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/\",\"name\":\"MySQL Replication Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2018-09-26T08:00:44+00:00\",\"description\":\"Interested to learn more about MySQL? Then check out our detailed tutorial on MySQL Replication!\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"sql\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"MySQL Replication Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2\",\"name\":\"Shubham Aggarwal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg\",\"caption\":\"Shubham Aggarwal\"},\"description\":\"Shubham is a Java Backend and Data Analytics Engineer with more than 3 years of experience in building quality products with Spring Boot, MongoDB, Elasticsearch, MySQL, Docker, AWS, Git, PrestoDB tools and I have a deep knowledge and passion towards analytics, Micro-service based architecture, design patterns, antipatterns and software design thinking.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sbmaggarwal\/\",\"https:\/\/x.com\/sbmaggarwal\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/shubham-aggarwal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL Replication Tutorial - Java Code Geeks","description":"Interested to learn more about MySQL? Then check out our detailed tutorial on MySQL Replication!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"MySQL Replication Tutorial - Java Code Geeks","og_description":"Interested to learn more about MySQL? Then check out our detailed tutorial on MySQL Replication!","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-09-26T08:00:44+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Shubham Aggarwal","twitter_card":"summary_large_image","twitter_creator":"@sbmaggarwal","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubham Aggarwal","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/"},"author":{"name":"Shubham Aggarwal","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2"},"headline":"MySQL Replication Tutorial","datePublished":"2018-09-26T08:00:44+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/"},"wordCount":3051,"commentCount":2,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["database","mysql"],"articleSection":["sql"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/","name":"MySQL Replication Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2018-09-26T08:00:44+00:00","description":"Interested to learn more about MySQL? Then check out our detailed tutorial on MySQL Replication!","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-replication-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"sql","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/"},{"@type":"ListItem","position":5,"name":"MySQL Replication Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2","name":"Shubham Aggarwal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg","caption":"Shubham Aggarwal"},"description":"Shubham is a Java Backend and Data Analytics Engineer with more than 3 years of experience in building quality products with Spring Boot, MongoDB, Elasticsearch, MySQL, Docker, AWS, Git, PrestoDB tools and I have a deep knowledge and passion towards analytics, Micro-service based architecture, design patterns, antipatterns and software design thinking.","sameAs":["https:\/\/www.linkedin.com\/in\/sbmaggarwal\/","https:\/\/x.com\/sbmaggarwal"],"url":"https:\/\/examples.javacodegeeks.com\/author\/shubham-aggarwal\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/60517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/154"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=60517"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/60517\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=60517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=60517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=60517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}