Migrate sbarjatiya.com VM
From Notes_Wiki
<yambe:breadcrumb>New_machine_configuration|New machine configuration</yambe:breadcrumb>
Migrate sbarjatiya.com VM
VM creation on AWS
- Create a new AWS account
- Create a CentOS 6.0 VM with updates
- Configure security group with same rules as existing VM. That is access to
- SSH
- HTTP, HTTPS
- SMTP, SMTPS, POP3, POP3S, IMAP, IMAPS
- DNS (UDP)
- ICMP echo-request, ICMP echo-reply
- TCP ports 100, 200, 300, 400 from anywhere
- Obtain a elastic IP and associate with the VM
- Add entry in /etc/hosts of current machine with appropriate name for new elastic IP
- SSH to VM
- Fully update the VM to latest packages
- Create partition /documents_raw with 10G or more space
- Reboot the VM
Package installations
- yum -y install vim parted epel-release wget
- Setup rpmfusion-free and non-free
- yum -y install ecryptfs-utils
- mount -t ecryptfs /documents_raw /documents
- Choose reasonable passphrase and accept all other defaults (aes, keybytes=16)
- Set desired hostname using hostname command and by editing /etc/sysconfig/network file
- Copy saurabh@labpc ssh public key as authorized on new server
- Copy old servers public key as authorized on new server
- Create /etc/hosts entry on old server for pointing to new server
- rsync /documents from old server to new server
- setenforce 0 on new server
- edit /etc/sysconfig/selinux and set SELINUX=disabled on new server
- cp /etc/profile.d/history.sh from old server to new
Copy user accounts and home folders
- rsync /etc/{passwd,shadow,group} to new server
- rsync /home to new server
- rsync -vtrp /root/ to new server
- Note this will overwrite history and .ssh configuration of root user
- vim /etc/ssh/sshd_config
- Allow root ssh with password
- service sshd restart
Configure email system
- service postfix stop
- chkconfig postfix off
- yum -y install sendmail
- verify in /etc/hosts first line has 127.0.0.1 <hostname> where hostname matches output of hostname command. There can be other names after hostname but first value should be hostname
- service sendmail start
- chkconfig sendmail on
- Copy {/etc/mail/,/etc/aliases,/etc/hosts} from old server to new
- newaliases
- cd /etc/mail; make
- service sendmail restart
Configure web server
- yum -y install mod_ssl php-mysql php-pdo php-xml php
- rsync -vtrp /etc/httpd/{conf,conf.d} from old server to new
- service httpd restart
- chkconfig httpd on
Install and configure erlang/yaws
- yum -y install erlang gcc pam-devel
- Download yaws sources and install it via ./configure; make; make install
- make test fails but yaws seems to work
- su - sbarjatiya
- cd ~/erlang/applications/interpreter; erlc *.erl
- cd ~/erlang/applications/wol_application; erlc *.erl
- cd ~/erlang/erlangcentral.com; erlc *.erl
- vim start_yaws.sh
- Replace old hostname with new hostname
- vim start_applications.erl
- Replace old hostname with new hostname
- erlc *.erl
- ./start_yaws.sh
- yaws --ls
- exit from sbarjatiya user
Configure DNS
- yum -y install bind bind-utils
- rsync -vaH /etc/named.conf to new server
- rsync -vaH /var/named/* to new server /var/named
- service named start
- chkconfig named on
Configure MySQL and migrate databases
- yum -y install mysql-server
- service mysqld start
- look at /documents/public_html/notes_wiki/LocalSetting.php file for MySQL credentials
- Create cooresponding db
- Create correspoding user with same password and grant all to created db. Remember to 'flush privileges;'.
- yum -y install sshpass
- run /documents/public_html/import_notes_database.sh
Configure AWStats, copy old logs
- yum -y install awstats perl-Geo-IP
- copy
- /etc/awstats
- /var/lib/awstats
- /var/log/httpd
- from old server to new server
- Run following:
- wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
- gunzip GeoLiteCity.dat.gz
- mkdir /usr/local/share/GeoIP
- mv -f GeoLiteCity.dat /usr/local/share/GeoIP
- chmod -R 755 /usr/local/share/GeoIP
- service httpd restart
Copy firewall, change DNS and check things
- copy /etc/sysconfig/iptables from old server to new
- Note old public IP and new public IP properly
- Add /etc/hosts entry for old public IP
- Change DNS as follows on godaddy.com:
- rekallsoftware.com :: @
- energyconservationclub.in :: @
- erlangcentral.com :: @
- pbarjatiya.com :: @
- sbarjatiya.com :: @
- Shutdown old VM (Do not release elastic IP yet)
- Check following URLs:
- Send email to saurabh@sbarjatiya.com, saurabh@energyconservationclub.in
- Release elastic IP from old VM
- Update ssh known_hosts keys on rekallcm1 for sbarjatiya.com and www.sbarjatiya.com.
- Take one full backup.
<yambe:breadcrumb>New_machine_configuration|New machine configuration</yambe:breadcrumb>