Friday, August 4, 2017

rescan the increased fc lun size in RHEL


[root@oxygen ~]# multipath -ll mpathb
mpathb (9mxD76oL/xPu9FBVIItP6wFFt9Y23/A7Lw73wOd9bLRb) dm-0 DGC,VRAID
size=200G features='1 queue_if_no_path' hwhandler='1 emc' wp=rw
|-+- policy='round-robin 0' prio=1 status=active
| |- 1:0:1:1  sdk  8:160  active ready running
| `- 2:0:1:1  sdaa 65:160 active ready running
`-+- policy='round-robin 0' prio=0 status=enabled
  |- 1:0:0:1  sdc  8:32   active ready running
  `- 2:0:0:1  sds  65:32  active ready running
[root@oxygen ~]# echo 1 > /sys/block/sdk/device/rescan
[root@oxygen ~]# echo 1 > /sys/block/sdaa/device/rescan
[root@oxygen ~]# echo 1 > /sys/block/sdc/device/rescan
[root@oxygen ~]# echo 1 > /sys/block/sds/device/rescan
[root@oxygen ~]# multipathd -k
multipathd> resize map mpathb
ok
multipathd>
[root@oxygen ~]# multipath -ll mpathb
mpathb (9mxD76oL/xPu9FBVIItP6wFFt9Y23/A7Lw73wOd9bLRb) dm-0 DGC,VRAID
size=700G features='1 queue_if_no_path' hwhandler='1 emc' wp=rw
|-+- policy='round-robin 0' prio=1 status=enabled
| |- 1:0:1:1  sdk  8:160  active ready running
| `- 2:0:1:1  sdaa 65:160 active ready running
`-+- policy='round-robin 0' prio=0 status=enabled
  |- 1:0:0:1  sdc  8:32   active ready running
  `- 2:0:0:1  sds  65:32  active ready running
[root@oxygen ~]# pvs
  PV                   VG       Fmt  Attr PSize   PFree
  /dev/mapper/mpathb   datavg   lvm2 a--  200.00g      0
[root@oxygen ~]# pvresize  /dev/mapper/mpathb
  Physical volume "/dev/mapper/mpathb" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[root@oxygen ~]# pvs
  PV                   VG       Fmt  Attr PSize   PFree
  /dev/mapper/mpathb   datavg   lvm2 a--  700.00g 500.00g
Share:

Tuesday, June 13, 2017

boot RHEL7/Centos 7 in single user mode

if you want to boot into single user mode of RHEL7 or Centos 7 in order to reset root password or do any other recovery work. You can follow the steps below.

1. Boot or reboot the server
2. Go to Grub2 OS boot selection menu
3. press e to go into edit mode.
4. append init=/bin/sh to line starting with linux.
5. Press Ctrl+x to boot to shell prompt
6. Now you can remount root partition with rw option ( #mount -o remount,rw /)
7. then change the password using passwd command.
Share:

Friday, February 17, 2017

get list of memory consuming processes

the below two commands will provide you the processes which are consuming maximum memory on Linux machine.

#ps -A --sort -rss -o comm,pmem | head -10
#ps axu | awk '{print $2, $3, $4, $11}' | head -1 && ps axu | awk '{print $2, $3, $4, $11}' | sort -k3 -nr |head -10
Share:

Monday, January 16, 2017

logrotate config for syslogs

here is an example of logrotate script/config file I use for syslogs.

[root@oxygen ~]# cat /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron 
{
    rotate 5
    compress
    size 50M
    create 0600 root root
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
        /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}
Share:

Monday, March 28, 2016

how to find wwn information of hba cards under linux

On Red Hat Enterprise Linux & openSUSE, you can run below command to get World Wide Name of a HBA card.

# systool -c fc_host -v | grep "port_name"

Note : systool command is provided by sysfsutils package.

alternative command for the same thing that should work in any standard Linux kernel.

# cat /sys/class/scsi_host/host*/device/fc_host/host*/node_name



Share:

Tuesday, December 22, 2015

nic bonding / teaming in centos 7

list all available NICs

# nmcli -p dev status
================================================
               Status of devices
================================================
DEVICE  TYPE      STATE      CONNECTION
------------------------------------------------
ens192  ethernet  connected  ens192
ens224  ethernet  connected  ens224
lo      loopback  unmanaged  --
[root@centos7 ~]#

add interface with ipv4 only address, two slaves and active-backup

#nmcli connection add type bond ifname bond0 con-name bond0 mode balance-rr primary ens192 miimon 200 ip4 192.168.0.2 gw4 192.168.0.1
#nmcli connection mod bond0 ipv4.dns “192.168.0.1” ipv6.method “ignore”
#nmcli connection add type bond-slave ifname ens192 master bond0
#nmcli connection add type bond-slave ifname ens224 master bond0

activate the newly created bond /team connection

#nmcli c u bond0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)

Verify the connectivity.

#nmcli network connectivity
full

[root@centos7 ~]# nmcli -p connection show bond0
===============================================================================
                      Connection profile details (bond0)
===============================================================================
connection.id:                          bond0
connection.uuid:                        XXXXXXX-XXXXX-XXXX-XXXXX-XXXXXXXX
connection.interface-name:              bond0
connection.type:                        bond
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
<--------------------->
Share:

Tuesday, December 1, 2015

disable ipv6 on rhel/centos version 5 / 6 / 7

on RHEL5

# cat /proc/sys/net/ipv6/conf/all/disable_ipv6
0
# echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
# cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1


on RHEL6 and RHEL7

# cat /proc/sys/net/ipv6/conf/all/disable_ipv6
0
# cat /proc/sys/net/ipv6/conf/default/disable_ipv6
0
# echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
# echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
# cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1
# cat /proc/sys/net/ipv6/conf/default/disable_ipv6
1
Share:

Monday, November 23, 2015

monitoring linux host with sar utility

you can use sar to monitor your Linux system effectively.

use the below command to redirect output to a file. i.e. to save data for that email to customer :)
[root@localhost ~]# sar -f /tmp/sardata


