Hacker News new | ask | show | jobs
by rythie 6148 days ago
It's really something that is specific to what we do and I had/have no intention of making it generic or let alone designing the type of thing that helps people who don't have experience doing sys admin - because I want to stay focused. For those that are interested these are the main techniques I use:

First I go to slicehost and create a machine, they send me a email when it's done (about 5 mins or so).

I have one install script and a syncing script, The install scripts one calls the sync script. After the machine is live I just use the sync one to update it. $hostname is the name or IP address of the new machine.

First I copy SSH authorization over, so I can login without a password (assumes you have created SSH keys already - which is one time event):

ssh root@$hostname "mkdir /root/.ssh; echo \"`cat /root/.ssh/id_dsa.pub`\" > /root/.ssh/authorized_keys2"

Then run various commands on the new machine. I put these in a file "commands.fragment". which contains things like

  mkdir /var/www

  groupadd -g600 web

  chgrp web /var/www

  yum -y install iptables ntp
and so on, then run it:

  cat commands.fragment | ssh root@$hostname
The I run the syncing script (which I'll rerun over the life of the machine) Then I sync my code across:

  rsync -avz -e ssh /var/www/ root@$hostname:/var/www/
and programs I've complied:

  rsync -avz -e ssh /usr/local/ root@$hostname:/usr/local/
and so on.

Now we have everything in place we can start the services for whatever the box does, for example to start a web server:

  ssh root@$hostname "/sbin/chkconfig --add lighttpd; /etc/init.d/lighttpd start"
And that's it.

My script took me a few hours to write and I did so that I can scale up (and down) in a hurry by adding a machine rather than taking the existing machines (there are 2) down whilst slicehost resize it - which is not something I wanted do while there is a lot of traffic coming in. We don't really need multiple machines, but buying one big slice is expensive to have running the whole time.

Hope that helps.

1 comments

Thanks for the excellent follow up! It sure helps.