Move to Cloud
Currently reading: Programming Amazon EC2.
Setup
One tiny instance will run all the live sites, another tiny instance will be used for development. This will also host a Git server.
Cost
http://calculator.s3.amazonaws.com/calc5.html
Just messing around with the calculator, I can get a pretty sweet setup for less than $25 a month. If I run everything on a single micro instance, it's free.
Plan
- Get a tiny instance up and running with a lamp stack
- Buy a test domain from Amazon and get that hooked up
- Terminate it and make sure the EBS volume sticks around
- Reattach the volume to a new instance
- Try attaching the volume to larger instance.
- Transfer the sites over (data)
- Confirm everything is up, running and works
- Transfer domains
- Try to figure out SSL
Also try
- Put the database (data) on a separate EBS volume
- Try running that volume on a separate instance (one for apache, one for MySql) - this would allow a lot of scaleability
- Running FTP server
- Running GIT
- AWS command line tools
Registrars
http://lifehacker.com/5943452/five-best-domain-name-registrars
Should move away from Dot 5, just not what I need.
To Do
- How to backup/restore an image
- I should really learn vim
- https?
- if I run my own DB, how does load balancing work (I can always just use the Amazon services)
- Can I install command line tools on an instance - then I can have one instance controlling others
- http://aws.amazon.com/articles/1663
- Rebooting
- Do all the necessary services start automatically
- Does the database attach correctly
- Can I create a script to attach the database
- Scripts
- Create Server
- Can I fully automate tasksel
- Can I pass in my passwords as arguments?
- Restore Server
- Move DB to new machine
- Move webserver to new machine
- Move DB back to main machine
- Create Server
Notes
startup script (for ubuntu) in /etc/init.d/ec2 and to make sure it's run at startup, "update-rc.d ec2 defaults"
Tools and Setup
Server Type
I've been using Ubuntu server, and that seems to be work very well. The only quirk (and perhaps not a bad one) is that the system does not allow you to log in as root, you must instead issue sudo.
Update
Do this first. Do it.
sudo apt-get update
Server Setup
Tasksel seems to be a good tool for system setup and is already installed in Ubuntu, just run "sudo tasksel".
More here: http://www.unixmen.com/install-lamp-with-1-command-in-ubuntu-1010-maverick-meerkat/
Webmin
Note, the initial attempt to install webmin will fail, but it will tell apt what it needs to finish. When the apt-get -f install command is run, it will get everything and install webmin.
http://www.webmin.com/deb.html
- wget http://prdownloads.sourceforge.net/webadmin/webmin_1.610_all.deb
- sudo dpkg --install webmin_1.610_all.deb
- sudo apt-get -f install
- sudo ufw allow 10000
- sudo sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
- sudo /usr/share/webmin/changepass.pl /etc/webmin root PASSWORD
- sudo /etc/webmin/restart
PhpMyAdmin
sudo apt-get install phpmyadmin
AWS Command Line Tools
http://alestic.com/2012/05/aws-command-line-packages
Attaching Database Volume
Through UI
- Attach a volume through AWS interface
- sudo parted /dev/DEVICE
- mklabel msdo
- mkpart primary 1 -1
- quit
- sudo mkfs.ext4 /dev/DEVICE1
- sudo mkdir -m 000 /vol
- sudo mount /dev/DEVICE1 /vol
- sudo /etc/init.d/mysql stop
- sudo mkdir /vol/etc /vol/lib /vol/log
- sudo mv /etc/mysql /vol/etc/
- sudo mv /var/lib/mysql /vol/lib/
- sudo mv /var/log/mysql /vol/log/
- sudo mkdir /etc/mysql /var/lib/mysql /var/log/mysql
- sudo /etc/init.d/mysql start
Through CLI
http://aws.amazon.com/articles/1663
- availabilityZone=`wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone`
- volumeId=`ec2-create-volume -z $availabilityZone -s 8 | grep -Eo 'vol-\w{8}'`
- instanceId=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`
- ec2-attach-volume $volumeId -d /dev/xvdf -i $instanceId
- parted /dev/xvdf --script -- mklabel msdos
- parted /dev/xvdf --script -- mkpart primary 1 -1
- mkfs.ext4 /dev/xvdf
VNC Setup
- Update the system
- Install a desktop either through tasksel or sudo apt-get install ubuntu-desktop
- sudo apt-get install vnc4server
- vncserver :1
- vncserver -kill :1 (starting and stopping it generates some necessary files
- sudo pico ~/.vnc/xstartup
- Erase the last two lines
- add "gnome-session &" at the end
- sudo passwd ubuntu
- vncserver :1
- Open ports 5900-5910
- Connect! I recommend Remmina (or RealVNC for windows)
Blender
Still don't have this working, but http://www.noobslab.com/2011/09/nvidia-drivers-for-ubuntu-1110-oneiric.html got me past the first set of errors.
Server Setup with Script
- Upload aws.tar.gz
- pscp -i minecraft.ppk aws.tar.gz ubuntu@54.235.214.84:
- scp -i Minecraft.pem aws.tar.gz ubuntu@54.235.214.84:
- tar -zxvf aws.tar.gz
- wget projects.adamcolton.net/startup/webServer.sh
- sudo chmod u+x webServer.sh
- sudo bash webServer.sh
- source $HOME/.bashrc
PuTTY Notes
To make the display cleaner, in Window > Appearance change the font to Courier New and in Window > Translation change the remote character set to UTF-8.