[root@localhost ~]# sar 2 4 -o /tmp/sardata > /dev/null 2>&1

now you can use the below one to read that file too.

[root@oxygen ~]# sar -f /var/log/sa/sa01
Linux 2.6.32-504.8.1.el6.x86_64 (oxygen)   06/01/20XX      _x86_64_        (4 CPU)

12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM     all      0.11     10.75      4.47      0.02      0.00     84.66
12:20:01 AM     all      0.08     11.07      4.56      0.01      0.00     84.29
12:30:01 AM     all      0.08     10.68      4.37      0.01      0.00     84.87
12:40:01 AM     all      0.08      9.94      4.07      0.00      0.00     85.90
12:50:01 AM     all      0.08      9.15      3.95      0.01      0.00     86.81
01:00:01 AM     all      0.07      9.75      4.37      0.01      0.00     85.80
01:10:01 AM     all      0.07      9.08      3.85      0.02      0.00     86.98
01:20:01 AM     all      0.07      9.14      3.81      0.01      0.00     86.97
01:30:01 AM     all      0.07      9.58      3.88      0.34      0.00     86.12
01:40:01 AM     all      0.07      9.30      3.80      0.08      0.00     86.75
01:50:01 AM     all      0.07      9.49      3.81      0.03      0.00     86.60

memory stats using sar

[root@oxygen ~]# sar -r 1 1
Linux 2.6.32-504.8.1.el6.x86_64 (oxygen)   06/06/20XX      _x86_64_        (4 CPU)

07:29:28 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
07:29:29 AM  10752692   5581480     34.17     81152   1423220   1058436      5.16
Average:     10752692   5581480     34.17     81152   1423220   1058436      5.16


disk stats using sar

[root@oxygen ~]# sar -d -p 1 1
Linux 2.6.32-504.8.1.el6.x86_64 (oxygen)   06/06/20XX      _x86_64_        (4 CPU)

07:28:04 AM       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
07:28:05 AM      scd0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM       sdb      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM       sda      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-root_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-swap_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM datavg-datalv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM infravg-images_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-usr_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-opt_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-tmp_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-var_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-home_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
07:28:05 AM rootvg-system_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
Average:         scd0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:          sdb      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:          sda      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-root_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-swap_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    datavg-datalv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    infravg-images_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-usr_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-opt_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-tmp_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-var_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-home_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:    rootvg-system_lv      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
[root@oxygen ~]# 
Share:

Friday, June 5, 2015

rescan new lun/ vdisk in linux

Use below for loop to detect new LUN assignments on existing HBA

#for host in `ls /sys/class/scsi_host/`;
do echo "- - -" >/sys/class/scsi_host/${host}/scan
done

echo "c t l" >  /sys/class/scsi_host/hostH/scan

Now rescan each of these devices.

The three values stand for channel, target, and LUN. The dashes act as wildcards meaning "rescan everything"

Use below commands when you are expanding existing disk in VM.

[root@rhel7test1 ~]# ls /sys/class/scsi_device/
2:0:0:0  2:0:1:0  2:0:2:0  2:0:3:0  3:0:0:0

[root@rhel7test1 ~]# echo 1> /sys/class/scsi_device/2\:0\:0\:0/device/rescan
[root@rhel7test1 ~]# echo 1> /sys/class/scsi_device/2\:0\:1\:0/device/rescan
[root@rhel7test1 ~]# echo 1> /sys/class/scsi_device/2\:0\:2\:0/device/rescan
[root@rhel7test1 ~]# echo 1> /sys/class/scsi_device/2\:0\:3\:0/device/rescan
[root@rhel7test1 ~]# echo 1> /sys/class/scsi_device/3\:0\:0\:0/device/rescan

You can also use rescan-scsi-bus.sh utility. Install the sg3_utils package

