Monday, July 6, 2020

extend root filesystem size on VM

1. Increase the space as required in vcenter.
2. fdisk -l /dev/sda (Check the new space reflected)
3. create new partition with fdisk /dev/sda
4. Need a restart to reflect the new partition (if required)
5. add new partition -
a) pvcreate /dev/sda4
b) vgextend vg_system /dev/sda4
c) lvextended -L +50G /dev/mapper/vg_system
d) resize2fs /dev/mapper/vg_system

df -h

Friday, August 17, 2018

Re-create failed RAID0 in Linux software raid using mdadm command

Re-create failed RAID0 in Linux software raid using mdadm command

Disk involved: /dev/sd[b-j]

mdadm --detail /dev/md0

mdadm --stop /dev/md0

mdadm --zero-superblock /dev/sd[b-j]

mdadm -C /dev/md0 --level=raid0 --raid-devices=9 /dev/sd[b-j]

Validation:

:/root $ cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdj[8] sdi[7] sdh[6] sdg[5] sdf[4] sde[3] sdd[2] sdc[1] sdb[0]
      7187807232 blocks super 1.2 512k chunks

unused devices:
:/root $

:/root $ mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Thu Aug 16 11:21:10 2018
     Raid Level : raid0
     Array Size : 7187807232 (6854.83 GiB 7360.31 GB)
   Raid Devices : 9
  Total Devices : 9
    Persistence : Superblock is persistent

    Update Time : Thu Aug 16 11:21:10 2018
          State : clean
 Active Devices : 9
Working Devices : 9
 Failed Devices : 0
  Spare Devices : 0

     Chunk Size : 512K

           Name : oserxxxxx:0  (local to host oserxxxx)
           UUID : 12488bc6:ba504d23:602ecd04:5dd5622f
         Events : 0

    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb
       1       8       32        1      active sync   /dev/sdc
       2       8       48        2      active sync   /dev/sdd
       3       8       64        3      active sync   /dev/sde
       4       8       80        4      active sync   /dev/sdf
       5       8       96        5      active sync   /dev/sdg
       6       8      112        6      active sync   /dev/sdh
       7       8      128        7      active sync   /dev/sdi
       8       8      144        8      active sync   /dev/sdj
:/root $

Monday, March 6, 2017

find command

find . -name "tomcat-0.log*" -mtime +70 -exec ls -lrt {} \;

Friday, September 16, 2016

RHEL scan new LUNS

cd /root/storage/
cat scan.sh
#!/bin/bash

SLEEP_INTERVAL=30

echo "Scanning all fibre channel host adapters"

for i in `ls /sys/class/fc_host`
do
    echo "Rescanning /sys/class/fc_host/${i}:"

    echo "  Issuing a loop initialization on ${i}:"
    echo "1" > /sys/class/fc_host/${i}/issue_lip

    echo "  Scanning ${i} for new devices:"
    echo "- - -" > "/sys/class/scsi_host/${i}/scan"

    echo "Sleeping for ${SLEEP_INTERVAL} seconds"
    sleep ${SLEEP_INTERVAL}
done
---
multipath -ll | egrep '0a43|0a44|0a45|0a46|0a47' | sort

Create a template for new voting disk and add them into EOF /etc/multipath.conf

multipaths {

##############VOTING##############
multipath {
wwid 360060e80166f440000016f4400000a46
alias asmvoting001
}
multipath {
wwid 360060e80166f440000016f4400000a47
alias asmvoting002
}
multipath {
wwid 360060e80166f440000016f4400000a44
alias asmvoting003
}
multipath {
wwid 360060e80166f440000016f4400000a45
alias asmvoting004
}
multipath {
wwid 360060e80166f440000016f4400000a43
alias asmvoting005
}

}

add the following lines into  /etc/udev/rules.d/96-multipath-permission.rules
ACTION=="add|change", ENV{DM_UUID}=="*mpath-*" , ENV{DEVLINKS}=="/dev/mapper/asm*[a-z][0-9][0-9][0-9]*p1*", GROUP="oinstall", OWNER="grid", MODE="660"
multipath -F
service multipathd reload
multipath -ll | grep asm
multipath -ll | grep asm | sort
create a disk input file with the following content devlist

mapper/asmvoting001
mapper/asmvoting002
mapper/asmvoting003
mapper/asmvoting004
mapper/asmvoting005

vi devlist
mapper/asmvoting001
mapper/asmvoting002
mapper/asmvoting003
mapper/asmvoting004
mapper/asmvoting005

cat format_disk.sh
#! /bin/bash
ODEV="/oracle_asmdev";
if [ ! -d ${ODEV} ]
then
        /bin/mkdir ${ODEV}
        if [ $? -ne 0 ]
        then
                echo "mkdir ${ODEV} may have failed. Please investigate."
                exit 1
        fi
fi
check_disk() {
        /bin/dd if=/dev/${1} of=/dev/null bs=1048576 count=10
        if [ $? -ne 0 ]
        then
                echo "/dev/${1}p1 may not be configured correctly."
        fi
}
setup_device() {

        echo "2048,," | /sbin/sfdisk -uS /dev/${1} --force
        /sbin/partprobe /dev/${1}
        kpartx -a -v -p p /dev/${1}
}
setup_permission() {
        fdisk -l /dev/${1};
        #/bin/ln -s  /dev/"$1"p1 $2
        /bin/chown grid:oinstall $2
        /bin/chmod 0640 $2
}
echo -n "Enter rac env:eg - pgr2>"
read env
for rec in `cat devlist`
do
        asmrawdev=`echo $rec|cut -d"," -f1`
        asmdir=`echo $rec|cut -d"," -f2`
        echo "/dev/${asmrawdev}p1 -> ${ODEV}/$env-${asmdir}"
        if [ -b /dev/${asmrawdev} ]
        then
                echo "setup_device $asmrawdev ${ODEV}/$env-${asmdir}"
                setup_device $asmrawdev ${ODEV}/$env-${asmdir}
                echo "setup_permission $asmrawdev ${ODEV}/$env-${asmdir}"
                setup_permission $asmrawdev ${ODEV}/$env-${asmdir}
                echo "check_disk ${asmrawdev} ${ODEV}/$env-${asmdir}"
                check_disk ${asmrawdev} ${ODEV}/$env-${asmdir}
        else
                echo "/dev/${asmrawdev} does not exist"
        fi
done
exit 0
--
on 2nd and 3rd node
just update the /etc/multipath.conf and into  /etc/udev/rules.d/96-multipath-permission.rules file content same as first node

then scan for luns using the script /root/storage/scan.sh
---
multipath -F
service multipathd reload

Thursday, March 3, 2016

RHEL6 File system shrink

RHEL6 File system shrink
#take back-up
umount /opt

e2fsck -f /dev/mapper/VolGroup00-optvol
resize2fs /dev/mapper/VolGroup00-optvol 150G
lvchange -an /dev/mapper/VolGroup00-optvol
lvreduce -L 150G /dev/mapper/VolGroup00-optvol
lvchange -ay /dev/mapper/VolGroup00-optvol
e2fsck -f /dev/mapper/VolGroup00-optvol


RHEL6 File system extent on-line root fs

lvextend VolGroup00/rootvol -L +230G

resize2fs /dev/mapper/VolGroup00-rootvol 271G