Migrate sbarjatiya.com VM

From Notes_Wiki
Revision as of 14:24, 14 February 2016 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>New_machine_configuration|New machine configuration</yambe:breadcrumb> =Migrate sbarjatiya.com VM= ==VM creation on AWS== # Create a new AWS account # Creat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>New_machine_configuration|New machine configuration</yambe:breadcrumb>

Migrate sbarjatiya.com VM

VM creation on AWS

  1. Create a new AWS account
  2. Create a CentOS 6.0 VM with updates
  3. 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
  4. Obtain a elastic IP and associate with the VM
  5. Add entry in /etc/hosts of current machine with appropriate name for new elastic IP
  6. SSH to VM
  7. Fully update the VM to latest packages
  8. Create partition /documents_raw with 10G or more space
  9. Reboot the VM


Package installations

  1. yum -y install vim parted epel-release wget
  2. Setup rpmfusion-free and non-free
  3. yum -y install ecryptfs-utils
  4. mount -t ecryptfs /documents_raw /documents
    • Choose reasonable passphrase and accept all other defaults (aes, keybytes=16)
  5. Set desired hostname using hostname command and by editing /etc/sysconfig/network file
  6. Copy saurabh@labpc ssh public key as authorized on new server
  7. Copy old servers public key as authorized on new server
  8. Create /etc/hosts entry on old server for pointing to new server
  9. rsync /documents from old server to new server
  10. setenforce 0 on new server
  11. edit /etc/sysconfig/selinux and set SELINUX=disabled on new server
  12. cp /etc/profile.d/history.sh from old server to new


Copy user accounts and home folders

  1. rsync /etc/{passwd,shadow,group} to new server
  2. rsync /home to new server
  3. rsync -vtrp /root/ to new server
    • Note this will overwrite history and .ssh configuration of root user
  4. vim /etc/ssh/sshd_config
    • Allow root ssh with password
  5. service sshd restart


Configure email system

  1. service postfix stop
  2. chkconfig postfix off
  3. yum -y install sendmail
  4. 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
  5. service sendmail start
  6. chkconfig sendmail on
  7. Copy {/etc/mail/,/etc/aliases,/etc/hosts} from old server to new
  8. newaliases
  9. cd /etc/mail; make
  10. service sendmail restart


Configure web server

  1. yum -y install mod_ssl php-mysql php-pdo php-xml php
  2. rsync -vtrp /etc/httpd/{conf,conf.d} from old server to new
  3. service httpd restart
  4. chkconfig httpd on


Install and configure erlang/yaws

  1. yum -y install erlang gcc pam-devel
  2. Download yaws sources and install it via ./configure; make; make install
    • make test fails but yaws seems to work
  3. su - sbarjatiya
  4. cd ~/erlang/applications/interpreter; erlc *.erl
  5. cd ~/erlang/applications/wol_application; erlc *.erl
  6. cd ~/erlang/erlangcentral.com; erlc *.erl
  7. vim start_yaws.sh
    • Replace old hostname with new hostname
  8. vim start_applications.erl
    • Replace old hostname with new hostname
  9. erlc *.erl
  10. ./start_yaws.sh
  11. yaws --ls
  12. exit from sbarjatiya user


Configure DNS

  1. yum -y install bind bind-utils
  2. rsync -vaH /etc/named.conf to new server
  3. rsync -vaH /var/named/* to new server /var/named
  4. service named start
  5. chkconfig named on


Configure MySQL and migrate databases

  1. yum -y install mysql-server
  2. service mysqld start
  3. look at /documents/public_html/notes_wiki/LocalSetting.php file for MySQL credentials
  4. Create cooresponding db
  5. Create correspoding user with same password and grant all to created db. Remember to 'flush privileges;'.
  6. yum -y install sshpass
  7. run /documents/public_html/import_notes_database.sh


Configure AWStats, copy old logs

  1. yum -y install awstats perl-Geo-IP
  2. copy
    • /etc/awstats
    • /var/lib/awstats
    • /var/log/httpd
    from old server to new server
  3. 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
  4. service httpd restart


Copy firewall, change DNS and check things

  1. copy /etc/sysconfig/iptables from old server to new
  2. Note old public IP and new public IP properly
  3. Add /etc/hosts entry for old public IP
  4. Change DNS as follows on godaddy.com:
    • rekallsoftware.com :: @
    • energyconservationclub.in :: @
    • erlangcentral.com :: @
    • pbarjatiya.com :: @
    • sbarjatiya.com :: @
  5. Shutdown old VM (Do not release elastic IP yet)
  6. Check following URLs:
  7. Send email to saurabh@sbarjatiya.com, saurabh@energyconservationclub.in
  8. Release elastic IP from old VM
  9. Update ssh known_hosts keys on rekallcm1 for sbarjatiya.com and www.sbarjatiya.com.
  10. Take one full backup.


<yambe:breadcrumb>New_machine_configuration|New machine configuration</yambe:breadcrumb>