This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Monday, November 6, 2017

How to Rebuild initramfs (initrd) on RHEL6?

Monday, November 06, 2017
 The mkinitrd command was used to rebuild the initial ramdisk on prior versions of RHEL . This has been replaced in RHEL6 with dracut.

The equivalent command to rebuild the initramfs for the running kernel on RHEL6 is:

$dracut -f /boot/initramfs-$(uname -r).img $(uname -r)

Hope it helps.

Sunday, November 5, 2017

Single command to list the software packages (RPMs) by install date in Linux Server

Sunday, November 05, 2017
Occasionally one needs to get a list of all software packages (rpm's) installed on a RHEL host, sorted by their install date. While there are many ways to do this

# rpm -qa --last


 copy and paste the following scriptlet into a shell command line:

#rpm -qa --queryformat="%{INSTALLTIME} %{NAME}\n" | sort -n | while read rpm_line; do rpm_date=$( date -d @$(echo $rpm_line | awk '{print $1}')); rpm=$( echo $rpm_line | awk '{print $2}'); printf '%-50s %s\n' "$rpm" "$rpm_date"; done
Hope it helps

Saturday, November 4, 2017

How to Manually Deactivate a High Available cluster volume group?

Saturday, November 04, 2017
Follow the below steps 

unmount all filesystem assocated with the VG:

#umount <mount_point>

deactivate the cluster VG:

#vgchange –a n HAVG_<vgname>

Remove all hostname tags from the VG:

#vgchange –-deltag <server_name> HAVG_<vgname>

Friday, November 3, 2017

Changing the Auto logout Timeout in SSH

Friday, November 03, 2017 0

The ssh "timed out waiting for input: auto-logout" messages is generated by ssh upon reaching a auto-logout after an inactivity time specified by the TMOUT environment variable. If this variable is not set your session will not be auto-logged out due to inactivity. If the environment variable is set, your session will be automatically closed/logged out after the amount of seconds specified by the TMOUT variable.

To see if your auto-logout variable is set and/or see what it is set to issue the following command:

[root@localhost ~]# timed out waiting for input: auto-logout

[root@localhost ~]# echo $TMOUT

Often this value is defined in /etc/profile (globally) or your user's profile (~/.profile or ~/.bash_profile).

To alter the auto-logout amount, set the TMOUT environment variable accordingly:

* TMOUT=120   #set an auto-logout timeout for  2 minutes

* TMOUT=1200  #set an auto-logout timeout for 20 minutes

* TMOUT=   #turn off auto-logout (user session will not auto-logout due to session inactivity)

This value can be set globally (e.g. TMOUT=1200) in the /etc/profile file; however, each user can override the value by setting the TMOUT variable in their personal profile file (~/.profile or ~/.bash_profile). To do this simply set the TMOUT variable as you like in your profile file.

Dont forget to source the file you changed to get the settings to take effect immediately or log out and log back in.

I hope the article was useful.

SOLVED : pam_ldap: error trying to bind as user

Friday, November 03, 2017
If you are getting error below after giving the correct password

Nov  2 03:56:42 testserver sshd[30173]: pam_ldap: error trying to bind as user "uid=testuser,ou=People,dc=test,dc=testdomain,dc=com" (Invalid credentials)

Nov  2 03:56:43 testserver sshd[30173]: Failed password for testuser from port 51306 ssh2

Reason: Password is not syncing properly to all client server during the scheduled window

Solution : Restart the slapd service on LDAP server & it will sync to all server.

#/etc/init.d/slapd restart

Hope it helps.

Thursday, November 2, 2017

How to create New Volume Group in RHEL Cluster?

Thursday, November 02, 2017 0

Follow the below steps to create Volume Group in RHEL Cluster

1. Add the disk to the server.

2. Pvcreate the new partitions

3. Create the VG’s

vgcreate -c n -s 32M HAVG_<vg_name> /dev/mapper/mpath#p#

-s : Sets the physical extent size on physical volumes of this volume group
-c : If clustered locking is enabled, this defaults to y indicating that this Volume Group is shared with other nodes in the cluster

Creating a new Logical volume to a HA Volume group

To create a LV to a newly created volume group you have to add the hostname tag to the VG. This will permit one server in the cluster to have access to the volume group at a given time.

1. vgchange --addtag <hostname> HAVG_<vg_name>
2. lvcreate –L ##M –n lv-<lvname> HAVG_<vg_name>
3. mke2fs –j /dev/HAVG_<vg_name>/lv-<lvname>

Create mountpoints on all nodes in the cluster. Do not add to /etc/fstab

1. mkdir <mount_point>
2. mount /dev/HAVG_<vg_name>/lv-<lvname> <mount_point>
3. Change permissions on mountpoint.

Wednesday, November 1, 2017

How to get the Old Hardware VM Version list with Powercli command?

Wednesday, November 01, 2017 0
Execute the  below command with the cluster name and required hardware version that all.

Get-Cluster "Cluster Name" | Get-VM | Get-View | Where {$_.Config.Version -ne "vmx-09"} |  Select Name

Hope it is useful.

How to Add and Remove Object Tags in Logical Volume Manager (Linux Server)?

Wednesday, November 01, 2017 0

Add or Delete tags, below steps will be used.

To add or delete tags from physical volumes, use the --addtag or --deltag option of the
 pvchange command.                                                                          
To add or delete tags from volume groups, use the --addtag or --deltag option of the 
vgchange or vgcreate commands.
To add or delete tags from logical volumes, use the --addtag or --deltag option of the 
lvchange or lvcreate commands.    

As of the Red Hat Enterprise Linux 6.1 release, you can specify multiple --addtag and --deltag arguments within asingle pvchange, vgchange, or lvchange command. For example, the following command deletes the tags T9 and T10 and adds the tags T13 and T14 to the volume group VGTEST

vgchange --deltag T9 --deltag T10 --addtag T13 --addtag T14 VGTEST