Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql : How to synchronize databases after having been offline using replication?

I created a replication between two computers (a laptop I use to add new datas in my db and a server that save everything I do on the laptop) and it works fine. But today, my laptop was online so I was not able to update my server. Result : I updated some lines and I created a lot of lines and when my laptop was back online, the replication did not works on the datas I've been working on offline.

Could anybody give me an advice to update datas (on the server) that have been modified on the laptop while I was not connected ? I don't get why it doesn't works !

Thx !

update : here is my show slave status :

    mysql> show slave status;
+----------------------------------+-------------+-------------+-------------+--
-------------+------------------+---------------------+-------------------------
---+---------------+-----------------------+------------------+-----------------
--+-----------------+---------------------+--------------------+----------------
--------+-------------------------+-----------------------------+------------+--
----------+--------------+---------------------+-----------------+--------------
---+----------------+---------------+--------------------+--------------------+-
-------------------+-----------------+-------------------+----------------+-----
------------------+-------------------------------+---------------+-------------
--+----------------+----------------+-----------------------------+-------------
-----+
| Slave_IO_State                   | Master_Host | Master_User | Master_Port | C
onnect_Retry | Master_Log_File  | Read_Master_Log_Pos | Relay_Log_File
   | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Runnin
g | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignor
e_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | L
ast_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Conditi
on | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File |
Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seco
nds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Erro
r | Last_SQL_Errno | Last_SQL_Error | Replicate_Ignore_Server_Ids | Master_Serve
r_Id |
+----------------------------------+-------------+-------------+-------------+--
-------------+------------------+---------------------+-------------------------
---+---------------+-----------------------+------------------+-----------------
--+-----------------+---------------------+--------------------+----------------
--------+-------------------------+-----------------------------+------------+--
----------+--------------+---------------------+-----------------+--------------
---+----------------+---------------+--------------------+--------------------+-
-------------------+-----------------+-------------------+----------------+-----
------------------+-------------------------------+---------------+-------------
--+----------------+----------------+-----------------------------+-------------
-----+
| Waiting for master to send event | ***.***.***.*** | masterRepli |        3306 |
          60 | mysql-bin.000027 |              454717 | aofr19072-relay-bin.0000
02 |          1227 | mysql-bin.000027      | Yes              | Yes
  |                 |                     |                    |
        |                         |                             |          0 |
          |            0 |              454717 |            1387 | None
   |                |             0 | No                 |                    |
                   |                 |                   |                |
                0 | No                            |             0 |
  |              0 |                |                             |
   2 |
+----------------------------------+-------------+-------------+-------------+--
-------------+------------------+---------------------+-------------------------
---+---------------+-----------------------+------------------+-----------------
--+-----------------+---------------------+--------------------+----------------
--------+-------------------------+-----------------------------+------------+--
----------+--------------+---------------------+-----------------+--------------
---+----------------+---------------+--------------------+--------------------+-
-------------------+-----------------+-------------------+----------------+-----
------------------+-------------------------------+---------------+-------------
--+----------------+----------------+-----------------------------+-------------
-----+
1 row in set (0.00 sec)
like image 617
beluga Avatar asked Feb 23 '23 13:02

beluga


2 Answers

BRUTE FORCE SYNC

I wrote out a detailed description on how to resync a Slave to its Master in a Circular Replication setup

PRECISION STRIKE SYNC

If you simply want to find the differences and update only differences, you must use mk-table-checksum and mk-table-sync.

Give it a Try !!!

like image 144
RolandoMySQLDBA Avatar answered Apr 27 '23 10:04

RolandoMySQLDBA


Is it possible that the slave server just doesn't have the slave process running?

See if the slave process is running by typing SHOW SLAVE STATUS; at the MySQL command prompt on the slave.

Then try starting it with START SLAVE;

If it still isn't working, post the output of the SHOW SLAVE STATUS; command, and we'll try to help you further :)

like image 28
Dave Rix Avatar answered Apr 27 '23 08:04

Dave Rix