Minimal rsync process for multinode web cluster

install rsync pkg if not installed on every node

yum install rsync

choose a “master node” to take code from, in our example we name it node1 and the others node2,3,4 etc

useradd rsyncuser
cat /home/ec2-user/.ssh/authorized_keys

copy the auth key inside

su rsyncuser
cd /home/rsyncuser
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys

paste the key in your clipboard

chmod 600 .ssh/authorized_keys

NODE 2,3,4
mkdir /root/keys
vi /root/keys/node1rsync.key

and copy inside your node1 ec2 private key

chmod 600 /root/keys/node1rsync.key

now you can launch an rsync command from node2,3,4 to node1 every X minutes

crontab -e

and add

*/X * * * * /usr/bin/rsync -avzhe "ssh -i /root/keys/nide1rsync.key" rsyncuser@NODE1_IP_OR_FQDN:/var/www/vhosts/ /var/www/vhosts/


Add and enable Swap on ec2 instance

To add this extra space to your instance you type:

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chown root:root /var/swap.1
sudo chmod 0600 /var/swap.1
sudo /sbin/swapon /var/swap.1

If you need more than 1024 then change that to something higher.

To enable it by default after reboot, add this line to /etc/fstab:

/var/swap.1 swap swap defaults 0 0

Set the Time for an Instance

Set the timezone

  1. open the timezone file: sudo vi /etc/sysconfig/clock and in “ZONE” row set your timezone (to view a list of timezones avalable lookup with a ll /usr/share/zoneinfo (and subdir)
  2. create a symlink to that file: sudo ln -sf /usr/share/zoneinfo/Europe/Rome /etc/localtime 
  3. reboot to be sure all services and applications are in sync

Set the ntp server

  1. by default amazon ec2 istances are fine with the ntp daemon but try this: sudo service ntpd status
  2. if is not running type: sudo service ntpd start (or restart)
    1. and be sure to run it at startup with: sudo chkconfig ntpd on
  3. check ntp is working and on wich servers with: ntpq -p