Oct 302011
 
Moving Servers

Moving servers from Strato (can’t complain, good enough service, nothing ever broke, few but regular planned outages, and not expensive either), to Linode (quite a bit more expensive for the same performance, but less performance is ok too, so it’s about the same price). The main advantage of Linode is the location: Tokyo.

Main differences:

  • Location Germany vs Japan
  • Ping round trip from home decreased from 310ms to 30ms (and 18ms is my ADSL line already)
  • CPU changed from 1 core Opteron 2347 HE to 4 core Xen L5520 (but in reality it’s only 1 core anyway, however the new one is about 3 times faster according to http://www.webhostingtalk.com/showthread.php?s=&threadid=308055)
  • RAM decreased from 2GB to 0.5GB (but I only use about 0.4GB anyway)
  • Disk size decreased from 80GB incl. backup plus 80GB ftp, to 20GB and no backups
  • Data traffic decreased from 3TB to 200GB (but I never crossed 100GB)
  • Virtualizer changed from Virtuozzo to Xen
  • I now have some transparency about oversubscription of the underlying server
  • DNS is totally different: Strato uses a simple wildcard scheme: anything with *.studiokubota.com is pointing to the server. Linode uses a more traditional scheme where I need to define those DNS entries manually. But now I have control about it and can point hosts in my domain to any IP I like.
  • IP addresses decreased from 2 to 1 (but I used the extra IP only for VPN)
  • I need to use another registrar (I actually don’t need to, but it’s much cheaper if I do)

As you can see, it’s a mixed bag, but I am, generally ok although I’ll lose the ability to do proxy services in Germany, which allowed me to see some content some companies like to prohibit me from watching (streaming movies).

As a reminder to myself, here the additional commands/configs I had to do to move the server with all stuff I need:

# This is pretty much copy & paste. Run as root on the new server.
OLD=the.old.server
NEW=the.new.server
MYSQLPASSWORD=THEMYSQLPASSWORD

# User accounts

# Add encrypted password
echo >>/etc/passwd "harald:*:2000:100:Harald Kubota:/home/harald:/bin/bash"
# Copy root .ssh directory from old server

cd ~root

rsync -av $OLD:~root/.ssh .
# Install packages
aptitude update
aptitude full-upgrade
aptitude install locate
aptitude install apache2 imagemagick openvpn  gcc rsnapshot
aptitude install libapache2-mod-perl2 libapache2-mod-php5 libapache2-mod-perl2-doc
aptitude install phpmyadmin bsd-mailx
aptitude install postfix spamassassin procmail dovecot-common dovecot-imapd
# Configure postfix as Internet site with its local name as hostname

aptitude install mysql-server

# Set mysql "root" password, do not initialize the DB beside creating it

# Installing MT5 support files

aptitude install php5

aptitude install bsd-mailx exim4 libsoap-lite-perl libdbi-perl libimage-size-perl \
libmime-charset-perl libmime-encwords-perl perlmagick libxml-libxslt-perl \
 libxml-simple-perl libxml-libxml-perl libmime-tools-perl
aptitude install libgd-gd2-perl libio-compress-zlib-perl libarchive-any-perl
# copy /var/www

rsync -avz --progress $OLD:/var/www/ /var/www/

# For test purposes, create a symbolic link to one of the existing web pages

cd /var/www
ln -s harald.studiokubota.com $NEW

# Copy apache config

rsync -av $OLD:/etc/apache2/ /etc/apache2/

# Copy backup job from /etc/cron.daily/

rsync -av $OLD:/etc/cron.daily/mysqldump /etc/cron.daily/

# Mail: postfix, dovecot, spamassassin

rsync -av $OLD:/etc/postfix /etc/
# Modify main.cf to contain all domain names and fix the hostname too
# Also add virtual names and rebuild via
postmap /etc/postfox/virtual

rsync -av $OLD:/etc/dovecot /etc/
rsync -av $OLD:/etc/spamassassin /etc/
rsync -ac $OLD:/etc/default/spamassassin /etc/default/

mkdir /var/log/spamassassin
groupadd spamd
useradd -d /var/log/spamassassin -M -g spamd -s /bin/false spamd
chown spamd:spamd /var/log/spamassassin

# To learn ham/spam by putting spam in Spam and ham in Ham, add those to your user crontab:
#10 19 * * * sudo sa-learn --spam -u spamd --dir /home/harald/Maildir/.Spam/* -D
#10 20 * * * sudo sa-learn --ham -u spamd --dir /home/harald/Maildir/.Ham/* -D

# On both servers stop spamassassin and copy the DB over
ssh $OLD "service spamassassin stop"
service spamassassin stop
rsync -av $OLD:/var/log/spamassassin .
# Start spamassassin again
ssh $OLD "service spamassassin start"
service spamassassin start
service postfix restart
service dovecot restart

# Restore mysql DB

d=`date +%d`
cat >/tmp/dump.sh <<EOF
FN="/var/tmp/dbdump-${d}.bz2"
rm -f "\$FN"
mysqldump -p$MYSQLPASSWORD --all-databases | bzip2 -9 >\$FN
EOF
scp /tmp/dump.sh $OLD:/var/tmp/
ssh $OLD "bash /var/tmp/dump.sh"

# Restore on NEW server

rsync -av --progress $OLD:/var/tmp/dbdump-${d}.bz2 /var/tmp/
bunzip2 </var/tmp/dbdump-${d}.bz2 | mysql -u root -p
mysqladmin -p$MYSQLPASSWORD flush-privileges

# Other things

rsync -av --progress $OLD:/etc/openvpn /etc/
rsync -av --progress $OLD:/etc/default/openvpn /etc/default/

Files to modify manually later:

  • /etc/openvpn/openvpn.conf
  • some more files in /etc/openvpn to create/configure (it’s obvious), and adjust the files on the VPN client too