MySQL Slave replication: Need to determine where replication left off to start slave in correct location












5















Idiotically I rebooted a machine that is used as a MySQL slave without running STOP SLAVE, FLUSH TABLES first.



I had thought MySQL automatically handles all of this during a machine reboot, but apparently it doesn't, at least not in the configuration I was using, because the SLAVE doesn't start back up.



mysqld does start but there is an error message in the logs indicating the slave portion stops due to duplicate primary key issues. Meaning it is trying to insert data that has already been added.



Here are the errors generated in the mysql log:



120104 11:07:54 [Warning] Slave: Duplicate entry '94459' for key 'PRIMARY' Error_code: 1062
120104 11:07:54 [ERROR] Error running query, slave SQL thread aborted.
Fix the problem, and restart the slave SQL thread with "SLAVE START".
We stopped at log 'mysql1-bin.000362' position 3384732


How do I determine where in the master binary log the process needs to start from to run a CHANGE MASTER statement? I know I could potentially, skip log entries using the sql_slave_skip_counter but without knowing how many to skip I would need to go one by one, and that could take all day.










share|improve this question





























    5















    Idiotically I rebooted a machine that is used as a MySQL slave without running STOP SLAVE, FLUSH TABLES first.



    I had thought MySQL automatically handles all of this during a machine reboot, but apparently it doesn't, at least not in the configuration I was using, because the SLAVE doesn't start back up.



    mysqld does start but there is an error message in the logs indicating the slave portion stops due to duplicate primary key issues. Meaning it is trying to insert data that has already been added.



    Here are the errors generated in the mysql log:



    120104 11:07:54 [Warning] Slave: Duplicate entry '94459' for key 'PRIMARY' Error_code: 1062
    120104 11:07:54 [ERROR] Error running query, slave SQL thread aborted.
    Fix the problem, and restart the slave SQL thread with "SLAVE START".
    We stopped at log 'mysql1-bin.000362' position 3384732


    How do I determine where in the master binary log the process needs to start from to run a CHANGE MASTER statement? I know I could potentially, skip log entries using the sql_slave_skip_counter but without knowing how many to skip I would need to go one by one, and that could take all day.










    share|improve this question



























      5












      5








      5


      7






      Idiotically I rebooted a machine that is used as a MySQL slave without running STOP SLAVE, FLUSH TABLES first.



      I had thought MySQL automatically handles all of this during a machine reboot, but apparently it doesn't, at least not in the configuration I was using, because the SLAVE doesn't start back up.



      mysqld does start but there is an error message in the logs indicating the slave portion stops due to duplicate primary key issues. Meaning it is trying to insert data that has already been added.



      Here are the errors generated in the mysql log:



      120104 11:07:54 [Warning] Slave: Duplicate entry '94459' for key 'PRIMARY' Error_code: 1062
      120104 11:07:54 [ERROR] Error running query, slave SQL thread aborted.
      Fix the problem, and restart the slave SQL thread with "SLAVE START".
      We stopped at log 'mysql1-bin.000362' position 3384732


      How do I determine where in the master binary log the process needs to start from to run a CHANGE MASTER statement? I know I could potentially, skip log entries using the sql_slave_skip_counter but without knowing how many to skip I would need to go one by one, and that could take all day.










      share|improve this question
















      Idiotically I rebooted a machine that is used as a MySQL slave without running STOP SLAVE, FLUSH TABLES first.



      I had thought MySQL automatically handles all of this during a machine reboot, but apparently it doesn't, at least not in the configuration I was using, because the SLAVE doesn't start back up.



      mysqld does start but there is an error message in the logs indicating the slave portion stops due to duplicate primary key issues. Meaning it is trying to insert data that has already been added.



      Here are the errors generated in the mysql log:



      120104 11:07:54 [Warning] Slave: Duplicate entry '94459' for key 'PRIMARY' Error_code: 1062
      120104 11:07:54 [ERROR] Error running query, slave SQL thread aborted.
      Fix the problem, and restart the slave SQL thread with "SLAVE START".
      We stopped at log 'mysql1-bin.000362' position 3384732


      How do I determine where in the master binary log the process needs to start from to run a CHANGE MASTER statement? I know I could potentially, skip log entries using the sql_slave_skip_counter but without knowing how many to skip I would need to go one by one, and that could take all day.







      mysql replication






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 12 mins ago









      Paul White

      51k14278450




      51k14278450










      asked Jan 4 '12 at 17:15









      AglystasAglystas

      3316




      3316






















          1 Answer
          1






          active

          oldest

          votes


















          6














          The Primary thing you need to do was left in a comment:




          Follow the suggestion in Duplicate entry in MySQL slave:




          STOP SLAVE;
          SET GLOBAL sql_slave_skip_counter=1;
          START SLAVE;




          However, here is how you can start off at the better position with the CHANGE MASTER TO command.



          Let's take a look at a sample SHOW SLAVE STATUSG



                         Slave_IO_State: Waiting for master to send event
          Master_Host: 10.4.16.245
          Master_User: replicant
          Master_Port: 3306
          Connect_Retry: 60
          Master_Log_File: mysql-bin.001527
          Read_Master_Log_Pos: 554619670
          Relay_Log_File: relay-bin.004561
          Relay_Log_Pos: 554619815
          Relay_Master_Log_File: mysql-bin.001527
          Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
          Replicate_Do_DB:
          Replicate_Ignore_DB: phpmyadmin
          Replicate_Do_Table:
          Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
          Replicate_Wild_Ignore_Table:
          Last_Errno: 0
          Last_Error:
          Skip_Counter: 0
          Exec_Master_Log_Pos: 554619670
          Relay_Log_Space: 554620007
          Until_Condition: None
          Until_Log_File:
          Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
          Master_SSL_Cert:
          Master_SSL_Cipher:
          Master_SSL_Key:
          Seconds_Behind_Master: 0
          Master_SSL_Verify_Server_Cert: No
          Last_IO_Errno: 0
          Last_IO_Error:
          Last_SQL_Errno: 0
          Last_SQL_Error:


          Please take note of Relay_Master_Log_File and Exec_Master_Log_Pos. These represent the log file and the position of the last SQL statement that was completed on the Master that is next in line to be executed on the Slave.



          So, the CHANGE MASTER TO in this case would be:



          CHANGE MASTER TO master_log_file='mysql-bin.001527',master_log_pos=554619670;


          For your particular case, here is what you need to do on the Slave Server:



          Step 01) Start mysql up with replication disabled at startup



          $ service mysql restart --skip-slave-start


          Step 02) Login to mysql and show the slave status:



          mysql> SHOW SLAVE STATUSG


          Step 03) Get Relay_Master_Log_File and Exec_Master_Log_Pos from SHOW SLAVE STATUSG



          Step 04) Run CHANGE MASTER TO command using Relay_Master_Log_File and Exec_Master_Log_Pos



          This will erase any relay logs collected and start collecting with a fresh, empty relay log.



          Step 05) mysql> START SLAVE;



          Step 06) mysql> SHOW SLAVE STATUSG repeatedly to watch Seconds_Behind_Master go to 0



          Step 07) If replication breaks due to Error 1062 (Duplicate Key), now you can implement @DTest's suggestion. Then, goto Step 06. Repeat this until Seconds_Behind_Master go to 0.




          We stopped at log 'mysql1-bin.000362' position 3384732.




          That's what you use:



          CHANGE MASTER TO master_log_file='mysql1-bin.000362'. master_log_pos=3384732;


          If you ran RESET SLAVE on the Slave, do not despair. Just run the full syntax version of the CHANGE MASTER TO command:



          CHANGE MASTER TO
          MASTER_HOST='IP Address of Master',
          MASTER_PORT=3306,
          MASTER_USER='Replication Username',
          MASTER_PASSWORD='Replication Password',
          MASTER_LOG_FILE='mysql1-bin.000362',
          MASTER_LOG_POS=3384732;





          share|improve this answer


























          • Thanks for all the help. I ended up using the Change Master command using a MASTER_LOG_POS that I knew would work, which is okay for now, but I will probably need to sync up the databases in the future.

            – Aglystas
            Jan 4 '12 at 19:04











          • If you want to sync the databases without a reload the full dataset, look into the tools pt-table-checksum and pt-table-sync. I wrote a script to automate that process using MAATKIT's mk-table-checksum and mk-table-sync : dba.stackexchange.com/a/8808/877

            – RolandoMySQLDBA
            Jan 4 '12 at 19:17













          • @RolandoMySQLDBA: As per my understanding, we can't start replication from the pointer where error log is showing as mysql has executed last point due to this error is related with duplicate key...here we have to skip this position as it has been executed....yes here Aglystas's concern is how can skip blindly so first we have to read binary logs and make sure that statement before this position and of this position has been executed on slave and the just next position sql is not updated till now, so we can skip 1 pointer here or use that position in change master to...

            – Zafar Malik
            Aug 18 '15 at 11:52













          • Also there should not any need of mysql service restart.

            – Zafar Malik
            Aug 18 '15 at 11:52











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f10151%2fmysql-slave-replication-need-to-determine-where-replication-left-off-to-start-s%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          The Primary thing you need to do was left in a comment:




          Follow the suggestion in Duplicate entry in MySQL slave:




          STOP SLAVE;
          SET GLOBAL sql_slave_skip_counter=1;
          START SLAVE;




          However, here is how you can start off at the better position with the CHANGE MASTER TO command.



          Let's take a look at a sample SHOW SLAVE STATUSG



                         Slave_IO_State: Waiting for master to send event
          Master_Host: 10.4.16.245
          Master_User: replicant
          Master_Port: 3306
          Connect_Retry: 60
          Master_Log_File: mysql-bin.001527
          Read_Master_Log_Pos: 554619670
          Relay_Log_File: relay-bin.004561
          Relay_Log_Pos: 554619815
          Relay_Master_Log_File: mysql-bin.001527
          Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
          Replicate_Do_DB:
          Replicate_Ignore_DB: phpmyadmin
          Replicate_Do_Table:
          Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
          Replicate_Wild_Ignore_Table:
          Last_Errno: 0
          Last_Error:
          Skip_Counter: 0
          Exec_Master_Log_Pos: 554619670
          Relay_Log_Space: 554620007
          Until_Condition: None
          Until_Log_File:
          Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
          Master_SSL_Cert:
          Master_SSL_Cipher:
          Master_SSL_Key:
          Seconds_Behind_Master: 0
          Master_SSL_Verify_Server_Cert: No
          Last_IO_Errno: 0
          Last_IO_Error:
          Last_SQL_Errno: 0
          Last_SQL_Error:


          Please take note of Relay_Master_Log_File and Exec_Master_Log_Pos. These represent the log file and the position of the last SQL statement that was completed on the Master that is next in line to be executed on the Slave.



          So, the CHANGE MASTER TO in this case would be:



          CHANGE MASTER TO master_log_file='mysql-bin.001527',master_log_pos=554619670;


          For your particular case, here is what you need to do on the Slave Server:



          Step 01) Start mysql up with replication disabled at startup



          $ service mysql restart --skip-slave-start


          Step 02) Login to mysql and show the slave status:



          mysql> SHOW SLAVE STATUSG


          Step 03) Get Relay_Master_Log_File and Exec_Master_Log_Pos from SHOW SLAVE STATUSG



          Step 04) Run CHANGE MASTER TO command using Relay_Master_Log_File and Exec_Master_Log_Pos



          This will erase any relay logs collected and start collecting with a fresh, empty relay log.



          Step 05) mysql> START SLAVE;



          Step 06) mysql> SHOW SLAVE STATUSG repeatedly to watch Seconds_Behind_Master go to 0



          Step 07) If replication breaks due to Error 1062 (Duplicate Key), now you can implement @DTest's suggestion. Then, goto Step 06. Repeat this until Seconds_Behind_Master go to 0.




          We stopped at log 'mysql1-bin.000362' position 3384732.




          That's what you use:



          CHANGE MASTER TO master_log_file='mysql1-bin.000362'. master_log_pos=3384732;


          If you ran RESET SLAVE on the Slave, do not despair. Just run the full syntax version of the CHANGE MASTER TO command:



          CHANGE MASTER TO
          MASTER_HOST='IP Address of Master',
          MASTER_PORT=3306,
          MASTER_USER='Replication Username',
          MASTER_PASSWORD='Replication Password',
          MASTER_LOG_FILE='mysql1-bin.000362',
          MASTER_LOG_POS=3384732;





          share|improve this answer


























          • Thanks for all the help. I ended up using the Change Master command using a MASTER_LOG_POS that I knew would work, which is okay for now, but I will probably need to sync up the databases in the future.

            – Aglystas
            Jan 4 '12 at 19:04











          • If you want to sync the databases without a reload the full dataset, look into the tools pt-table-checksum and pt-table-sync. I wrote a script to automate that process using MAATKIT's mk-table-checksum and mk-table-sync : dba.stackexchange.com/a/8808/877

            – RolandoMySQLDBA
            Jan 4 '12 at 19:17













          • @RolandoMySQLDBA: As per my understanding, we can't start replication from the pointer where error log is showing as mysql has executed last point due to this error is related with duplicate key...here we have to skip this position as it has been executed....yes here Aglystas's concern is how can skip blindly so first we have to read binary logs and make sure that statement before this position and of this position has been executed on slave and the just next position sql is not updated till now, so we can skip 1 pointer here or use that position in change master to...

            – Zafar Malik
            Aug 18 '15 at 11:52













          • Also there should not any need of mysql service restart.

            – Zafar Malik
            Aug 18 '15 at 11:52
















          6














          The Primary thing you need to do was left in a comment:




          Follow the suggestion in Duplicate entry in MySQL slave:




          STOP SLAVE;
          SET GLOBAL sql_slave_skip_counter=1;
          START SLAVE;




          However, here is how you can start off at the better position with the CHANGE MASTER TO command.



          Let's take a look at a sample SHOW SLAVE STATUSG



                         Slave_IO_State: Waiting for master to send event
          Master_Host: 10.4.16.245
          Master_User: replicant
          Master_Port: 3306
          Connect_Retry: 60
          Master_Log_File: mysql-bin.001527
          Read_Master_Log_Pos: 554619670
          Relay_Log_File: relay-bin.004561
          Relay_Log_Pos: 554619815
          Relay_Master_Log_File: mysql-bin.001527
          Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
          Replicate_Do_DB:
          Replicate_Ignore_DB: phpmyadmin
          Replicate_Do_Table:
          Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
          Replicate_Wild_Ignore_Table:
          Last_Errno: 0
          Last_Error:
          Skip_Counter: 0
          Exec_Master_Log_Pos: 554619670
          Relay_Log_Space: 554620007
          Until_Condition: None
          Until_Log_File:
          Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
          Master_SSL_Cert:
          Master_SSL_Cipher:
          Master_SSL_Key:
          Seconds_Behind_Master: 0
          Master_SSL_Verify_Server_Cert: No
          Last_IO_Errno: 0
          Last_IO_Error:
          Last_SQL_Errno: 0
          Last_SQL_Error:


          Please take note of Relay_Master_Log_File and Exec_Master_Log_Pos. These represent the log file and the position of the last SQL statement that was completed on the Master that is next in line to be executed on the Slave.



          So, the CHANGE MASTER TO in this case would be:



          CHANGE MASTER TO master_log_file='mysql-bin.001527',master_log_pos=554619670;


          For your particular case, here is what you need to do on the Slave Server:



          Step 01) Start mysql up with replication disabled at startup



          $ service mysql restart --skip-slave-start


          Step 02) Login to mysql and show the slave status:



          mysql> SHOW SLAVE STATUSG


          Step 03) Get Relay_Master_Log_File and Exec_Master_Log_Pos from SHOW SLAVE STATUSG



          Step 04) Run CHANGE MASTER TO command using Relay_Master_Log_File and Exec_Master_Log_Pos



          This will erase any relay logs collected and start collecting with a fresh, empty relay log.



          Step 05) mysql> START SLAVE;



          Step 06) mysql> SHOW SLAVE STATUSG repeatedly to watch Seconds_Behind_Master go to 0



          Step 07) If replication breaks due to Error 1062 (Duplicate Key), now you can implement @DTest's suggestion. Then, goto Step 06. Repeat this until Seconds_Behind_Master go to 0.




          We stopped at log 'mysql1-bin.000362' position 3384732.




          That's what you use:



          CHANGE MASTER TO master_log_file='mysql1-bin.000362'. master_log_pos=3384732;


          If you ran RESET SLAVE on the Slave, do not despair. Just run the full syntax version of the CHANGE MASTER TO command:



          CHANGE MASTER TO
          MASTER_HOST='IP Address of Master',
          MASTER_PORT=3306,
          MASTER_USER='Replication Username',
          MASTER_PASSWORD='Replication Password',
          MASTER_LOG_FILE='mysql1-bin.000362',
          MASTER_LOG_POS=3384732;





          share|improve this answer


























          • Thanks for all the help. I ended up using the Change Master command using a MASTER_LOG_POS that I knew would work, which is okay for now, but I will probably need to sync up the databases in the future.

            – Aglystas
            Jan 4 '12 at 19:04











          • If you want to sync the databases without a reload the full dataset, look into the tools pt-table-checksum and pt-table-sync. I wrote a script to automate that process using MAATKIT's mk-table-checksum and mk-table-sync : dba.stackexchange.com/a/8808/877

            – RolandoMySQLDBA
            Jan 4 '12 at 19:17













          • @RolandoMySQLDBA: As per my understanding, we can't start replication from the pointer where error log is showing as mysql has executed last point due to this error is related with duplicate key...here we have to skip this position as it has been executed....yes here Aglystas's concern is how can skip blindly so first we have to read binary logs and make sure that statement before this position and of this position has been executed on slave and the just next position sql is not updated till now, so we can skip 1 pointer here or use that position in change master to...

            – Zafar Malik
            Aug 18 '15 at 11:52













          • Also there should not any need of mysql service restart.

            – Zafar Malik
            Aug 18 '15 at 11:52














          6












          6








          6







          The Primary thing you need to do was left in a comment:




          Follow the suggestion in Duplicate entry in MySQL slave:




          STOP SLAVE;
          SET GLOBAL sql_slave_skip_counter=1;
          START SLAVE;




          However, here is how you can start off at the better position with the CHANGE MASTER TO command.



          Let's take a look at a sample SHOW SLAVE STATUSG



                         Slave_IO_State: Waiting for master to send event
          Master_Host: 10.4.16.245
          Master_User: replicant
          Master_Port: 3306
          Connect_Retry: 60
          Master_Log_File: mysql-bin.001527
          Read_Master_Log_Pos: 554619670
          Relay_Log_File: relay-bin.004561
          Relay_Log_Pos: 554619815
          Relay_Master_Log_File: mysql-bin.001527
          Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
          Replicate_Do_DB:
          Replicate_Ignore_DB: phpmyadmin
          Replicate_Do_Table:
          Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
          Replicate_Wild_Ignore_Table:
          Last_Errno: 0
          Last_Error:
          Skip_Counter: 0
          Exec_Master_Log_Pos: 554619670
          Relay_Log_Space: 554620007
          Until_Condition: None
          Until_Log_File:
          Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
          Master_SSL_Cert:
          Master_SSL_Cipher:
          Master_SSL_Key:
          Seconds_Behind_Master: 0
          Master_SSL_Verify_Server_Cert: No
          Last_IO_Errno: 0
          Last_IO_Error:
          Last_SQL_Errno: 0
          Last_SQL_Error:


          Please take note of Relay_Master_Log_File and Exec_Master_Log_Pos. These represent the log file and the position of the last SQL statement that was completed on the Master that is next in line to be executed on the Slave.



          So, the CHANGE MASTER TO in this case would be:



          CHANGE MASTER TO master_log_file='mysql-bin.001527',master_log_pos=554619670;


          For your particular case, here is what you need to do on the Slave Server:



          Step 01) Start mysql up with replication disabled at startup



          $ service mysql restart --skip-slave-start


          Step 02) Login to mysql and show the slave status:



          mysql> SHOW SLAVE STATUSG


          Step 03) Get Relay_Master_Log_File and Exec_Master_Log_Pos from SHOW SLAVE STATUSG



          Step 04) Run CHANGE MASTER TO command using Relay_Master_Log_File and Exec_Master_Log_Pos



          This will erase any relay logs collected and start collecting with a fresh, empty relay log.



          Step 05) mysql> START SLAVE;



          Step 06) mysql> SHOW SLAVE STATUSG repeatedly to watch Seconds_Behind_Master go to 0



          Step 07) If replication breaks due to Error 1062 (Duplicate Key), now you can implement @DTest's suggestion. Then, goto Step 06. Repeat this until Seconds_Behind_Master go to 0.




          We stopped at log 'mysql1-bin.000362' position 3384732.




          That's what you use:



          CHANGE MASTER TO master_log_file='mysql1-bin.000362'. master_log_pos=3384732;


          If you ran RESET SLAVE on the Slave, do not despair. Just run the full syntax version of the CHANGE MASTER TO command:



          CHANGE MASTER TO
          MASTER_HOST='IP Address of Master',
          MASTER_PORT=3306,
          MASTER_USER='Replication Username',
          MASTER_PASSWORD='Replication Password',
          MASTER_LOG_FILE='mysql1-bin.000362',
          MASTER_LOG_POS=3384732;





          share|improve this answer















          The Primary thing you need to do was left in a comment:




          Follow the suggestion in Duplicate entry in MySQL slave:




          STOP SLAVE;
          SET GLOBAL sql_slave_skip_counter=1;
          START SLAVE;




          However, here is how you can start off at the better position with the CHANGE MASTER TO command.



          Let's take a look at a sample SHOW SLAVE STATUSG



                         Slave_IO_State: Waiting for master to send event
          Master_Host: 10.4.16.245
          Master_User: replicant
          Master_Port: 3306
          Connect_Retry: 60
          Master_Log_File: mysql-bin.001527
          Read_Master_Log_Pos: 554619670
          Relay_Log_File: relay-bin.004561
          Relay_Log_Pos: 554619815
          Relay_Master_Log_File: mysql-bin.001527
          Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
          Replicate_Do_DB:
          Replicate_Ignore_DB: phpmyadmin
          Replicate_Do_Table:
          Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
          Replicate_Wild_Ignore_Table:
          Last_Errno: 0
          Last_Error:
          Skip_Counter: 0
          Exec_Master_Log_Pos: 554619670
          Relay_Log_Space: 554620007
          Until_Condition: None
          Until_Log_File:
          Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
          Master_SSL_Cert:
          Master_SSL_Cipher:
          Master_SSL_Key:
          Seconds_Behind_Master: 0
          Master_SSL_Verify_Server_Cert: No
          Last_IO_Errno: 0
          Last_IO_Error:
          Last_SQL_Errno: 0
          Last_SQL_Error:


          Please take note of Relay_Master_Log_File and Exec_Master_Log_Pos. These represent the log file and the position of the last SQL statement that was completed on the Master that is next in line to be executed on the Slave.



          So, the CHANGE MASTER TO in this case would be:



          CHANGE MASTER TO master_log_file='mysql-bin.001527',master_log_pos=554619670;


          For your particular case, here is what you need to do on the Slave Server:



          Step 01) Start mysql up with replication disabled at startup



          $ service mysql restart --skip-slave-start


          Step 02) Login to mysql and show the slave status:



          mysql> SHOW SLAVE STATUSG


          Step 03) Get Relay_Master_Log_File and Exec_Master_Log_Pos from SHOW SLAVE STATUSG



          Step 04) Run CHANGE MASTER TO command using Relay_Master_Log_File and Exec_Master_Log_Pos



          This will erase any relay logs collected and start collecting with a fresh, empty relay log.



          Step 05) mysql> START SLAVE;



          Step 06) mysql> SHOW SLAVE STATUSG repeatedly to watch Seconds_Behind_Master go to 0



          Step 07) If replication breaks due to Error 1062 (Duplicate Key), now you can implement @DTest's suggestion. Then, goto Step 06. Repeat this until Seconds_Behind_Master go to 0.




          We stopped at log 'mysql1-bin.000362' position 3384732.




          That's what you use:



          CHANGE MASTER TO master_log_file='mysql1-bin.000362'. master_log_pos=3384732;


          If you ran RESET SLAVE on the Slave, do not despair. Just run the full syntax version of the CHANGE MASTER TO command:



          CHANGE MASTER TO
          MASTER_HOST='IP Address of Master',
          MASTER_PORT=3306,
          MASTER_USER='Replication Username',
          MASTER_PASSWORD='Replication Password',
          MASTER_LOG_FILE='mysql1-bin.000362',
          MASTER_LOG_POS=3384732;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 13 mins ago









          Paul White

          51k14278450




          51k14278450










          answered Jan 4 '12 at 18:13









          RolandoMySQLDBARolandoMySQLDBA

          141k24221379




          141k24221379













          • Thanks for all the help. I ended up using the Change Master command using a MASTER_LOG_POS that I knew would work, which is okay for now, but I will probably need to sync up the databases in the future.

            – Aglystas
            Jan 4 '12 at 19:04











          • If you want to sync the databases without a reload the full dataset, look into the tools pt-table-checksum and pt-table-sync. I wrote a script to automate that process using MAATKIT's mk-table-checksum and mk-table-sync : dba.stackexchange.com/a/8808/877

            – RolandoMySQLDBA
            Jan 4 '12 at 19:17













          • @RolandoMySQLDBA: As per my understanding, we can't start replication from the pointer where error log is showing as mysql has executed last point due to this error is related with duplicate key...here we have to skip this position as it has been executed....yes here Aglystas's concern is how can skip blindly so first we have to read binary logs and make sure that statement before this position and of this position has been executed on slave and the just next position sql is not updated till now, so we can skip 1 pointer here or use that position in change master to...

            – Zafar Malik
            Aug 18 '15 at 11:52













          • Also there should not any need of mysql service restart.

            – Zafar Malik
            Aug 18 '15 at 11:52



















          • Thanks for all the help. I ended up using the Change Master command using a MASTER_LOG_POS that I knew would work, which is okay for now, but I will probably need to sync up the databases in the future.

            – Aglystas
            Jan 4 '12 at 19:04











          • If you want to sync the databases without a reload the full dataset, look into the tools pt-table-checksum and pt-table-sync. I wrote a script to automate that process using MAATKIT's mk-table-checksum and mk-table-sync : dba.stackexchange.com/a/8808/877

            – RolandoMySQLDBA
            Jan 4 '12 at 19:17













          • @RolandoMySQLDBA: As per my understanding, we can't start replication from the pointer where error log is showing as mysql has executed last point due to this error is related with duplicate key...here we have to skip this position as it has been executed....yes here Aglystas's concern is how can skip blindly so first we have to read binary logs and make sure that statement before this position and of this position has been executed on slave and the just next position sql is not updated till now, so we can skip 1 pointer here or use that position in change master to...

            – Zafar Malik
            Aug 18 '15 at 11:52













          • Also there should not any need of mysql service restart.

            – Zafar Malik
            Aug 18 '15 at 11:52

















          Thanks for all the help. I ended up using the Change Master command using a MASTER_LOG_POS that I knew would work, which is okay for now, but I will probably need to sync up the databases in the future.

          – Aglystas
          Jan 4 '12 at 19:04





          Thanks for all the help. I ended up using the Change Master command using a MASTER_LOG_POS that I knew would work, which is okay for now, but I will probably need to sync up the databases in the future.

          – Aglystas
          Jan 4 '12 at 19:04













          If you want to sync the databases without a reload the full dataset, look into the tools pt-table-checksum and pt-table-sync. I wrote a script to automate that process using MAATKIT's mk-table-checksum and mk-table-sync : dba.stackexchange.com/a/8808/877

          – RolandoMySQLDBA
          Jan 4 '12 at 19:17







          If you want to sync the databases without a reload the full dataset, look into the tools pt-table-checksum and pt-table-sync. I wrote a script to automate that process using MAATKIT's mk-table-checksum and mk-table-sync : dba.stackexchange.com/a/8808/877

          – RolandoMySQLDBA
          Jan 4 '12 at 19:17















          @RolandoMySQLDBA: As per my understanding, we can't start replication from the pointer where error log is showing as mysql has executed last point due to this error is related with duplicate key...here we have to skip this position as it has been executed....yes here Aglystas's concern is how can skip blindly so first we have to read binary logs and make sure that statement before this position and of this position has been executed on slave and the just next position sql is not updated till now, so we can skip 1 pointer here or use that position in change master to...

          – Zafar Malik
          Aug 18 '15 at 11:52







          @RolandoMySQLDBA: As per my understanding, we can't start replication from the pointer where error log is showing as mysql has executed last point due to this error is related with duplicate key...here we have to skip this position as it has been executed....yes here Aglystas's concern is how can skip blindly so first we have to read binary logs and make sure that statement before this position and of this position has been executed on slave and the just next position sql is not updated till now, so we can skip 1 pointer here or use that position in change master to...

          – Zafar Malik
          Aug 18 '15 at 11:52















          Also there should not any need of mysql service restart.

          – Zafar Malik
          Aug 18 '15 at 11:52





          Also there should not any need of mysql service restart.

          – Zafar Malik
          Aug 18 '15 at 11:52


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f10151%2fmysql-slave-replication-need-to-determine-where-replication-left-off-to-start-s%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Liste der Baudenkmale in Friedland (Mecklenburg)

          Single-Malt-Whisky

          Czorneboh