User Tools

Site Tools


databases:replicarestore

Replica restore

First thing

Verify on the sysmgmt wich server is affected (if master or slave) on the “Hosts & Components” section; it will be marked as “down” or “out of sync”, in the former case verify first that the machine is up and running.

For both MySQL and MongoDB there is always a “Master” and “Slave”, make sure to check who is who before proceeding.


MySQL

This works for both Config(Config1/Config2) and Reporting(DB1/DB2) DBs.


  1. Login to both machines (SSH)
  2. On Slave login into mysql interface:
    mysql -u super -p*password*
  3. On Slave show slave status with the following myslq command:
    SHOW SLAVE STATUS;
  4. On Master stop all BP services with:
    /usr/lib/servicepattern/setup/sp_servers.sh stop
  5. On Slave stop slave with the following mysql command and exit:
    STOP SLAVE;
    EXIT;
  6. Choose a proper position for this file: it's very big, mind to check disk space before a mysqldump:

'df -h' → this is to check disk utilization and where a disk is mounted,

for example, if we see the following situation:

    
Filesystem      Size  Used Avail Use% Mounted on
    
Disk1           100G  73G  27G   73%  /
Disk2           300G  30G  270G  10%  /mnt
    
    
Is much better to put the backup in the second disk, so anywhere in the /mnt folder.
(**This is only an example, you will not see those disks in the actual machines**)
  1. Make a mysql backup of Master (the “healthy” one) on Slave (this way is much faster, in alternative you would have to make the backup on Master, download it and re-upload it on Slave, this operation could take several hours instead of a couple of minutes) with the following command:
    mysqldump -u super -p*password* --host=*DB1 hostname* --all-databases > /*path*/*to*/*file*.sql
  2. Reconnect to mysql console on Slave (command from step 2)
  3. See wich dbs exist and drop everything except “information_schema”, “performance_schema” and “mysql” with the following commands:
    SHOW databases;
    DROP DATABASE *database name*;
  4. Exit from mysql and load the backup you have done previously of Master in Slave with the following command:
    mysql -u super -p*password* < /*path*/*to*/*file*.sql
  5. Login to mysql on both Master and Slave (command from step 2)
databases/replicarestore.txt · Last modified: by sysadm

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki