Creating a File Sync Between Web01 and Web02 - blake-anderson/SEC-440 GitHub Wiki

Creating a Sync Between Web01 and Web02

In order to get all the pages and comments that are uploaded to WordPress on web01 to web02, a file sync solution is needed.

Despite storing most things on the database, WordPress needs local copies of pages to properly display them.

Therefore, the local pages must be syncing to web02 so that it can properly display all pages in the event of web01 failing.

The solution to this will be to use Lsyncd, a file synchronization platform that uses rsync as it's backend.

Configuring SSH Keys

Lsyncd needs a working public/private SSH keypair in order to authenticate for syncing.

Generate the key-

ssh-keygen -t rsa

Save to the default location, set a password if you like.

Copy the key to the client machine-

ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]

Note: The IP in the command above is the target box that you want to add the key to!

There should be a message stating the key was copied. To test that the key is working, simply ssh into the box and you should login without providing any credentials!

Install Lsysncd

yum install lsyncd

The application is extremely simple, the configuration file is located at /etc/lsysncd.conf

The sample config file I used is located in this github repo-

https://github.com/blake-anderson/SEC-440/blob/master/lsyncd.conf

Once that config file is all set, simply run

systemctl restart lsyncd

The files should now be syncing without any errors. Check the logs at the directory you defined in the configuration if there are any problems.