Thursday, January 12, 2012

Reset root password for Xen Virtual Machine.


If we want to reset password for the vm named "problem.vm"


1.Check whether the vm is running or not.


root@main#xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0     1024     8 r----- 689689.3
problem                                    0     1024     8 r----- 425100.8


2. Locate the configuration file for the vm. Mostly the config paths will be /etc/xen/

root@main#vi /etc/xen/problem.cfg


you can find the path of the disk image of the particular xen vm.


for ex:
disk = ['phy:/dev/VolGroup01/xenvpsa_rootimg,sda1,w',
'phy:/dev/VolGroup01/xenvps_vmswap,sda2,w']


The above lines meant that the disk image path is "/dev/VolGroup01/xenvpsa_rootimg".


3. Mount that disk image in anothe place. Just create a folder named test and mount the image.


root@main#mkdir /test
root@main#mount /dev/VolGroup01/xenvpsa_rootimg /test


4.Change the root environment to the mounted image using chroot command.


root@main#chroot /test


5.Chnage the password as ususual using passwd command


root@problem#passwd root


passwd: Authentication token lock busy
passwd: password unchanged


If you receive this error while changing the password. follow below steps.


mount -o remount,rw / 
then try changing the root password.


If you still not able to reset.


pwconv /etc/passwd 


surely you will be able to change root password.


6. exit the chrooted environment.


The above steps are necessary only if you are not able to boot the VM in single user mode. Xen vm can boot in to single user mode.


root@main#xm create -c /etc/xen/problem.cfg


you will be showed the grub menu to select Kernels to start boot, here you can use the linux single method to boot in to the single user mode.


If you have file system errors, you cannot enter in to the vm instead you will enter in to automatic fsck. If that automatic fsck is completed successfully then you
will enter in to the single user mode otherwise you will be displayed by the error message below.(just major part of the errors)




/dev/hda2: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
        (i.e., without -a or -p options)
fsck died with exit status 4
failed (code 4).
An automatic file system check (fsck) of the root filesystem failed. A manual fsck must be performed, then the system restarted. The fsck should be performed in maintenance mode with the root filesystem mounted in read-only mode. failed!
The root filesystem is currently mounted in read-only mode. A maintenance shell will now be started. After performing system maintenance, press CONTROL-D to terminate the maintenance shell and restart the system. (warning).
Give root password for maintenance
(or type Control-D to continue):


Our current task is to reset the root password, but we are now in the situation like old root password is necessary. We have fix for this also.


like explained above mount the problem vm disk image in anothe mount point.


for ex:
mount -o loop /dev/VolGroup01/xenvpsa_rootimg /test


then edit the shadow file,


vi /test/etc/shadow
root:$6$GkB2ABuH$cjZCeh3JaT2ZnfIO7yz.743luzCpRx/dTgwccWZ/wUeLZu.PYHuG8/qzMezcaj9r37pOud1xheM2TLSq1WkVB0:15289:0:99999:7:::
bin:$1$RPTybk9p$k7lUO/hkluqGUfEZlcFhk/:14884:0:99999:7:::
daemon:*:15042:0:99999:7:::
sys:*:15042:0:99999:7:::
sync:*:15042:0:99999:7:::
games:*:15042:0:99999:7:


Change the root like below and save the file.
root::15289:0:99999:7:::


Now root has no password.


Give root password for maintenance
(or type Control-D to continue):


when you are showed by this just type enter you can enter in to the server. Run fsck manually and reset the root password without fail.


That's it we have done

Tuesday, September 20, 2011

nrpe&nagios plugin installation.txt

Nagios plugins and nrpe installation in remote host.

useradd nagios
passwd nagios

download the source files using the below links

wget https://api.opensuse.org/public/source/home:netmax/nagios-plugins/nagios-plugins-1.4.6.tar.gz?rev=285448d8f1b79ea7d33cc6ee74ba65a1&

wget http://space.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.8/nrpe-2.8.tar.gz


tar -xvzf nagios-plugins-1.4.6.tar.gz\?rev\=285448d8f1b79ea7d33cc6ee74ba65a1
tar -xvzf nrpe-2.8.tar.gz

cd nagios-plugins-1.4.6
./configure
make
make install

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

cd nrpe-2.8
./configure --enable-ssl
make all
make install-plugin
make install-daemon
make install-daemon-config

add the 5666 port no in /etc/services

Add the nagios host IP in the Allowed Host Directive of the nrpe.cfg file.

allowed_hosts=127.0.0.1,x.x.x.x

make sure that both the remote host and nagios hosts servers firewall blocks eachother ip's.

start nrpe plugin use the command below.

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

netstat -nat | grep 5666 or lsof -i tcp:5666

make sure that 5666 port listening

check whether nrpe is working,

/usr/local/nagios/libexec/check_nrpe -H localhost

if this returns the nrpe version then its working.


rndc issues

While restarting named or any services in the server, if you get the below log in Syslog or in messages

Sep 20 14:44:14 named[13573]: isc_socket_create: fcntl/reserved: Too many open
files
Sep 20 14:44:14 named[13573]: could not listen on UDP socket: not enough free resources

in addition in this time..you will have a issues in rndc also like below.

root@#rndc status
rndc: connect failed: 127.0.0.1#953: connection refused


due to this issues the newly created domains will not work because the IP associated with the new domains will not bind with the DNS.

if you do...

root@#telnet <new-ip> 25
connect failed: 127.0.0.1#953: connection refused
you will get the same error as like rndc.

Solution:

the problem is due to the user limit exceeded.

root@# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 106496
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 106496
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited


The output will be like above.

open files (-n) 1024

