Categories

Sunday, 16 November 2014

Steps to migrate Ubuntu Server to another Machine

Hi,

I have  a requirement in my organisation to replicate the  server environment running in  operating system ubuntu in kvm to another machine in vmware. The current machine contains applications like apache, trac, postgresql, svn etc. One solution for migration is to shutdown kvm machine. Then convert the kvm disk images of the machines to the vmware disks using vmware tools as mentioned in the post

http://syamkumar-linux.blogspot.in/2014/08/how-to-install-vmware-tools-and-convert.html

This process will take many hours to complete and the system will be down on that time. As it is a critical system, we cannot afford that much downtime. So I decided to use an alternative method. That is migration of ubuntu server to another one. Below are the steps for that.

1)First We need to find out the version of ubuntu running on the current machineu. This can be get using the command.

cat /etc/issue

Ubuntu 12.04.2 LTS \n \l

2)Then we need to create a machine in vmware with the same version of ubuntu as in the current machine and install the ubuntu on it.

3)Now on the source machine we need find out the list of packages installed on the source.

sudo dpkg --get-selections | sed "s/.*deinstall//" | sed "s/install$//g" > ~/pkglist


The above command will list all the installed packages on the source machine and will store it in the file pkglist

4)Now on the destination machine install the packages same as in the source machine. That can be done by copying the file pkglist to the destination machine using scp or rsync. The use the below command to install the packages .

sudo aptitude update && cat pkglist | xargs sudo aptitude install -y


Now we have same packages and services running on the destination machine as in the source machine.


5)Now we need to transfer the config file and data from the source machine to the destination machine using scp or rsync.

That is you need to rsync the apache directory, document roots, postgresql data directory, trac configuration file, and trac modules etc. Make sure that you need to shutdown the services before copying it.

Once it is done. All the services will run on the destination machine like in source machine. That is it will behave like the source machine.

If you have done this steps correctly your migration will be succesfull.


Thanks and Regards
Syamkumar.M

Friday, 14 November 2014

Command to reset the cpanel account password

Hi,

We can  reset the account password for the cpanel account by using commands. We usually do it by login to WHM interface and then use the modify account section. But this can be done simply using command line.
This post is usefull for some one who doesn't have a cpanel license on the server.


Below is the commands to reset the cpanel account password

1)First we need to change an environment variable in the current shell we are using export command

export ALLOW_PASSWORD_CHANGE=1

2)Then use the command

/scripts/chpass  username password 

This will change the account password

3)But the ftp password won't sync with the new update. So you need to run the below command to update it

/scripts/ftpupdate

Cheers
Syamkumar.M


Ad