Rysnc Mirror two ispconfig server (web directory mainly)

Discussion in 'General' started by pebkac, May 27, 2010.

  1. pebkac

    pebkac Member HowtoForge Supporter

    Hey all,

    I need to mirror a production ISPCONFIG3 server to a backup server I have. I mainly just need the sites mirrored as I will use other methods to mirror the databases.

    I found a couple how to's but they were geared at Fedora.

    Any have a good tutorial for this?


    --Steve
     
  2. falko

    falko Super Moderator Howtoforge Staff

  3. Toucan

    Toucan Member

    I've just completed that howto and it works well on to an 'is mirror' server.

    Most of my sites are CMS based though which rely databases. I've seen the linked howtos using sql replication but they only seem to cover one database copies. What I want to do is copy all my joomla databases to the new server.

    Any ideas?
     
  4. mike_p

    mike_p Member

    I've successfully used rsync to keep a backup copy of all the mysql databases from one server on another.
    On only one occasion have I needed to run the mysql repair routine (using the free mysql administrator) - and the data was intact... only needed an index rebuilt.
     
  5. Toucan

    Toucan Member

    is it just an additional directory to mirror the mysql?
     
  6. mike_p

    mike_p Member

    I run a seperate rsync command to synchronise the entire mysql directory from the source server to a folder ('folderA') on my target server.

    I then run individual rysnc operations to synchonise the individual databases from folderA to the mysql database folders on the target machine.

    I've done it in two steps because I want to backup all the databases on the source server, but I only want some of the databases updated for live use on the target server.

    I've been running this system for a couple of years from a source server in Kansas to a target server in London Docklands! (Before I discovered ISPConfig!)
    -----
    The one small problem with this technique is that stored procedures/functions don't get sync'ed. (I don't sync the master mysql database itself where I guess they are stored)
     
  7. falko

    falko Super Moderator Howtoforge Staff

    You can replicate multiple MySQL databases. Just use multiple binlog_do_db statements in my.cnf.
     
  8. Toucan

    Toucan Member


    I'm not sure what you mean, could you point me in the right direction please?

    I'm also having trouble getting the mirror server to serve up the virtual host sites. Do I have to rsync the directories /etc/apache2/* ?

    I may have also asked this question in this thread:
    http://www.howtoforge.com/forums/showthread.php?t=46360

    If switch off the 'is mirror' function and then also create the site on the second server it resolve and serve it up
     
  9. falko

    falko Super Moderator Howtoforge Staff

    You need one binlog_do_db per database that you want to replicate, e.g.:
    binlog_do_db = db1
    binlog_do_db = db2
    binlog_do_db = db3
    ...
     
  10. Toucan

    Toucan Member

    Are these files where the actual databases stored and therefore i need to include them in the rsync command?

    If so, where do I locate them?
    I have had a gander around the file system but couldn't find anything that looked similar
     
  11. falko

    falko Super Moderator Howtoforge Staff

    You have to put these lines in your my.cnf.
     
  12. Toucan

    Toucan Member

    OK thanks Falko, I'm almost there i think.

    I've found my.cnf in /etc/mysql

    I have one on my master and mirror server.

    The section you are talking about looks like this:
    Code:
    #server-id              = 1
    #log_bin                        = /var/log/mysql/mysql-bin.log
    expire_logs_days        = 10
    max_binlog_size         = 100M
    #binlog_do_db           = include_database_name
    #binlog_ignore_db       = include_database_name
    
    1. Do I uncomment this section on the master or slave my.cnf file?
    2. Server ID relates to the server mysql to replicate yes? how do i find out the ID number?

    Thanks, much appreciated.
     
  13. falko

    falko Super Moderator Howtoforge Staff

  14. Toucan

    Toucan Member

    Falko, thanks. That tutorial worked really well and now I have one db mirroring perfectly.

    Now stage two, i need to get it to mirror more than one db. I think i understand most of it. When I add more db to the my.cnf file, do i repeat the line like this?
    Code:
    server-id               = 1
    log_bin                 = /var/log/mysql/mysql-bin.log
    expire_logs_days        = 10
    max_binlog_size         = 100M
    binlog_do_db            = exampledb
    binlod_do_db            =anotherdb
    
    and then same with the slave settings?

    After that follow most of the same process again?


    So now with rsync copying the content and this process replicating the databases, I need exactly the same users and permission. Is there any reason you can this of that I can't copy the mysql user db too? My mysql root user and password are exactly the same on both machines. The only extra user that the master has is the newly created 'slave_user'. Is there any reason why this won't work?

    I've tried adding users via phpmyadmin and tried giving them privelidges on dbs but when the CMS sites try to access them it throws an error??

    Thanks for the help so far, this is a real educator for me!
     
    Last edited: Jun 11, 2010
  15. Toucan

    Toucan Member

    I've been trying solidly to get two web sites to use two of the databases but every time the cms reports an error that I can't determine but the line does relate to the database.

    Static sites show fine on this slave server.

    The master and slave databases do seem in sync

    I've made a user identical (I think) to the master for host localhost and one for %

    I've given this user previliges on the slave to the db

    I can log in to phpmyadmin with this user and it displays the relevant db

    I've even restarted mysql to ensure priveliges are updated.

    Is there something I've missed?

    I plan to take the master offline tonight for maintenance and it would be ideal if the slave could take over for a couple of hours.
     
  16. falko

    falko Super Moderator Howtoforge Staff

    On the slave, you need one replicate-do-db line per database that you want to replicate.
     
  17. Toucan

    Toucan Member

    That bit I have sorted now. But do I have to go through the whole process off locking each database, taking the snapshot and importing it to the slave etc? Or will adding the lines be enough?

    As for the users, if I include that db too will it over write my slave users db or just insert the extra entries?

    Can you think of any reason why the cms sites aren't connecting to the databases on the slave?

    Sorry for so many questions all in one.
     
  18. falko

    falko Super Moderator Howtoforge Staff

    No, you just need to set one lock and then create dumps of all your databases and then remove the lock afterwards.
     
  19. Toucan

    Toucan Member

    OK thanks. I think I have replication sorted now.

    I'm still getting error with the CMS, but I get those problems whether the database is automatically replicated or if I have made a dump and imported it manually I so I don't think it's to do with this thread. So, to umcomplicated things, I'll open a separate thread.

    Thanks again for your patience.
     

Share This Page