Difference between revisions of "Migrate sbarjatiya.com VM"
From Notes_Wiki
(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...") |
m |
||
Line 4: | Line 4: | ||
==VM creation on AWS== | ==VM creation on AWS== | ||
# Create a new AWS account | # Create a new AWS account | ||
# Create a CentOS | # Create a CentOS 7.x VM with updates VM is same region and availability zone as previous VM with. Disk space should be at least same as previous VM. | ||
# Obtain a elastic IP and associate with the VM | # Obtain a elastic IP and associate with the VM | ||
# Add entry in /etc/hosts of current machine with appropriate name for new elastic IP | # Add entry in /etc/hosts of current machine with appropriate name for new elastic IP (eg newcommonhosting) | ||
# SSH to VM | # Log into older AWS account using private browser | ||
# Add entry in /etc/hosts of previous VM with appropriate name for previous elastic IP (eg oldcommonhosting) | |||
# SSH to oldVM | |||
# Set correct hostname using | |||
#:<pre> | |||
#:: hostname oldcommonhosting | |||
#:</pre> | |||
# Update /etc/hostname with oldcommonhosting name | |||
# Exit from SSH and reconnect and verify oldcommonhosting name appears | |||
# SSH to new VM using centos and root may not work | |||
# Do "sudo su -" on new VM to get root console | |||
# Install vim | |||
#:<pre> | |||
#:: yum -y install vim | |||
#:</pre> | |||
# Set correct hostname in /etc/hostname | |||
# Set hostname for current run | |||
#:<pre> | |||
#:: hostname newcommonhosting | |||
#:</pre> | |||
# Edit /root/.ssh/authorized_keys and allow direct root ssh (150x on first line) | |||
#:Also copy saurabh@labpc as authorized on new VM root account | |||
# Exit from new VM and SSH again as root without using any additional identity apart from saurabh@labpc. Verify newcommonhosting name appears. | |||
# Fully update the VM to latest packages | # Fully update the VM to latest packages | ||
# Create | #:<pre> | ||
# Reboot the VM | #:: yum -y update --skip-broken | ||
#:</pre> | |||
# Create swap file as mentioned at [[CentOS 7.x adding swap space using file]] | |||
# Configure security group commonhosting-sg with same rules as existing VM. That is access to | |||
#* SSH (22) | |||
#* HTTP (80), HTTPS (443) | |||
#* SMTP (25), SMTPS (465) | |||
#* Custom Alt-web (8080) | |||
#* ICMP echo-request | |||
#:from anywhere | |||
# Reboot the new VM | |||
Revision as of 13:19, 12 August 2018
<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 7.x VM with updates VM is same region and availability zone as previous VM with. Disk space should be at least same as previous VM.
- Obtain a elastic IP and associate with the VM
- Add entry in /etc/hosts of current machine with appropriate name for new elastic IP (eg newcommonhosting)
- Log into older AWS account using private browser
- Add entry in /etc/hosts of previous VM with appropriate name for previous elastic IP (eg oldcommonhosting)
- SSH to oldVM
- Set correct hostname using
- hostname oldcommonhosting
- Update /etc/hostname with oldcommonhosting name
- Exit from SSH and reconnect and verify oldcommonhosting name appears
- SSH to new VM using centos and root may not work
- Do "sudo su -" on new VM to get root console
- Install vim
- yum -y install vim
- Set correct hostname in /etc/hostname
- Set hostname for current run
- hostname newcommonhosting
- Edit /root/.ssh/authorized_keys and allow direct root ssh (150x on first line)
- Also copy saurabh@labpc as authorized on new VM root account
- Exit from new VM and SSH again as root without using any additional identity apart from saurabh@labpc. Verify newcommonhosting name appears.
- Fully update the VM to latest packages
- yum -y update --skip-broken
- Create swap file as mentioned at CentOS 7.x adding swap space using file
- Configure security group commonhosting-sg with same rules as existing VM. That is access to
- SSH (22)
- HTTP (80), HTTPS (443)
- SMTP (25), SMTPS (465)
- Custom Alt-web (8080)
- ICMP echo-request
- from anywhere
- Reboot the new 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>