[root@rhel7test1 ~]# rescan-scsi-bus.sh
which: no multipath in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
Scanning SCSI subsystem for new devices
Scanning host 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 1 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 2 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
 Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
      Vendor: VMware   Model: Virtual disk     Rev: 1.0
      Type:   Direct-Access                    ANSI SCSI revision: 02
 Scanning for device 2 0 1 0 ...
OLD: Host: scsi2 Channel: 00 Id: 01 Lun: 00
      Vendor: VMware   Model: Virtual disk     Rev: 1.0
      Type:   Direct-Access                    ANSI SCSI revision: 02
 Scanning for device 2 0 2 0 ...
OLD: Host: scsi2 Channel: 00 Id: 02 Lun: 00
      Vendor: VMware   Model: Virtual disk     Rev: 1.0
      Type:   Direct-Access                    ANSI SCSI revision: 02
 Scanning for device 2 0 3 0 ...
OLD: Host: scsi2 Channel: 00 Id: 03 Lun: 00
      Vendor: VMware   Model: Virtual disk     Rev: 1.0
      Type:   Direct-Access                    ANSI SCSI revision: 02
Scanning host 3 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
 Scanning for device 3 0 0 0 ...
OLD: Host: scsi3 Channel: 00 Id: 00 Lun: 00
      Vendor: NECVMWar Model: VMware SATA CD00 Rev: 1.00
      Type:   CD-ROM                           ANSI SCSI revision: 05
Scanning host 4 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 5 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 6 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 7 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 8 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 9 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 10 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 11 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 12 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 13 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 14 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 15 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 16 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 17 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 18 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 19 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 20 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 21 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 22 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 23 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 24 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 25 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 26 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 27 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 28 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 29 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 30 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 31 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 32 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
0 new or changed device(s) found.
0 remapped or resized device(s) found.
0 device(s) removed.
Share:

Tuesday, July 15, 2014

autoremove feature of Linux package management tools

Today, I was just trying to install inxi on my mint desktop and the aptitude not only told that its already installed but also figured out to provide the list of package no longer required by my desktop. This is something which is missing on yum in dependency resolution. This functionality is also available in yum on RedHat based distros.


it's called autoremove option in aptitude. see the output below.
From man page of apt-get

autoremove
autoremove is used to remove packages that were
automatically installed to satisfy dependencies for
other packages and are now no longer needed.


# apt-get install inxi
Reading package lists... Done
Building dependency tree 
Reading state information... Done
inxi is already the newest version.
The following packages were automatically installed and are no longer required
augeas-lenses cgroup-lite libaugeas0 libgtk-vnc-1.0-0 libgvnc-1.0-0
libnetcf1 libvirt0 python-gtk-vnc python-libvirt python-urlgrabber virtinst
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 25 not upgraded.

# apt-get autoremove
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following packages will be REMOVED:
augeas-lenses cgroup-lite libaugeas0 libgtk-vnc-1.0-0 libgvnc-1.0-0
libnetcf1 libvirt0 python-gtk-vnc python-libvirt python-urlgrabber virtinst
0 upgraded, 0 newly installed, 11 to remove and 25 not upgraded.
After this operation, 9,200 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 166773 files and directories currently installed.)
Removing libnetcf1 (1:0.2.3-4ubuntu1) ...
Removing libaugeas0 (1.2.0-0ubuntu1) ...
Removing augeas-lenses (1.2.0-0ubuntu1) ...
Removing cgroup-lite (1.9) ...
cgroup-lite stop/waiting
Removing python-gtk-vnc (0.5.3-0ubuntu2) ...
Removing libgtk-vnc-1.0-0 (0.5.3-0ubuntu2) ...
Removing libgvnc-1.0-0 (0.5.3-0ubuntu2) ...
Removing virtinst (0.600.4-3ubuntu2) ...
Removing python-libvirt (1.2.2-0ubuntu1) ...
Removing libvirt0 (1.2.2-0ubuntu13.1) ...
Removing python-urlgrabber (3.9.1-4ubuntu3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
Processing triggers for man-db (2.6.7.1-1) ...
Share:

Saturday, March 1, 2014

unusual file system usage in linux

If you ever come across a situation where the df command and du commands reporting different size of the same file system. The main cause of this are the files being written by applications after the files have been deleted by users on the file system. du/ls command will not show these files. Hence the conflict between du and df. You can view those files using lsof |grep deleted command. Then you can kill those processes or restart the concerned application to reclaim space.

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
50G 16G 32G 34% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 504M 121M 358M 26% /boot
/dev/sda2
104G 96G 2.8G 98% /local
# du -sh /local
11G /local

# lsof |grep deleted
httpd 477 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 865 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 1312 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 1393 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 1532 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 2022 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 2640 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 2763 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 2909 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 3047 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
httpd 3048 root 5w REG 253,2 90780834079 9848484 /local/access.log (deleted)
Share:

Copyright © diary | Powered by Blogger

Design by Anders Norén | Blogger Theme by NewBloggerThemes.com