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

Wednesday, January 21, 2015

A complete list of FORMAT control characters supported by the date command

A complete list of FORMAT control characters supported by the date command

FORMAT controls the output. It can be the combination of any one of the following:
%FORMAT StringDescription
%%a literal %
%alocale's abbreviated weekday name (e.g., Sun)
%Alocale's full weekday name (e.g., Sunday)
%blocale's abbreviated month name (e.g., Jan)
%Blocale's full month name (e.g., January)
%clocale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%Ccentury; like %Y, except omit last two digits (e.g., 21)
%dday of month (e.g, 01)
%Ddate; same as %m/%d/%y
%eday of month, space padded; same as %_d
%Ffull date; same as %Y-%m-%d
%glast two digits of year of ISO week number (see %G)
%Gyear of ISO week number (see %V); normally useful only with %V
%hsame as %b
%Hhour (00..23)
%Ihour (01..12)
%jday of year (001..366)
%khour ( 0..23)
%lhour ( 1..12)
%mmonth (01..12)
%Mminute (00..59)
%na newline
%Nnanoseconds (000000000..999999999)
%plocale's equivalent of either AM or PM; blank if not known
%Plike %p, but lower case
%rlocale's 12-hour clock time (e.g., 11:11:04 PM)
%R24-hour hour and minute; same as %H:%M
%sseconds since 1970-01-01 00:00:00 UTC
%Ssecond (00..60)
%ta tab
%Ttime; same as %H:%M:%S
%uday of week (1..7); 1 is Monday
%Uweek number of year, with Sunday as first day of week (00..53)
%VISO week number, with Monday as first day of week (01..53)
%wday of week (0..6); 0 is Sunday
%Wweek number of year, with Monday as first day of week (00..53)
%xlocale's date representation (e.g., 12/31/99)
%Xlocale's time representation (e.g., 23:13:48)
%ylast two digits of year (00..99)
%Yyear
%z+hhmm numeric timezone (e.g., -0400)
%:z+hh:mm numeric timezone (e.g., -04:00)
%::z+hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::znumeric time zone with : to necessary precision (e.g., -04, +05:30)
%Zalphabetic time zone abbreviation (e.g., EDT)