increase this limit to 2000

root@#ulimit -n 2000

logout the terminal and login so that you can see the change. Now restart named and do rndc reload, telnet to newip for the port 53, everything will work.

Wednesday, June 22, 2011

URL redirection with masking

Here is how to redirect a domain with masking the URL


For ex: 
We need to redirect the domain "abc.com" to "xyz.com". If  we redirect the domain using htaccess redirection using the code below 



RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ "http\:\/\/www\.xyz\.com" [L]


When we access the domain "abc.com" it will redirect to "xyz.com" but the address bar shows "xyz.com" only not 'abc.com".


so we need to mask the "xyz.com" domain name using the script below.


You need to add the below code in the "index.html" file of the domain in which you are going to add redirect.


#root@test[~] vi index.html


<html>


<head>

<title>Same Title As Your Homepage</title>
<!--incase they have javascript turned off-->

<script type="text/javascript">
<!--changes title bar to match title on current page in frame-->
function changeTitle()
   {
   if (top.frames['main'].document.title)
      {
      top.document.title=top.frames['main'].document.title;
      }
   }
</script>
</head>


<frameset>
<frame name="main"
src="http://xyz.com"scrolling="auto"
target="main" ONLOAD="changeTitle();">
<!--You need the onload handler to make the javascript work-->

<noframes>

<body>
Place a suitable message here for people with browsers that can't read
frames.
</body>

</noframes>

</frameset>

</html>

In this scenario we are redirecting the domain to "xyz.com" so I have given the 
URL like that.

Now if you access the domain "abc.com" it will display the page of the "xyz.com" but the URL in the address will be "abc.com".






Wednesday, April 6, 2011

How to upgrade kernel in Linux CentOS

Here's is the guide for you all to update kernel in Linux..especially in Centos...

Why the need for upgrading Kernel..might be your existing kernel crashes periodically...or the update you need would not be available in the current Linux version....However if we get a situation to upgrade Linux kernel...do the following...

The most important thing is if you update the kernel..it will automatically update some of the packages like httpd, MySQL. If you want to exclude these changes modify the file,

/etc/yum.conf 
as 
[main]
exclude=courier* apache* mod_ssl* httpd* perl mysql* php* spamassassin* exim*
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=centos-release
tolerant=1
exactarch=1
retries=20
obsoletes=1
gpgcheck=1

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

First you need to check the current version of  Kernel..type the below command in the prompt

uname -a

Most of the admin uses "yum upgrade kernel" to update the Kernel version..

yum upgrade kernel

Nothing to do.

the newer kernel version is not present in the Repo you are curretly using, you need to find out the corresponding  repo for the needed kernel...

here...we are going to upgrade the kernel from,


kernel-2.6.18-32  to kernel-2.6.18-238.5.1.1

but that kernel version was not found in the default repo....
so we need to find a exact one...
for this version I have found one which is given below...

Create a new file called centalt.repo file in /etc/yum.repos.d/ and paste the below 
contents.....

[CentALT]
name=CentALT Packages for Enterprise Linux 5 - $basearch
baseurl=http://centos.alt.ru/repository/centos/5/$basearch/
enabled=1
gpgcheck=0

Then try 

yum update kernel*

It will automatically add a new entry in grub.conf file....so just reboot the server and check..

uname -a

Kernel version is Updated ! ! ! !

Sunday, February 20, 2011

Upgrade Joomla from 1.5.x to 1.5.22

Upgrade Joomla from 1.5.x to 1.5.22:
----------------------------------------------

The most important point before proceeding is to take a backup of the mysql database which used by your Joomla.

1.Download the component 'com_jupdateman_151.tgz' from the Site "http://joomlacode.org/gf/project/pasamioprojects/frs/?action=FrsReleaseBrowse&frs_package_id=4728"

2.Install the component. After that use the component by going to Components >> Update Manager.

3.Select the 'Download the Updated File' link to download the latest version of the Joomla.

4.Choose the Patch Package version when prompted.  A full package is not required for upgrading from 1.5.x. to 1.5.22.

Thats all upgrade Completed Successfully ! ! ! ! !


Errors and fixes:
----------------------

1.If you face any error while upgrading Joolma, there might be corrupted table so you need to repair the mysql tables to fx it.

2.After upgrading the Joomla to 1.5.22 if you got blank page then at the spot you need to restore the database which you have dumped already.

Sunday, January 23, 2011

How to migrate joomla from version 1.0 to 1.5

Here is how to Migrate Joomla from version 1.0 to 1.5.x stable

The most important thing before proceeding with the steps below is to take the backup of  the current Joomla you are having and also database it will be safe.

1. You need to install the component called migrator for the current version of  Joomla1.0.x

2. Then go to "Components" option in your Joomla admin page then select "Migrator"

3. Then select the "Create Migration SQL" file option



4. Then download the SQL file using the download option and place it in the Local system or FTP it to your server



 5. Download the Stable release Joomla 1.5 from Joomla from the site below and
http://www.joomla.org/download.html

6. Step 4. Perform the migration
Proceed with the installation until you reach Step 6: Configuration:


 7. Fill the site name, email, admin user name and password . The imp thing to keep on mind is to select the option 'Load Migration Script'.




8. Fill the old table prefix _jos and leave the encoding unchanged unless needed and you are familiar with this option.

By clicking on the [Browse] button you should select the Joomla 1.0.x migration dump you downloaded earlier.

Make sure to check the This script is a Joomla! 1.0 migration script. check box as well.
Proceed by clicking on the [Upload and execute] button.

Once the data is imported you will see the following screen


9.As always remove the installation directory and access the joomla admin.