Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How sync webservers each other
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How sync webservers each other

sepeisepei Member

Hello,

I got some webservers and I want to sync each other.
it should be
-Master
-Slave
-Slave
-...

So changes will just happen on the master and the slaves should sync.
It should also be possible to change the master.
How I can do this?

Comments

  • Use http://syncthing.net/ or RSync to sync files and MariaDB for SQL

    Thanked by 1cassa
  • wychwych Member
    edited August 2014

    Rsync/Mysql cluster depending what you mean by "webserver"

  • mikhomikho Member, Host Rep

    I did setup the wiki for LES using rsync to sync data between the sifferent locations.

    There is a page about the setup @ wiki.lowendguide.com

    Feel free to copy it.
    There is no DB sync however.

  • what is your definition of webserver?
    a sql database?
    some php files?
    some normal files?
    jeez

  • Now all files are static so no DB now. But also how I can sync MariaDBs?

  • sepei said: Now all files are static so no DB now.

    If only files, it is too easy. Use rsync for the folders you want to sync (do not sync critical OS folders and files, because each machine is differend and it can brake your configuration).

    A simple approach:

    rsync -avz /the/directory/you/want/to/sync/* [email protected]:/the/destination/ .

    Put this in a cron every 5 minutes or what is working for you.

    But first, generate keys to let master connect with slaves without the need of passwords (see this https://digitalocean.com/community/tutorials/how-to-copy-files-with-rsync-over-ssh )

    On the other hand, database is more complicated. You cannot just copy files, this will corrupt the database in slave. You have to do periodic db replication for large dbs or dump the database from time to time, transfer it to the slaves and import it there, for smaller databases.

    Thanked by 1Mark_R
  • If you need to sync only files, there are different approaches to do this.

    You can set up filesystem like tahoe-lafs between servers, or you can use instant sync like syncthing, csync2, lsyncd, lipsyncd.

  • Rsync and other 1-way copies may not be sufficient if files can be created on the slaves and need to be synced back - upload media on WordPress isn't guaranteed to hit any particular server.

    We've tried most of the software @ValdikSS suggested (and Unison too) and recently migrated to GlusterFS with it configured to pull from itself when possible. So far, so good.

  • joshin said: Rsync and other 1-way copies may not be sufficient if files can be created on the slaves and need to be synced back - upload media on WordPress isn't guaranteed to hit any particular server.

    There are several approaches to this. It depends of the need (mirroring, 2-way syncing etc.) I thing OP wants a simple approach, without even DB replication.

Sign In or Register to comment.